From be58f864adcc92ff9403171fd760c3e264402652 Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Mon, 10 Feb 2020 13:07:30 -0500 Subject: [PATCH] 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 abbc30a05fb..bf9d9b520e5 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: {