From ae0b534fab117e97e5c6a32eccb0be84e681effd Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Mon, 10 Feb 2020 13:07:30 -0500 Subject: [PATCH 1/9] Update: deprecate Node.js & CommonJS rules --- docs/rules/callback-return.md | 2 ++ docs/rules/global-require.md | 2 ++ docs/rules/handle-callback-err.md | 2 ++ docs/rules/no-buffer-constructor.md | 2 ++ docs/rules/no-mixed-requires.md | 2 ++ docs/rules/no-new-require.md | 2 ++ docs/rules/no-path-concat.md | 2 ++ docs/rules/no-process-env.md | 2 ++ docs/rules/no-process-exit.md | 2 ++ docs/rules/no-restricted-modules.md | 2 ++ docs/rules/no-sync.md | 2 ++ lib/rules/callback-return.js | 4 ++++ lib/rules/global-require.js | 4 ++++ lib/rules/handle-callback-err.js | 4 ++++ lib/rules/no-buffer-constructor.js | 4 ++++ lib/rules/no-mixed-requires.js | 4 ++++ lib/rules/no-new-require.js | 4 ++++ lib/rules/no-path-concat.js | 4 ++++ lib/rules/no-process-env.js | 4 ++++ lib/rules/no-process-exit.js | 4 ++++ lib/rules/no-restricted-modules.js | 4 ++++ lib/rules/no-sync.js | 4 ++++ 22 files changed, 66 insertions(+) diff --git a/docs/rules/callback-return.md b/docs/rules/callback-return.md index ba27e23340d..a2abd28fcf5 100644 --- a/docs/rules/callback-return.md +++ b/docs/rules/callback-return.md @@ -1,5 +1,7 @@ # Enforce Return After Callback (callback-return) +This rule was **deprecated** in ESLint v7.0.0. + The callback pattern is at the heart of most I/O and event-driven programming in JavaScript. diff --git a/docs/rules/global-require.md b/docs/rules/global-require.md index c31134dcc62..3f0bb01c0b3 100644 --- a/docs/rules/global-require.md +++ b/docs/rules/global-require.md @@ -1,5 +1,7 @@ # Enforce require() on the top-level module scope (global-require) +This rule was **deprecated** in ESLint v7.0.0. + In Node.js, module dependencies are included using the `require()` function, such as: ```js diff --git a/docs/rules/handle-callback-err.md b/docs/rules/handle-callback-err.md index 5733e421729..5bc745c1947 100644 --- a/docs/rules/handle-callback-err.md +++ b/docs/rules/handle-callback-err.md @@ -1,5 +1,7 @@ # Enforce Callback Error Handling (handle-callback-err) +This rule was **deprecated** in ESLint v7.0.0. + In Node.js, a common pattern for dealing with asynchronous behavior is called the callback pattern. This pattern expects an `Error` object or `null` as the first argument of the callback. Forgetting to handle these errors can lead to some really strange behavior in your application. diff --git a/docs/rules/no-buffer-constructor.md b/docs/rules/no-buffer-constructor.md index f287ce57343..b49ec7846fb 100644 --- a/docs/rules/no-buffer-constructor.md +++ b/docs/rules/no-buffer-constructor.md @@ -1,5 +1,7 @@ # disallow use of the Buffer() constructor (no-buffer-constructor) +This rule was **deprecated** in ESLint v7.0.0. + In Node.js, the behavior of the `Buffer` constructor is different depending on the type of its argument. Passing an argument from user input to `Buffer()` without validating its type can lead to security vulnerabilities such as remote memory disclosure and denial of service. As a result, the `Buffer` constructor has been deprecated and should not be used. Use the producer methods `Buffer.from`, `Buffer.alloc`, and `Buffer.allocUnsafe` instead. ## Rule Details diff --git a/docs/rules/no-mixed-requires.md b/docs/rules/no-mixed-requires.md index ee63c99090a..eb98ed22a4a 100644 --- a/docs/rules/no-mixed-requires.md +++ b/docs/rules/no-mixed-requires.md @@ -1,5 +1,7 @@ # disallow `require` calls to be mixed with regular variable declarations (no-mixed-requires) +This rule was **deprecated** in ESLint v7.0.0. + In the Node.js community it is often customary to separate initializations with calls to `require` modules from other variable declarations, sometimes also grouping them by the type of module. This rule helps you enforce this convention. ## Rule Details diff --git a/docs/rules/no-new-require.md b/docs/rules/no-new-require.md index 5ffaf2ad464..02730309d22 100644 --- a/docs/rules/no-new-require.md +++ b/docs/rules/no-new-require.md @@ -1,5 +1,7 @@ # Disallow new require (no-new-require) +This rule was **deprecated** in ESLint v7.0.0. + The `require` function is used to include modules that exist in separate files, such as: ```js diff --git a/docs/rules/no-path-concat.md b/docs/rules/no-path-concat.md index 998ec10d978..023a171b83f 100644 --- a/docs/rules/no-path-concat.md +++ b/docs/rules/no-path-concat.md @@ -1,5 +1,7 @@ # Disallow string concatenation when using `__dirname` and `__filename` (no-path-concat) +This rule was **deprecated** in ESLint v7.0.0. + In Node.js, the `__dirname` and `__filename` global variables contain the directory path and the file path of the currently executing script file, respectively. Sometimes, developers try to use these variables to create paths to other files, such as: ```js diff --git a/docs/rules/no-process-env.md b/docs/rules/no-process-env.md index 9db800fa153..d5db9e74392 100644 --- a/docs/rules/no-process-env.md +++ b/docs/rules/no-process-env.md @@ -1,5 +1,7 @@ # Disallow process.env (no-process-env) +This rule was **deprecated** in ESLint v7.0.0. + The `process.env` object in Node.js is used to store deployment/configuration parameters. Littering it through out a project could lead to maintenance issues as it's another kind of global dependency. As such, it could lead to merge conflicts in a multi-user setup and deployment issues in a multi-server setup. Instead, one of the best practices is to define all those parameters in a single configuration/settings file which could be accessed throughout the project. diff --git a/docs/rules/no-process-exit.md b/docs/rules/no-process-exit.md index 0070a0965f1..e74af09b27e 100644 --- a/docs/rules/no-process-exit.md +++ b/docs/rules/no-process-exit.md @@ -1,5 +1,7 @@ # Disallow process.exit() (no-process-exit) +This rule was **deprecated** in ESLint v7.0.0. + The `process.exit()` method in Node.js is used to immediately stop the Node.js process and exit. This is a dangerous operation because it can occur in any method at any point in time, potentially stopping a Node.js application completely when an error occurs. For example: ```js diff --git a/docs/rules/no-restricted-modules.md b/docs/rules/no-restricted-modules.md index 7f9c926a1ef..de0894a30fd 100644 --- a/docs/rules/no-restricted-modules.md +++ b/docs/rules/no-restricted-modules.md @@ -1,5 +1,7 @@ # Disallow Node.js modules (no-restricted-modules) +This rule was **deprecated** in ESLint v7.0.0. + A module in Node.js is a simple or complex functionality organized in a JavaScript file which can be reused throughout the Node.js application. The keyword `require` is used in Node.js/CommonJS to import modules into an application. This way you can have dynamic loading where the loaded module name isn't predefined /static, or where you conditionally load a module only if it's "truly required". diff --git a/docs/rules/no-sync.md b/docs/rules/no-sync.md index 50ab515eef5..e8f46e09f45 100644 --- a/docs/rules/no-sync.md +++ b/docs/rules/no-sync.md @@ -1,5 +1,7 @@ # Disallow Synchronous Methods (no-sync) +This rule was **deprecated** in ESLint v7.0.0. + In Node.js, most I/O is done through asynchronous methods. However, there are often synchronous versions of the asynchronous methods. For example, `fs.exists()` and `fs.existsSync()`. In some contexts, using synchronous operations is okay (if, as with ESLint, you are writing a command line utility). However, in other contexts the use of synchronous operations is considered a bad practice that should be avoided. For example, if you are running a high-travel web server on Node.js, you should consider carefully if you want to allow any synchronous operations that could lock up the server. ## Rule Details diff --git a/lib/rules/callback-return.js b/lib/rules/callback-return.js index c5263cde46b..ba13c9a6481 100644 --- a/lib/rules/callback-return.js +++ b/lib/rules/callback-return.js @@ -10,6 +10,10 @@ module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { diff --git a/lib/rules/global-require.js b/lib/rules/global-require.js index 4af3a6a4669..469c0175d25 100644 --- a/lib/rules/global-require.js +++ b/lib/rules/global-require.js @@ -48,6 +48,10 @@ function isShadowed(scope, node) { module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { diff --git a/lib/rules/handle-callback-err.js b/lib/rules/handle-callback-err.js index 640946699e7..b92490ad16b 100644 --- a/lib/rules/handle-callback-err.js +++ b/lib/rules/handle-callback-err.js @@ -11,6 +11,10 @@ module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { diff --git a/lib/rules/no-buffer-constructor.js b/lib/rules/no-buffer-constructor.js index bf4c8891ad1..152dda0ceae 100644 --- a/lib/rules/no-buffer-constructor.js +++ b/lib/rules/no-buffer-constructor.js @@ -10,6 +10,10 @@ module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "problem", docs: { diff --git a/lib/rules/no-mixed-requires.js b/lib/rules/no-mixed-requires.js index 8e988e32c24..a02de9104bd 100644 --- a/lib/rules/no-mixed-requires.js +++ b/lib/rules/no-mixed-requires.js @@ -11,6 +11,10 @@ module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { diff --git a/lib/rules/no-new-require.js b/lib/rules/no-new-require.js index df12a424e35..063f783e70c 100644 --- a/lib/rules/no-new-require.js +++ b/lib/rules/no-new-require.js @@ -11,6 +11,10 @@ module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { diff --git a/lib/rules/no-path-concat.js b/lib/rules/no-path-concat.js index 9fa8b852fe8..fc1f894f878 100644 --- a/lib/rules/no-path-concat.js +++ b/lib/rules/no-path-concat.js @@ -10,6 +10,10 @@ module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { diff --git a/lib/rules/no-process-env.js b/lib/rules/no-process-env.js index 0f8d7f8a339..49d1734906e 100644 --- a/lib/rules/no-process-env.js +++ b/lib/rules/no-process-env.js @@ -10,6 +10,10 @@ module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { diff --git a/lib/rules/no-process-exit.js b/lib/rules/no-process-exit.js index 29871660cc6..77c9cfd7cbd 100644 --- a/lib/rules/no-process-exit.js +++ b/lib/rules/no-process-exit.js @@ -10,6 +10,10 @@ module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { diff --git a/lib/rules/no-restricted-modules.js b/lib/rules/no-restricted-modules.js index abd8d5cbe29..d0b8a78a507 100644 --- a/lib/rules/no-restricted-modules.js +++ b/lib/rules/no-restricted-modules.js @@ -40,6 +40,10 @@ const arrayOfStringsOrObjects = { module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { diff --git a/lib/rules/no-sync.js b/lib/rules/no-sync.js index d8111059631..06424e0b38f 100644 --- a/lib/rules/no-sync.js +++ b/lib/rules/no-sync.js @@ -13,6 +13,10 @@ module.exports = { meta: { + deprecated: true, + + replacedBy: [], + type: "suggestion", docs: { From 885e11f92772e8c5f8421013b12f6f28a1b71408 Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Thu, 2 Apr 2020 15:59:51 -0400 Subject: [PATCH 2/9] Upgrade eslint-plugin-node@11 --- lib/shared/relative-module-resolver.js | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/shared/relative-module-resolver.js b/lib/shared/relative-module-resolver.js index fa6cca72361..80335c5cfca 100644 --- a/lib/shared/relative-module-resolver.js +++ b/lib/shared/relative-module-resolver.js @@ -11,6 +11,7 @@ const Module = require("module"); * `Module.createRequire` is added in v12.2.0. It supports URL as well. * We only support the case where the argument is a filepath, not a URL. */ +// eslint-disable-next-line node/no-unsupported-features/node-builtins, node/no-deprecated-api const createRequire = Module.createRequire || Module.createRequireFromPath; module.exports = { diff --git a/package.json b/package.json index ed15f61d02b..1e03c72fad3 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "eslint-plugin-eslint-plugin": "^2.2.1", "eslint-plugin-internal-rules": "file:tools/internal-rules", "eslint-plugin-jsdoc": "^15.9.5", - "eslint-plugin-node": "^9.0.0", + "eslint-plugin-node": "^11.1.0", "eslint-release": "^1.2.0", "eslump": "^2.0.0", "esprima": "^4.0.1", From 0a97853e8b5a10204ca6695ee037f764f4ecf943 Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Thu, 2 Apr 2020 16:21:58 -0400 Subject: [PATCH 3/9] Update config/replaceBy fields --- lib/rules/callback-return.js | 2 +- lib/rules/global-require.js | 2 +- lib/rules/handle-callback-err.js | 2 +- lib/rules/no-buffer-constructor.js | 2 +- lib/rules/no-mixed-requires.js | 2 +- lib/rules/no-new-require.js | 2 +- lib/rules/no-path-concat.js | 2 +- lib/rules/no-process-env.js | 2 +- lib/rules/no-process-exit.js | 2 +- lib/rules/no-restricted-modules.js | 2 +- lib/rules/no-sync.js | 2 +- packages/eslint-config-eslint/default.yml | 14 +++++++------- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/rules/callback-return.js b/lib/rules/callback-return.js index ba13c9a6481..9c82da365a8 100644 --- a/lib/rules/callback-return.js +++ b/lib/rules/callback-return.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/callback-return.md"], type: "suggestion", diff --git a/lib/rules/global-require.js b/lib/rules/global-require.js index 469c0175d25..f5c1a4dee04 100644 --- a/lib/rules/global-require.js +++ b/lib/rules/global-require.js @@ -50,7 +50,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/global-require.md"], type: "suggestion", diff --git a/lib/rules/handle-callback-err.js b/lib/rules/handle-callback-err.js index b92490ad16b..bf8f04d1337 100644 --- a/lib/rules/handle-callback-err.js +++ b/lib/rules/handle-callback-err.js @@ -13,7 +13,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/handle-callback-err.md"], type: "suggestion", diff --git a/lib/rules/no-buffer-constructor.js b/lib/rules/no-buffer-constructor.js index 152dda0ceae..7dccbe59e20 100644 --- a/lib/rules/no-buffer-constructor.js +++ b/lib/rules/no-buffer-constructor.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-deprecated-api.md"], type: "problem", diff --git a/lib/rules/no-mixed-requires.js b/lib/rules/no-mixed-requires.js index a02de9104bd..08634d1628f 100644 --- a/lib/rules/no-mixed-requires.js +++ b/lib/rules/no-mixed-requires.js @@ -13,7 +13,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-mixed-requires.md"], type: "suggestion", diff --git a/lib/rules/no-new-require.js b/lib/rules/no-new-require.js index 063f783e70c..06cee722c4e 100644 --- a/lib/rules/no-new-require.js +++ b/lib/rules/no-new-require.js @@ -13,7 +13,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-new-require.md"], type: "suggestion", diff --git a/lib/rules/no-path-concat.js b/lib/rules/no-path-concat.js index fc1f894f878..f16e369f831 100644 --- a/lib/rules/no-path-concat.js +++ b/lib/rules/no-path-concat.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-path-concat.md"], type: "suggestion", diff --git a/lib/rules/no-process-env.js b/lib/rules/no-process-env.js index 49d1734906e..171e900be70 100644 --- a/lib/rules/no-process-env.js +++ b/lib/rules/no-process-env.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-process-env.md"], type: "suggestion", diff --git a/lib/rules/no-process-exit.js b/lib/rules/no-process-exit.js index 77c9cfd7cbd..51b8c02b1a6 100644 --- a/lib/rules/no-process-exit.js +++ b/lib/rules/no-process-exit.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-process-exit.md"], type: "suggestion", diff --git a/lib/rules/no-restricted-modules.js b/lib/rules/no-restricted-modules.js index d0b8a78a507..f3cc1b22090 100644 --- a/lib/rules/no-restricted-modules.js +++ b/lib/rules/no-restricted-modules.js @@ -42,7 +42,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-restricted-require.md"], type: "suggestion", diff --git a/lib/rules/no-sync.js b/lib/rules/no-sync.js index 06424e0b38f..b838cdbba91 100644 --- a/lib/rules/no-sync.js +++ b/lib/rules/no-sync.js @@ -15,7 +15,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: [], + replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-sync.md"], type: "suggestion", diff --git a/packages/eslint-config-eslint/default.yml b/packages/eslint-config-eslint/default.yml index 2082409ffa2..f9befd8c064 100644 --- a/packages/eslint-config-eslint/default.yml +++ b/packages/eslint-config-eslint/default.yml @@ -21,7 +21,6 @@ rules: block-spacing: "error" brace-style: ["error", "1tbs"] camelcase: "error" - callback-return: ["error", ["cb", "callback", "next"]] class-methods-use-this: "error" comma-dangle: "error" comma-spacing: "error" @@ -40,7 +39,6 @@ rules: function-paren-newline: ["error", "consistent"] generator-star-spacing: "error" guard-for-in: "error" - handle-callback-err: ["error", "err"] jsdoc/check-alignment: "error" jsdoc/check-param-names: "error" jsdoc/check-syntax: "error" @@ -78,7 +76,6 @@ rules: new-parens: "error" no-alert: "error" no-array-constructor: "error" - no-buffer-constructor: "error" no-caller: "error" no-confusing-arrow: "error" no-console: "error" @@ -97,7 +94,6 @@ rules: no-labels: "error" no-lone-blocks: "error" no-loop-func: "error" - no-mixed-requires: "error" no-mixed-spaces-and-tabs: ["error", false] no-multi-spaces: "error" no-multi-str: "error" @@ -106,13 +102,10 @@ rules: no-new: "error" no-new-func: "error" no-new-object: "error" - no-new-require: "error" no-new-wrappers: "error" no-octal: "error" no-octal-escape: "error" no-param-reassign: "error" - no-path-concat: "error" - no-process-exit: "error" no-proto: "error" no-redeclare: "error" no-restricted-properties: [ @@ -151,6 +144,13 @@ rules: no-useless-return: "error" no-whitespace-before-property: "error" no-var: "error" + node/callback-return: ["error", ["cb", "callback", "next"]] + node/handle-callback-err: ["error", "err"] + node/no-deprecated-api: "error" + node/no-mixed-requires: "error" + node/no-new-require: "error" + node/no-path-concat: "error" + node/no-process-exit: "error" object-curly-newline: ["error", { "consistent": true, "multiline": true }] object-curly-spacing: ["error", "always"] object-property-newline: ["error", { "allowAllPropertiesOnSameLine": true }] From c030d80a4fb5725faf72bfb83b08b33e5337b4e2 Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Thu, 2 Apr 2020 16:27:42 -0400 Subject: [PATCH 4/9] Fix lint errors --- lib/init/autoconfig.js | 2 +- lib/init/source-code-utils.js | 2 +- tests/bin/eslint.js | 10 ++++++---- tests/lib/linter/code-path-analysis/code-path.js | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/init/autoconfig.js b/lib/init/autoconfig.js index 64be3d2a84f..31fcd21923b 100644 --- a/lib/init/autoconfig.js +++ b/lib/init/autoconfig.js @@ -301,7 +301,7 @@ class Registry { ruleSetIdx += 1; if (cb) { - cb(totalFilesLinting); // eslint-disable-line callback-return + cb(totalFilesLinting); // eslint-disable-line node/callback-return } }); diff --git a/lib/init/source-code-utils.js b/lib/init/source-code-utils.js index dfc170a65cf..c95f64f69d3 100644 --- a/lib/init/source-code-utils.js +++ b/lib/init/source-code-utils.js @@ -97,7 +97,7 @@ function getSourceCodeOfFiles(patterns, options, callback) { sourceCodes[filename] = sourceCode; } if (callback) { - callback(filenames.length); // eslint-disable-line callback-return + callback(filenames.length); // eslint-disable-line node/callback-return } }); diff --git a/tests/bin/eslint.js b/tests/bin/eslint.js index 8b771dc5bf5..4895dff0523 100644 --- a/tests/bin/eslint.js +++ b/tests/bin/eslint.js @@ -8,7 +8,9 @@ const childProcess = require("child_process"); const fs = require("fs"); const assert = require("chai").assert; -const EXECUTABLE_PATH = require("path").resolve(`${__dirname}/../../bin/eslint.js`); +const path = require("path"); + +const EXECUTABLE_PATH = path.resolve(path.join(__dirname, "../../bin/eslint.js")); /** * Returns a Promise for when a child process exits @@ -166,7 +168,7 @@ describe("bin/eslint.js", () => { it("successfully handles more than 4k data via stdin", () => { const child = runESLint(["--stdin", "--no-eslintrc"]); - const large = fs.createReadStream(`${__dirname}/../bench/large.js`, "utf8"); + const large = fs.createReadStream(path.join(__dirname, "../bench/large.js"), "utf8"); large.pipe(child.stdin); @@ -182,7 +184,7 @@ describe("bin/eslint.js", () => { }); describe("automatically fixing files", () => { - const fixturesPath = `${__dirname}/../fixtures/autofix-integration`; + const fixturesPath = path.join(__dirname, "../fixtures/autofix-integration"); const tempFilePath = `${fixturesPath}/temp.js`; const startingText = fs.readFileSync(`${fixturesPath}/left-pad.js`).toString(); const expectedFixedText = fs.readFileSync(`${fixturesPath}/left-pad-expected.js`).toString(); @@ -359,7 +361,7 @@ describe("bin/eslint.js", () => { }); it("prints the error message pointing to line of code", () => { - const invalidConfig = `${__dirname}/../fixtures/bin/.eslintrc.yml`; + const invalidConfig = path.join(__dirname, "../fixtures/bin/.eslintrc.yml"); const child = runESLint(["--no-ignore", invalidConfig]); const exitCodeAssertion = assertExitCode(child, 2); const outputAssertion = getOutput(child).then(output => { diff --git a/tests/lib/linter/code-path-analysis/code-path.js b/tests/lib/linter/code-path-analysis/code-path.js index 9c0ae9ffc40..0c4fdd18328 100644 --- a/tests/lib/linter/code-path-analysis/code-path.js +++ b/tests/lib/linter/code-path-analysis/code-path.js @@ -50,7 +50,7 @@ function getOrderOfTraversing(codePath, options, callback) { codePath.traverseSegments(options, (segment, controller) => { retv.push(segment.id); if (callback) { - callback(segment, controller); // eslint-disable-line callback-return + callback(segment, controller); // eslint-disable-line node/callback-return } }); From cc70569180b7e1869e1ea866689a9fd479d3f055 Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Thu, 2 Apr 2020 16:49:56 -0400 Subject: [PATCH 5/9] Update .eslintrc.js --- .eslintrc.js | 151 ++++++++++++++++------------------ lib/init/source-code-utils.js | 2 +- 2 files changed, 73 insertions(+), 80 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 6ab4510cb37..0ca92dab810 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,13 +1,44 @@ "use strict"; -const internalFiles = [ - "**/cli-engine/**/*", - "**/init/**/*", - "**/linter/**/*", - "**/rule-tester/**/*", - "**/rules/**/*", - "**/source-code/**/*" -]; +const path = require("path"); + +const INTERNAL_FILES = { + CLI_ENGINE_PATTERN: "lib/cli-engine/**/*", + INIT_PATTERN: "lib/init/**/*", + LINTER_PATTERN: "lib/linter/**/*", + RULE_TESTER_PATTERN: "lib/rule-tester/**/*", + RULES_PATTERN: "lib/rules/**/*", + SOURCE_CODE_PATTERN: "lib/source-code/**/*" +}; + +/** + * Resolve an absolute path or glob pattern. + * @param {string} pathOrPattern the path or glob pattern. + * @returns {string} The resolved path or glob pattern. + */ +function resolveAbsPath(pathOrPattern) { + return path.resolve(__dirname, pathOrPattern); +} + +/** + * Create an array of `no-restricted-require` entries for ESLint's core files. + * @param {string} [pattern] The glob pattern to create the entries for. + * @returns {Object[]} The array of `no-restricted-require` entries. + */ +function createInternalFilesPatterns(pattern = null) { + return Object.values(INTERNAL_FILES) + .filter(p => p !== pattern) + .map(p => ({ + name: [ + + // Disallow all children modules. + resolveAbsPath(p), + + // Allow the main `index.js` module. + `!${resolveAbsPath(p.replace(/\*\*\/\*$/u, "index.js"))}` + ] + })); +} module.exports = { root: true, @@ -84,106 +115,68 @@ module.exports = { { files: ["lib/*"], rules: { - "no-restricted-modules": ["error", { - patterns: [ - ...internalFiles - ] - }] + "node/no-restricted-require": ["error", [ + ...createInternalFilesPatterns() + ]] } }, { - files: ["lib/cli-engine/**/*"], + files: [INTERNAL_FILES.CLI_ENGINE_PATTERN], rules: { - "no-restricted-modules": ["error", { - patterns: [ - ...internalFiles, - "**/init" - ] - }] + "node/no-restricted-require": ["error", [ + ...createInternalFilesPatterns(INTERNAL_FILES.CLI_ENGINE_PATTERN) + ]] } }, { - files: ["lib/init/**/*"], + files: [INTERNAL_FILES.INIT_PATTERN], rules: { - "no-restricted-modules": ["error", { - patterns: [ - ...internalFiles, - "**/rule-tester" - ] - }] + "node/no-restricted-require": ["error", [ + ...createInternalFilesPatterns(INTERNAL_FILES.INIT_PATTERN) + ]] } }, { - files: ["lib/linter/**/*"], + files: [INTERNAL_FILES.LINTER_PATTERN], rules: { - "no-restricted-modules": ["error", { - patterns: [ - ...internalFiles, - "fs", - "**/cli-engine", - "**/init", - "**/rule-tester" - ] - }] + "node/no-restricted-require": ["error", [ + ...createInternalFilesPatterns(INTERNAL_FILES.LINTER_PATTERN), + "fs" + ]] } }, { - files: ["lib/rules/**/*"], + files: [INTERNAL_FILES.RULES_PATTERN], rules: { - "no-restricted-modules": ["error", { - patterns: [ - ...internalFiles, - "fs", - "**/cli-engine", - "**/init", - "**/linter", - "**/rule-tester", - "**/source-code" - ] - }] + "node/no-restricted-require": ["error", [ + ...createInternalFilesPatterns(INTERNAL_FILES.RULES_PATTERN), + "fs" + ]] } }, { files: ["lib/shared/**/*"], rules: { - "no-restricted-modules": ["error", { - patterns: [ - ...internalFiles, - "**/cli-engine", - "**/init", - "**/linter", - "**/rule-tester", - "**/source-code" - ] - }] + "node/no-restricted-require": ["error", [ + ...createInternalFilesPatterns() + ]] } }, { - files: ["lib/source-code/**/*"], + files: [INTERNAL_FILES.SOURCE_CODE_PATTERN], rules: { - "no-restricted-modules": ["error", { - patterns: [ - ...internalFiles, - "fs", - "**/cli-engine", - "**/init", - "**/linter", - "**/rule-tester", - "**/rules" - ] - }] + "node/no-restricted-require": ["error", [ + ...createInternalFilesPatterns(INTERNAL_FILES.SOURCE_CODE_PATTERN), + "fs" + ]] } }, { - files: ["lib/rule-tester/**/*"], + files: [INTERNAL_FILES.RULE_TESTER_PATTERN], rules: { - "no-restricted-modules": ["error", { - patterns: [ - ...internalFiles, - "**/cli-engine", - "**/init" - ] - }] + "node/no-restricted-require": ["error", [ + ...createInternalFilesPatterns(INTERNAL_FILES.RULE_TESTER_PATTERN) + ]] } } ] diff --git a/lib/init/source-code-utils.js b/lib/init/source-code-utils.js index c95f64f69d3..dca6541d1ed 100644 --- a/lib/init/source-code-utils.js +++ b/lib/init/source-code-utils.js @@ -23,7 +23,7 @@ const { CLIEngine } = require("../cli-engine"); * TODO1: Expose the API that enumerates target files. * TODO2: Extract the creation logic of `SourceCode` from `Linter` class. */ -const { getCLIEngineInternalSlots } = require("../cli-engine/cli-engine"); // eslint-disable-line no-restricted-modules +const { getCLIEngineInternalSlots } = require("../cli-engine/cli-engine"); // eslint-disable-line node/no-restricted-require const debug = require("debug")("eslint:source-code-utils"); From 7633a73cb3e426e40b97a32c3eb6abf71412d650 Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Fri, 3 Apr 2020 00:30:15 -0400 Subject: [PATCH 6/9] Fix tests --- packages/eslint-config-eslint/default.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-eslint/default.yml b/packages/eslint-config-eslint/default.yml index f9befd8c064..0ab7653f77d 100644 --- a/packages/eslint-config-eslint/default.yml +++ b/packages/eslint-config-eslint/default.yml @@ -107,6 +107,7 @@ rules: no-octal-escape: "error" no-param-reassign: "error" no-proto: "error" + no-process-exit: "off" no-redeclare: "error" no-restricted-properties: [ "error", From 8895539e412c418645aef367a7ab5a848e3fc17b Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Fri, 3 Apr 2020 00:37:00 -0400 Subject: [PATCH 7/9] Disallow directory imports --- .eslintrc.js | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 0ca92dab810..dc858070f2e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -124,7 +124,8 @@ module.exports = { files: [INTERNAL_FILES.CLI_ENGINE_PATTERN], rules: { "node/no-restricted-require": ["error", [ - ...createInternalFilesPatterns(INTERNAL_FILES.CLI_ENGINE_PATTERN) + ...createInternalFilesPatterns(INTERNAL_FILES.CLI_ENGINE_PATTERN), + resolveAbsPath("lib/init/index.js") ]] } }, @@ -132,7 +133,8 @@ module.exports = { files: [INTERNAL_FILES.INIT_PATTERN], rules: { "node/no-restricted-require": ["error", [ - ...createInternalFilesPatterns(INTERNAL_FILES.INIT_PATTERN) + ...createInternalFilesPatterns(INTERNAL_FILES.INIT_PATTERN), + resolveAbsPath("lib/rule-tester/index.js") ]] } }, @@ -141,7 +143,10 @@ module.exports = { rules: { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(INTERNAL_FILES.LINTER_PATTERN), - "fs" + "fs", + resolveAbsPath("lib/cli-engine/index.js"), + resolveAbsPath("lib/init/index.js"), + resolveAbsPath("lib/rule-tester/index.js") ]] } }, @@ -150,7 +155,12 @@ module.exports = { rules: { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(INTERNAL_FILES.RULES_PATTERN), - "fs" + "fs", + resolveAbsPath("lib/cli-engine/index.js"), + resolveAbsPath("lib/init/index.js"), + resolveAbsPath("lib/linter/index.js"), + resolveAbsPath("lib/rule-tester/index.js"), + resolveAbsPath("lib/source-code/index.js") ]] } }, @@ -158,7 +168,12 @@ module.exports = { files: ["lib/shared/**/*"], rules: { "node/no-restricted-require": ["error", [ - ...createInternalFilesPatterns() + ...createInternalFilesPatterns(), + resolveAbsPath("lib/cli-engine/index.js"), + resolveAbsPath("lib/init/index.js"), + resolveAbsPath("lib/linter/index.js"), + resolveAbsPath("lib/rule-tester/index.js"), + resolveAbsPath("lib/source-code/index.js") ]] } }, @@ -167,7 +182,12 @@ module.exports = { rules: { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(INTERNAL_FILES.SOURCE_CODE_PATTERN), - "fs" + "fs", + resolveAbsPath("lib/cli-engine/index.js"), + resolveAbsPath("lib/init/index.js"), + resolveAbsPath("lib/linter/index.js"), + resolveAbsPath("lib/rule-tester/index.js"), + resolveAbsPath("lib/rules/index.js") ]] } }, @@ -175,7 +195,9 @@ module.exports = { files: [INTERNAL_FILES.RULE_TESTER_PATTERN], rules: { "node/no-restricted-require": ["error", [ - ...createInternalFilesPatterns(INTERNAL_FILES.RULE_TESTER_PATTERN) + ...createInternalFilesPatterns(INTERNAL_FILES.RULE_TESTER_PATTERN), + resolveAbsPath("lib/cli-engine/index.js"), + resolveAbsPath("lib/init/index.js") ]] } } From 05c3b1824d4a214bf3e63be94600368b2476f404 Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Mon, 6 Apr 2020 17:06:49 -0400 Subject: [PATCH 8/9] Address feedback --- .eslintrc.js | 50 ++++++++++++++--------------- docs/rules/callback-return.md | 2 +- docs/rules/global-require.md | 2 +- docs/rules/handle-callback-err.md | 2 +- docs/rules/no-buffer-constructor.md | 2 +- docs/rules/no-mixed-requires.md | 2 +- docs/rules/no-new-require.md | 2 +- docs/rules/no-path-concat.md | 2 +- docs/rules/no-process-env.md | 2 +- docs/rules/no-process-exit.md | 2 +- docs/rules/no-restricted-modules.md | 2 +- docs/rules/no-sync.md | 2 +- lib/rules/callback-return.js | 2 +- lib/rules/global-require.js | 2 +- lib/rules/handle-callback-err.js | 2 +- lib/rules/no-buffer-constructor.js | 2 +- lib/rules/no-mixed-requires.js | 2 +- lib/rules/no-new-require.js | 2 +- lib/rules/no-path-concat.js | 2 +- lib/rules/no-process-env.js | 2 +- lib/rules/no-process-exit.js | 2 +- lib/rules/no-restricted-modules.js | 2 +- lib/rules/no-sync.js | 2 +- 23 files changed, 47 insertions(+), 47 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index dc858070f2e..a857d977ba2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,7 +16,7 @@ const INTERNAL_FILES = { * @param {string} pathOrPattern the path or glob pattern. * @returns {string} The resolved path or glob pattern. */ -function resolveAbsPath(pathOrPattern) { +function resolveAbsolutePath(pathOrPattern) { return path.resolve(__dirname, pathOrPattern); } @@ -32,10 +32,10 @@ function createInternalFilesPatterns(pattern = null) { name: [ // Disallow all children modules. - resolveAbsPath(p), + resolveAbsolutePath(p), // Allow the main `index.js` module. - `!${resolveAbsPath(p.replace(/\*\*\/\*$/u, "index.js"))}` + `!${resolveAbsolutePath(p.replace(/\*\*\/\*$/u, "index.js"))}` ] })); } @@ -125,7 +125,7 @@ module.exports = { rules: { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(INTERNAL_FILES.CLI_ENGINE_PATTERN), - resolveAbsPath("lib/init/index.js") + resolveAbsolutePath("lib/init/index.js") ]] } }, @@ -134,7 +134,7 @@ module.exports = { rules: { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(INTERNAL_FILES.INIT_PATTERN), - resolveAbsPath("lib/rule-tester/index.js") + resolveAbsolutePath("lib/rule-tester/index.js") ]] } }, @@ -144,9 +144,9 @@ module.exports = { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(INTERNAL_FILES.LINTER_PATTERN), "fs", - resolveAbsPath("lib/cli-engine/index.js"), - resolveAbsPath("lib/init/index.js"), - resolveAbsPath("lib/rule-tester/index.js") + resolveAbsolutePath("lib/cli-engine/index.js"), + resolveAbsolutePath("lib/init/index.js"), + resolveAbsolutePath("lib/rule-tester/index.js") ]] } }, @@ -156,11 +156,11 @@ module.exports = { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(INTERNAL_FILES.RULES_PATTERN), "fs", - resolveAbsPath("lib/cli-engine/index.js"), - resolveAbsPath("lib/init/index.js"), - resolveAbsPath("lib/linter/index.js"), - resolveAbsPath("lib/rule-tester/index.js"), - resolveAbsPath("lib/source-code/index.js") + resolveAbsolutePath("lib/cli-engine/index.js"), + resolveAbsolutePath("lib/init/index.js"), + resolveAbsolutePath("lib/linter/index.js"), + resolveAbsolutePath("lib/rule-tester/index.js"), + resolveAbsolutePath("lib/source-code/index.js") ]] } }, @@ -169,11 +169,11 @@ module.exports = { rules: { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(), - resolveAbsPath("lib/cli-engine/index.js"), - resolveAbsPath("lib/init/index.js"), - resolveAbsPath("lib/linter/index.js"), - resolveAbsPath("lib/rule-tester/index.js"), - resolveAbsPath("lib/source-code/index.js") + resolveAbsolutePath("lib/cli-engine/index.js"), + resolveAbsolutePath("lib/init/index.js"), + resolveAbsolutePath("lib/linter/index.js"), + resolveAbsolutePath("lib/rule-tester/index.js"), + resolveAbsolutePath("lib/source-code/index.js") ]] } }, @@ -183,11 +183,11 @@ module.exports = { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(INTERNAL_FILES.SOURCE_CODE_PATTERN), "fs", - resolveAbsPath("lib/cli-engine/index.js"), - resolveAbsPath("lib/init/index.js"), - resolveAbsPath("lib/linter/index.js"), - resolveAbsPath("lib/rule-tester/index.js"), - resolveAbsPath("lib/rules/index.js") + resolveAbsolutePath("lib/cli-engine/index.js"), + resolveAbsolutePath("lib/init/index.js"), + resolveAbsolutePath("lib/linter/index.js"), + resolveAbsolutePath("lib/rule-tester/index.js"), + resolveAbsolutePath("lib/rules/index.js") ]] } }, @@ -196,8 +196,8 @@ module.exports = { rules: { "node/no-restricted-require": ["error", [ ...createInternalFilesPatterns(INTERNAL_FILES.RULE_TESTER_PATTERN), - resolveAbsPath("lib/cli-engine/index.js"), - resolveAbsPath("lib/init/index.js") + resolveAbsolutePath("lib/cli-engine/index.js"), + resolveAbsolutePath("lib/init/index.js") ]] } } diff --git a/docs/rules/callback-return.md b/docs/rules/callback-return.md index a2abd28fcf5..f425ccd3f25 100644 --- a/docs/rules/callback-return.md +++ b/docs/rules/callback-return.md @@ -1,6 +1,6 @@ # Enforce Return After Callback (callback-return) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). The callback pattern is at the heart of most I/O and event-driven programming in JavaScript. diff --git a/docs/rules/global-require.md b/docs/rules/global-require.md index 3f0bb01c0b3..a81d5a3a506 100644 --- a/docs/rules/global-require.md +++ b/docs/rules/global-require.md @@ -1,6 +1,6 @@ # Enforce require() on the top-level module scope (global-require) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). In Node.js, module dependencies are included using the `require()` function, such as: diff --git a/docs/rules/handle-callback-err.md b/docs/rules/handle-callback-err.md index 5bc745c1947..dad537e9695 100644 --- a/docs/rules/handle-callback-err.md +++ b/docs/rules/handle-callback-err.md @@ -1,6 +1,6 @@ # Enforce Callback Error Handling (handle-callback-err) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). In Node.js, a common pattern for dealing with asynchronous behavior is called the callback pattern. This pattern expects an `Error` object or `null` as the first argument of the callback. diff --git a/docs/rules/no-buffer-constructor.md b/docs/rules/no-buffer-constructor.md index b49ec7846fb..9902a71605f 100644 --- a/docs/rules/no-buffer-constructor.md +++ b/docs/rules/no-buffer-constructor.md @@ -1,6 +1,6 @@ # disallow use of the Buffer() constructor (no-buffer-constructor) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). In Node.js, the behavior of the `Buffer` constructor is different depending on the type of its argument. Passing an argument from user input to `Buffer()` without validating its type can lead to security vulnerabilities such as remote memory disclosure and denial of service. As a result, the `Buffer` constructor has been deprecated and should not be used. Use the producer methods `Buffer.from`, `Buffer.alloc`, and `Buffer.allocUnsafe` instead. diff --git a/docs/rules/no-mixed-requires.md b/docs/rules/no-mixed-requires.md index eb98ed22a4a..c697d04e865 100644 --- a/docs/rules/no-mixed-requires.md +++ b/docs/rules/no-mixed-requires.md @@ -1,6 +1,6 @@ # disallow `require` calls to be mixed with regular variable declarations (no-mixed-requires) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). In the Node.js community it is often customary to separate initializations with calls to `require` modules from other variable declarations, sometimes also grouping them by the type of module. This rule helps you enforce this convention. diff --git a/docs/rules/no-new-require.md b/docs/rules/no-new-require.md index 02730309d22..6cf1242f72b 100644 --- a/docs/rules/no-new-require.md +++ b/docs/rules/no-new-require.md @@ -1,6 +1,6 @@ # Disallow new require (no-new-require) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). The `require` function is used to include modules that exist in separate files, such as: diff --git a/docs/rules/no-path-concat.md b/docs/rules/no-path-concat.md index 023a171b83f..fddf27b9e45 100644 --- a/docs/rules/no-path-concat.md +++ b/docs/rules/no-path-concat.md @@ -1,6 +1,6 @@ # Disallow string concatenation when using `__dirname` and `__filename` (no-path-concat) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). In Node.js, the `__dirname` and `__filename` global variables contain the directory path and the file path of the currently executing script file, respectively. Sometimes, developers try to use these variables to create paths to other files, such as: diff --git a/docs/rules/no-process-env.md b/docs/rules/no-process-env.md index d5db9e74392..83bfa6d02ac 100644 --- a/docs/rules/no-process-env.md +++ b/docs/rules/no-process-env.md @@ -1,6 +1,6 @@ # Disallow process.env (no-process-env) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). The `process.env` object in Node.js is used to store deployment/configuration parameters. Littering it through out a project could lead to maintenance issues as it's another kind of global dependency. As such, it could lead to merge conflicts in a multi-user setup and deployment issues in a multi-server setup. Instead, one of the best practices is to define all those parameters in a single configuration/settings file which could be accessed throughout the project. diff --git a/docs/rules/no-process-exit.md b/docs/rules/no-process-exit.md index e74af09b27e..54f2661ae2c 100644 --- a/docs/rules/no-process-exit.md +++ b/docs/rules/no-process-exit.md @@ -1,6 +1,6 @@ # Disallow process.exit() (no-process-exit) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). The `process.exit()` method in Node.js is used to immediately stop the Node.js process and exit. This is a dangerous operation because it can occur in any method at any point in time, potentially stopping a Node.js application completely when an error occurs. For example: diff --git a/docs/rules/no-restricted-modules.md b/docs/rules/no-restricted-modules.md index de0894a30fd..3fc412fe5d6 100644 --- a/docs/rules/no-restricted-modules.md +++ b/docs/rules/no-restricted-modules.md @@ -1,6 +1,6 @@ # Disallow Node.js modules (no-restricted-modules) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). A module in Node.js is a simple or complex functionality organized in a JavaScript file which can be reused throughout the Node.js application. The keyword `require` is used in Node.js/CommonJS to import modules into an application. This way you can have dynamic loading where the loaded module name isn't predefined /static, or where you conditionally load a module only if it's "truly required". diff --git a/docs/rules/no-sync.md b/docs/rules/no-sync.md index e8f46e09f45..949df6d36b4 100644 --- a/docs/rules/no-sync.md +++ b/docs/rules/no-sync.md @@ -1,6 +1,6 @@ # Disallow Synchronous Methods (no-sync) -This rule was **deprecated** in ESLint v7.0.0. +This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). In Node.js, most I/O is done through asynchronous methods. However, there are often synchronous versions of the asynchronous methods. For example, `fs.exists()` and `fs.existsSync()`. In some contexts, using synchronous operations is okay (if, as with ESLint, you are writing a command line utility). However, in other contexts the use of synchronous operations is considered a bad practice that should be avoided. For example, if you are running a high-travel web server on Node.js, you should consider carefully if you want to allow any synchronous operations that could lock up the server. diff --git a/lib/rules/callback-return.js b/lib/rules/callback-return.js index 9c82da365a8..5df792d4363 100644 --- a/lib/rules/callback-return.js +++ b/lib/rules/callback-return.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/callback-return.md"], + replacedBy: ["node/callback-return"], type: "suggestion", diff --git a/lib/rules/global-require.js b/lib/rules/global-require.js index f5c1a4dee04..9bd073b8854 100644 --- a/lib/rules/global-require.js +++ b/lib/rules/global-require.js @@ -50,7 +50,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/global-require.md"], + replacedBy: ["node/global-require"], type: "suggestion", diff --git a/lib/rules/handle-callback-err.js b/lib/rules/handle-callback-err.js index bf8f04d1337..8ad63bbd53a 100644 --- a/lib/rules/handle-callback-err.js +++ b/lib/rules/handle-callback-err.js @@ -13,7 +13,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/handle-callback-err.md"], + replacedBy: ["node/handle-callback-err"], type: "suggestion", diff --git a/lib/rules/no-buffer-constructor.js b/lib/rules/no-buffer-constructor.js index 7dccbe59e20..5dce047b923 100644 --- a/lib/rules/no-buffer-constructor.js +++ b/lib/rules/no-buffer-constructor.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-deprecated-api.md"], + replacedBy: ["node/no-deprecated-api"], type: "problem", diff --git a/lib/rules/no-mixed-requires.js b/lib/rules/no-mixed-requires.js index 08634d1628f..bfe9b7aa978 100644 --- a/lib/rules/no-mixed-requires.js +++ b/lib/rules/no-mixed-requires.js @@ -13,7 +13,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-mixed-requires.md"], + replacedBy: ["node/no-mixed-requires"], type: "suggestion", diff --git a/lib/rules/no-new-require.js b/lib/rules/no-new-require.js index 06cee722c4e..7f81e83fd78 100644 --- a/lib/rules/no-new-require.js +++ b/lib/rules/no-new-require.js @@ -13,7 +13,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-new-require.md"], + replacedBy: ["node/no-new-require"], type: "suggestion", diff --git a/lib/rules/no-path-concat.js b/lib/rules/no-path-concat.js index f16e369f831..77a03a7f952 100644 --- a/lib/rules/no-path-concat.js +++ b/lib/rules/no-path-concat.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-path-concat.md"], + replacedBy: ["node/no-path-concat"], type: "suggestion", diff --git a/lib/rules/no-process-env.js b/lib/rules/no-process-env.js index 171e900be70..24bb9f9971d 100644 --- a/lib/rules/no-process-env.js +++ b/lib/rules/no-process-env.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-process-env.md"], + replacedBy: ["node/no-process-env"], type: "suggestion", diff --git a/lib/rules/no-process-exit.js b/lib/rules/no-process-exit.js index 51b8c02b1a6..9c70ea8808b 100644 --- a/lib/rules/no-process-exit.js +++ b/lib/rules/no-process-exit.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-process-exit.md"], + replacedBy: ["node/no-process-exit"], type: "suggestion", diff --git a/lib/rules/no-restricted-modules.js b/lib/rules/no-restricted-modules.js index f3cc1b22090..61834ceeb44 100644 --- a/lib/rules/no-restricted-modules.js +++ b/lib/rules/no-restricted-modules.js @@ -42,7 +42,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-restricted-require.md"], + replacedBy: ["node/no-restricted-require"], type: "suggestion", diff --git a/lib/rules/no-sync.js b/lib/rules/no-sync.js index b838cdbba91..c80e1182366 100644 --- a/lib/rules/no-sync.js +++ b/lib/rules/no-sync.js @@ -15,7 +15,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-sync.md"], + replacedBy: ["node/no-sync.md"], type: "suggestion", From 01c17ef1b8ef5cd1ea738ca87b6063cf9361759f Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Mon, 6 Apr 2020 17:09:10 -0400 Subject: [PATCH 9/9] Fix typo --- lib/rules/no-sync.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rules/no-sync.js b/lib/rules/no-sync.js index c80e1182366..9790d1f94bb 100644 --- a/lib/rules/no-sync.js +++ b/lib/rules/no-sync.js @@ -15,7 +15,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/no-sync.md"], + replacedBy: ["node/no-sync"], type: "suggestion",