diff --git a/README.md b/README.md index 981670b3..7a74851a 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,6 @@ npm install --save-dev eslint eslint-plugin-n - Requires Node.js `>=12.22.0` - Requires ESLint `>=7.0.0` -**Note:** It recommends a use of [the "engines" field of package.json](https://docs.npmjs.com/files/package.json#engines). The "engines" field is used by `n/no-unsupported-features/*` rules. - **.eslintrc.json** (An example) ```jsonc @@ -53,6 +51,31 @@ npm install --save-dev eslint eslint-plugin-n } ``` +### Configured Node.js version range + +The rules get the supported Node.js version range from the following, falling back to the next if unspecified: + +1. Rule configuration `version` +2. ESLint [shared setting](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings) `node.version` +3. `package.json` [`engines`] field +4. `>=16.0.0` + +If you omit the [engines] field, this rule chooses `>=16.0.0` as the configured Node.js version since `16` is the active lts (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)). + +For Node.js packages, using the [`engines`] field is recommended because it's the official way to indicate support: + +```json +{ + "name": "your-module", + "version": "1.0.0", + "engines": { + "node": ">=16.0.0" + } +} +``` + +For [Shareable Configs](https://eslint.org/docs/latest/developer-guide/shareable-configs) or packages with a different development environment (e.g. pre-compiled, web package, etc.), you can configure ESLint with `settings.node.version` to specify support. + ## 📖 Rules diff --git a/docs/rules/no-deprecated-api.md b/docs/rules/no-deprecated-api.md index aea0be52..c67dd782 100644 --- a/docs/rules/no-deprecated-api.md +++ b/docs/rules/no-deprecated-api.md @@ -141,22 +141,7 @@ This rule reports the following deprecated API. ### Configured Node.js version range -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=16.0.0" - } -} -``` - -If you omit the [engines] field, this rule chooses `>=16.0.0` as the configured Node.js version since `16` is the active lts (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)). +[Configured Node.js version range](../../README.md#configured-nodejs-version-range) ### Options diff --git a/docs/rules/no-unsupported-features/es-builtins.md b/docs/rules/no-unsupported-features/es-builtins.md index 764242d4..4c6e438f 100644 --- a/docs/rules/no-unsupported-features/es-builtins.md +++ b/docs/rules/no-unsupported-features/es-builtins.md @@ -19,28 +19,7 @@ See also [TC39 finished proposals](https://github.com/tc39/proposals/blob/master ### Configured Node.js version range -This rule gets the supported Node.js version range from the following, falling back to the next if unspecified: - -1. Rule configuration `version` -2. ESLint [shared setting](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings) `node.version` -3. `package.json` [`engines`] field -4. `>=16.0.0` - -If you omit the [engines] field, this rule chooses `>=16.0.0` as the configured Node.js version since `16` is the active lts (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)). - -For Node.js packages, using the [`engines`] field is recommended because it's the official way to indicate support: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=16.0.0" - } -} -``` - -For [Shareable Configs](https://eslint.org/docs/latest/developer-guide/shareable-configs) or packages with a different development environment (e.g. pre-compiled, web package, etc.), you can configure ESLint with `settings.node.version` to specify support. +[Configured Node.js version range](../../../README.md#configured-nodejs-version-range) ### Options diff --git a/docs/rules/no-unsupported-features/es-syntax.md b/docs/rules/no-unsupported-features/es-syntax.md index 2fc64aac..e4f51daa 100644 --- a/docs/rules/no-unsupported-features/es-syntax.md +++ b/docs/rules/no-unsupported-features/es-syntax.md @@ -22,28 +22,7 @@ For example, set `2020` to `parserOptions.ecmaVersion`. ### Configured Node.js version range -This rule gets the supported Node.js version range from the following, falling back to the next if unspecified: - -1. Rule configuration `version` -2. ESLint [shared setting](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings) `node.version` -3. `package.json` [`engines`] field -4. `>=16.0.0` - -If you omit the [engines] field, this rule chooses `>=16.0.0` as the configured Node.js version since `16` is the active lts (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)). - -For Node.js packages, using the [`engines`] field is recommended because it's the official way to indicate support: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=16.0.0" - } -} -``` - -For [Shareable Configs](https://eslint.org/docs/latest/developer-guide/shareable-configs) or packages with a different development environment (e.g. pre-compiled, web package, etc.), you can configure ESLint with `settings.node.version` to specify support. +[Configured Node.js version range](../../../README.md#configured-nodejs-version-range) ### Options diff --git a/docs/rules/no-unsupported-features/node-builtins.md b/docs/rules/no-unsupported-features/node-builtins.md index 9e121d5e..a31dfc3d 100644 --- a/docs/rules/no-unsupported-features/node-builtins.md +++ b/docs/rules/no-unsupported-features/node-builtins.md @@ -16,28 +16,7 @@ This rule reports APIs of Node.js built-in APIs on the basis of [Node.js v13.2.0 ### Configured Node.js version range -This rule gets the supported Node.js version range from the following, falling back to the next if unspecified: - -1. Rule configuration `version` -2. ESLint [shared setting](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings) `node.version` -3. `package.json` [`engines`] field -4. `>=16.0.0` - -If you omit the [engines] field, this rule chooses `>=16.0.0` as the configured Node.js version since `16` is the active lts (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)). - -For Node.js packages, using the [`engines`] field is recommended because it's the official way to indicate support: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=16.0.0" - } -} -``` - -For [Shareable Configs](https://eslint.org/docs/latest/developer-guide/shareable-configs) or packages with a different development environment (e.g. pre-compiled, web package, etc.), you can configure ESLint with `settings.node.version` to specify support. +[Configured Node.js version range](../../../README.md#configured-nodejs-version-range) ### Options