Skip to content

Commit

Permalink
Use node prefix for build-in modules (#3340)
Browse files Browse the repository at this point in the history
It is basically a cosmetic thing, but has the following advantages:

1. Consistency with the official node documentation. The prefix is used
there.
2. It is easier to recognize the build-in modules.
  • Loading branch information
KristjanESPERANTO authored Jan 8, 2024
1 parent 407072d commit 4bbd35f
Show file tree
Hide file tree
Showing 28 changed files with 489 additions and 132 deletions.
9 changes: 5 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": ["eslint:recommended", "plugin:@stylistic/all-extends", "plugin:import/recommended", "plugin:jest/recommended", "plugin:jsdoc/recommended"],
"plugins": [],
"plugins": ["unicorn"],
"env": {
"browser": true,
"es2023": true,
"es2024": true,
"jest/globals": true,
"node": true
},
Expand All @@ -16,7 +16,7 @@
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2023,
"ecmaVersion": "latest",
"ecmaFeatures": {
"globalReturn": true
}
Expand Down Expand Up @@ -62,7 +62,8 @@
"@stylistic/indent": ["error", "tab"],
"@stylistic/semi": ["error", "always"],
"@stylistic/space-before-function-paren": ["error", "always"],
"@stylistic/spaced-comment": "off"
"@stylistic/spaced-comment": "off",
"unicorn/prefer-node-protocol": "error"
},
"overrides": [
{
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ _This release is scheduled to be released on 2024-04-01._

### Updated

- Use node prefix for build-in modules

### Fixed

- Skip changelog requirement when running tests for dependency updates (#3320)
Expand Down
4 changes: 2 additions & 2 deletions clientonly/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// Return new pending promise
return new Promise((resolve, reject) => {
// Select http or https module, depending on requested url
const lib = url.startsWith("https") ? require("https") : require("http");
const lib = url.startsWith("https") ? require("node:https") : require("node:http");
const request = lib.get(url, (response) => {
let configData = "";

Expand Down Expand Up @@ -94,7 +94,7 @@

// Spawn electron application
const electron = require("electron");
const child = require("child_process").spawn(electron, ["js/electron.js"], options);
const child = require("node:child_process").spawn(electron, ["js/electron.js"], options);

// Pipe all child process output to current stdout
child.stdout.on("data", function (buf) {
Expand Down
4 changes: 2 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// Alias modules mentioned in package.js under _moduleAliases.
require("module-alias/register");

const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");
const envsub = require("envsub");
const Log = require("logger");

Expand Down
4 changes: 2 additions & 2 deletions js/check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.
*/
const path = require("path");
const fs = require("fs");
const path = require("node:path");
const fs = require("node:fs");
const { Linter } = require("eslint");

const linter = new Linter();
Expand Down
8 changes: 4 additions & 4 deletions js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* By Michael Teeuw https://michaelteeuw.nl
* MIT Licensed.
*/
const fs = require("fs");
const http = require("http");
const https = require("https");
const path = require("path");
const fs = require("node:fs");
const http = require("node:http");
const https = require("node:https");
const path = require("node:path");
const express = require("express");
const ipfilter = require("express-ipfilter").IpFilter;
const helmet = require("helmet");
Expand Down
4 changes: 2 additions & 2 deletions js/server_functions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");
const Log = require("logger");

const startUp = new Date();
Expand Down
2 changes: 1 addition & 1 deletion js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.
*/
const execSync = require("child_process").execSync;
const execSync = require("node:child_process").execSync;
const colors = require("colors/safe");
const Log = require("logger");
const si = require("systeminformation");
Expand Down
2 changes: 1 addition & 1 deletion modules/default/calendar/calendarfetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* MIT Licensed.
*/

const https = require("https");
const https = require("node:https");
const ical = require("node-ical");
const Log = require("logger");
const NodeHelper = require("node_helper");
Expand Down
2 changes: 1 addition & 1 deletion modules/default/calendar/calendarfetcherutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @external Moment
*/
const path = require("path");
const path = require("node:path");
const moment = require("moment");

const zoneTable = require(path.join(__dirname, "windowsZones.json"));
Expand Down
2 changes: 1 addition & 1 deletion modules/default/newsfeed/newsfeedfetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* MIT Licensed.
*/

const stream = require("stream");
const stream = require("node:stream");
const FeedMe = require("feedme");
const iconv = require("iconv-lite");
const { htmlToText } = require("html-to-text");
Expand Down
8 changes: 4 additions & 4 deletions modules/default/updatenotification/git_helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const fs = require("fs");
const path = require("path");
const util = require("node:util");
const exec = util.promisify(require("node:child_process").exec);
const fs = require("node:fs");
const path = require("node:path");
const Log = require("logger");

const BASE_DIR = path.normalize(`${__dirname}/../../../`);
Expand Down
4 changes: 2 additions & 2 deletions modules/default/updatenotification/update_helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Exec = require("child_process").exec;
const Spawn = require("child_process").spawn;
const Exec = require("node:child_process").exec;
const Spawn = require("node:child_process").spawn;
const commandExists = require("command-exists");
const Log = require("logger");

Expand Down
Loading

0 comments on commit 4bbd35f

Please sign in to comment.