Skip to content
Draft
6 changes: 1 addition & 5 deletions .eslint-doc-generatorrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const config = {
ignoreConfig: [
"recommended",
"mixed-esm-and-cjs",
"flat/recommended-script",
"flat/recommended-module",
"flat/recommended",
Expand All @@ -14,11 +15,6 @@ const config = {
configEmoji: [
["recommended-script", "✅"],
["recommended-module", "🟢"],
["recommended", "☑️"],
["flat/recommended-script", "✅"],
["flat/recommended-module", "🟢"],
["flat/recommended", "☑️"],
["flat/mixed-esm-and-cjs", "🟠"],
],
ruleDocSectionOptions: false,
}
Expand Down
173 changes: 70 additions & 103 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/rules/callback-return.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Require `return` statements after callbacks (`n/callback-return`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

The callback pattern is at the heart of most I/O and event-driven programming
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/exports-style.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce either `module.exports` or `exports` (`n/exports-style`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/file-extension-in-import.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce the style of file extensions in `import` declarations (`n/file-extension-in-import`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/global-require.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Require `require()` calls to be placed at top-level module scope (`n/global-require`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

In Node.js, module dependencies are included using the `require()` function, such as:
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/handle-callback-err.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Require error handling in callbacks (`n/handle-callback-err`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

In Node.js, a common pattern for dealing with asynchronous behavior is called the callback pattern.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/hashbang.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Require correct usage of hashbang (`n/hashbang`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-callback-literal.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce Node.js-style error-first callback pattern is followed (`n/no-callback-literal`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

When invoking a callback function which uses the Node.js error-first callback pattern, all of your errors should either use the `Error` class or a subclass of it. It is also acceptable to use `undefined` or `null` if there is no error.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-deprecated-api.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow deprecated APIs (`n/no-deprecated-api`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-exports-assign.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow the assignment to `exports` (`n/no-exports-assign`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-extraneous-import.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow `import` declarations which import extraneous modules (`n/no-extraneous-import`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-extraneous-require.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow `require()` expressions which import extraneous modules (`n/no-extraneous-require`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-missing-import.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow `import` declarations which import missing modules (`n/no-missing-import`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-missing-require.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow `require()` expressions which import missing modules (`n/no-missing-require`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-mixed-requires.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow `require` calls to be mixed with regular variable declarations (`n/no-mixed-requires`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

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.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-new-require.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow `new` operators with calls to `require` (`n/no-new-require`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

The `require` function is used to include modules that exist in separate files, such as:
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-path-concat.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow string concatenation with `__dirname` and `__filename` (`n/no-path-concat`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

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:
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-process-env.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow the use of `process.env` (`n/no-process-env`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

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.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-process-exit.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow the use of `process.exit()` (`n/no-process-exit`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-restricted-import.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow specified modules when loaded by `import` declarations (`n/no-restricted-import`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

## 📖 Rule Details
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-restricted-require.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow specified modules when loaded by `require` (`n/no-restricted-require`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

A module in Node.js is a simple or complex functionality organized in a JavaScript file which can be reused throughout the Node.js
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-sync.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow synchronous methods (`n/no-sync`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

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.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-top-level-await.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow top-level `await` in published modules (`n/no-top-level-await`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

Node.js v20.19 introduced `require(esm)`, but ES modules with top-level `await` cannot be loaded with `require(esm)`. It is a good idea to disallow top-level `await` to ensure interoperability of modules published as Node.js libraries.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unpublished-bin.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow `bin` files that npm ignores (`n/no-unpublished-bin`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unpublished-import.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow `import` declarations which import private modules (`n/no-unpublished-import`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unpublished-require.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow `require()` expressions which import private modules (`n/no-unpublished-require`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unsupported-features/es-builtins.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow unsupported ECMAScript built-ins on the specified version (`n/no-unsupported-features/es-builtins`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unsupported-features/es-syntax.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow unsupported ECMAScript syntax on the specified version (`n/no-unsupported-features/es-syntax`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unsupported-features/node-builtins.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow unsupported Node.js built-in APIs on the specified version (`n/no-unsupported-features/node-builtins`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-global/buffer.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce either `Buffer` or `require("buffer").Buffer` (`n/prefer-global/buffer`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

The `Buffer` class of `buffer` module is defined as a global variable.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-global/console.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce either `console` or `require("console")` (`n/prefer-global/console`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

The `console` module is defined as a global variable.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-global/process.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce either `process` or `require("process")` (`n/prefer-global/process`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

The `process` module is defined as a global variable.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-global/text-decoder.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce either `TextDecoder` or `require("util").TextDecoder` (`n/prefer-global/text-decoder`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

The `TextDecoder` class of `util` module is defined as a global variable.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-global/text-encoder.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce either `TextEncoder` or `require("util").TextEncoder` (`n/prefer-global/text-encoder`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

The `TextEncoder` class of `util` module is defined as a global variable.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-global/url-search-params.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce either `URLSearchParams` or `require("url").URLSearchParams` (`n/prefer-global/url-search-params`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

The `URLSearchParams` class of `url` module is defined as a global variable.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-global/url.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce either `URL` or `require("url").URL` (`n/prefer-global/url`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

The `URL` class of `url` module is defined as a global variable.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-node-protocol.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce using the `node:` protocol when importing Node.js builtin modules (`n/prefer-node-protocol`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-promises/dns.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce `require("dns").promises` (`n/prefer-promises/dns`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

Since Node.js v11.14.0, `require("dns").promises` API has been stable.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-promises/fs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce `require("fs").promises` (`n/prefer-promises/fs`)

💼 This rule is enabled in the 🌐 `all` [config](https://github.com/eslint-community/eslint-plugin-n#-configs).

<!-- end auto-generated rule header -->

Since Node.js v11.14.0, `require("fs").promises` API has been stable.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/process-exit-as-throw.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Require that `process.exit()` expressions use the same code path as `throw` (`n/process-exit-as-throw`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🟢 `recommended-module`, ✅ `recommended-script`.
💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): 🌐 `all`, 🟢 `recommended-module`, ✅ `recommended-script`.

<!-- end auto-generated rule header -->

Expand Down
4 changes: 2 additions & 2 deletions lib/configs/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const recommendeConfig = require("./recommended")

/**
* https://eslint.org/docs/latest/use/configure/configuration-files-new
* @type {import('eslint').Linter.FlatConfig}
* @type {import('eslint').Linter.Config}
*/
exports.flat = {
name: "node/flat/all",
name: "node/all",
languageOptions: recommendeConfig.flat.languageOptions ?? {},
rules: allRulesConfig,
}
Loading