Skip to content

Commit

Permalink
docs: deduplication of the configured Node.js version range
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Apr 18, 2023
1 parent 7935ae5 commit a50264f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 84 deletions.
27 changes: 25 additions & 2 deletions README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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

<!-- begin auto-generated rules list -->
Expand Down
17 changes: 1 addition & 16 deletions docs/rules/no-deprecated-api.md
Expand Up @@ -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

Expand Down
23 changes: 1 addition & 22 deletions docs/rules/no-unsupported-features/es-builtins.md
Expand Up @@ -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

Expand Down
23 changes: 1 addition & 22 deletions docs/rules/no-unsupported-features/es-syntax.md
Expand Up @@ -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

Expand Down
23 changes: 1 addition & 22 deletions docs/rules/no-unsupported-features/node-builtins.md
Expand Up @@ -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

Expand Down

0 comments on commit a50264f

Please sign in to comment.