Skip to content

Commit 075f0c5

Browse files
authored
feat!: engines.node defaults to 16.0.0 (#91)
* feat!: engines.node defaults to 16.0.0 node.js < 13, v15 has been eol. and node.js v14 will be eol in a few months. refs: #42 * docs: update docs to reflect the new default version * docs: deduplication of the configured Node.js version range * docs: fix node lts statement
1 parent aa75610 commit 075f0c5

File tree

7 files changed

+40
-93
lines changed

7 files changed

+40
-93
lines changed

README.md

+25-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ npm install --save-dev eslint eslint-plugin-n
1515
- Requires Node.js `>=16.0.0`
1616
- Requires ESLint `>=7.0.0`
1717

18-
**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.
19-
2018
**.eslintrc.json** (An example)
2119

2220
```jsonc
@@ -53,6 +51,31 @@ npm install --save-dev eslint eslint-plugin-n
5351
}
5452
```
5553

54+
### Configured Node.js version range
55+
56+
The rules get the supported Node.js version range from the following, falling back to the next if unspecified:
57+
58+
1. Rule configuration `version`
59+
2. ESLint [shared setting](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings) `node.version`
60+
3. `package.json` [`engines`] field
61+
4. `>=16.0.0`
62+
63+
If you omit the [engines] field, this rule chooses `>=16.0.0` as the configured Node.js version since `16` is the maintained lts (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)).
64+
65+
For Node.js packages, using the [`engines`] field is recommended because it's the official way to indicate support:
66+
67+
```json
68+
{
69+
"name": "your-module",
70+
"version": "1.0.0",
71+
"engines": {
72+
"node": ">=16.0.0"
73+
}
74+
}
75+
```
76+
77+
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.
78+
5679
## 📖 Rules
5780

5881
<!-- begin auto-generated rules list -->

docs/rules/no-deprecated-api.md

+2-17
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,7 @@ This rule reports the following deprecated API.
141141
142142
### Configured Node.js version range
143143

144-
This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting.
145-
146-
I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting.
147-
For example of `package.json`:
148-
149-
```json
150-
{
151-
"name": "your-module",
152-
"version": "1.0.0",
153-
"engines": {
154-
"node": ">=8.0.0"
155-
}
156-
}
157-
```
158-
159-
If you omit the [engines] field, this rule chooses `>=8.0.0` as the configured Node.js version since `8` is the minimum version the community is maintaining (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)).
144+
[Configured Node.js version range](../../README.md#configured-nodejs-version-range)
160145

161146
### Options
162147

@@ -166,7 +151,7 @@ This rule has 4 options.
166151
{
167152
"rules": {
168153
"n/no-deprecated-api": ["error", {
169-
"version": ">=8.0.0",
154+
"version": ">=16.0.0",
170155
"ignoreModuleItems": [],
171156
"ignoreGlobalItems": []
172157
"ignoreIndirectDependencies": true

docs/rules/no-unsupported-features/es-builtins.md

+3-24
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,14 @@ See also [TC39 finished proposals](https://github.com/tc39/proposals/blob/master
1919

2020
### Configured Node.js version range
2121

22-
This rule gets the supported Node.js version range from the following, falling back to the next if unspecified:
23-
24-
1. Rule configuration `version`
25-
2. ESLint [shared setting](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings) `node.version`
26-
3. `package.json` [`engines`] field
27-
4. `>=8.0.0`
28-
29-
The default version is `8.0.0` because it's the minimum version the community is maintaining (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)).
30-
31-
For Node.js packages, using the [`engines`] field is recommended because it's the official way to indicate support:
32-
33-
```json
34-
{
35-
"name": "your-module",
36-
"version": "1.0.0",
37-
"engines": {
38-
"node": ">=8.0.0"
39-
}
40-
}
41-
```
42-
43-
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.
22+
[Configured Node.js version range](../../../README.md#configured-nodejs-version-range)
4423

4524
### Options
4625

4726
```json
4827
{
4928
"n/no-unsupported-features/es-builtins": ["error", {
50-
"version": ">=8.0.0",
29+
"version": ">=16.0.0",
5130
"ignores": []
5231
}]
5332
}
@@ -159,7 +138,7 @@ For Example:
159138
{
160139
"settings": {
161140
"node": {
162-
"version": ">=8.0.0",
141+
"version": ">=16.0.0",
163142
}
164143
},
165144
"rules": {

docs/rules/no-unsupported-features/es-syntax.md

+3-24
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,14 @@ For example, set `2020` to `parserOptions.ecmaVersion`.
2222

2323
### Configured Node.js version range
2424

25-
This rule gets the supported Node.js version range from the following, falling back to the next if unspecified:
26-
27-
1. Rule configuration `version`
28-
2. ESLint [shared setting](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings) `node.version`
29-
3. `package.json` [`engines`] field
30-
4. `>=8.0.0`
31-
32-
The default version is `8.0.0` because it's the minimum version the community is maintaining (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)).
33-
34-
For Node.js packages, using the [`engines`] field is recommended because it's the official way to indicate support:
35-
36-
```json
37-
{
38-
"name": "your-module",
39-
"version": "1.0.0",
40-
"engines": {
41-
"node": ">=8.0.0"
42-
}
43-
}
44-
```
45-
46-
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.
25+
[Configured Node.js version range](../../../README.md#configured-nodejs-version-range)
4726

4827
### Options
4928

5029
```json
5130
{
5231
"n/no-unsupported-features/es-syntax": ["error", {
53-
"version": ">=8.0.0",
32+
"version": ">=16.0.0",
5433
"ignores": []
5534
}]
5635
}
@@ -144,7 +123,7 @@ For Example:
144123
{
145124
"settings": {
146125
"node": {
147-
"version": ">=8.0.0",
126+
"version": ">=16.0.0",
148127
}
149128
},
150129
"rules": {

docs/rules/no-unsupported-features/node-builtins.md

+3-24
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,14 @@ This rule reports APIs of Node.js built-in APIs on the basis of [Node.js v13.2.0
1616

1717
### Configured Node.js version range
1818

19-
This rule gets the supported Node.js version range from the following, falling back to the next if unspecified:
20-
21-
1. Rule configuration `version`
22-
2. ESLint [shared setting](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings) `node.version`
23-
3. `package.json` [`engines`] field
24-
4. `>=8.0.0`
25-
26-
The default version is `8.0.0` because it's the minimum version the community is maintaining (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)).
27-
28-
For Node.js packages, using the [`engines`] field is recommended because it's the official way to indicate support:
29-
30-
```json
31-
{
32-
"name": "your-module",
33-
"version": "1.0.0",
34-
"engines": {
35-
"node": ">=8.0.0"
36-
}
37-
}
38-
```
39-
40-
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.
19+
[Configured Node.js version range](../../../README.md#configured-nodejs-version-range)
4120

4221
### Options
4322

4423
```json
4524
{
4625
"n/no-unsupported-features/node-builtins": ["error", {
47-
"version": ">=8.0.0",
26+
"version": ">=16.0.0",
4827
"ignores": []
4928
}]
5029
}
@@ -343,7 +322,7 @@ For Example:
343322
{
344323
"settings": {
345324
"node": {
346-
"version": ">=8.0.0",
325+
"version": ">=16.0.0",
347326
}
348327
},
349328
"rules": {

lib/util/get-configured-node-version.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function getEnginesNode(filename) {
3636
*
3737
* 1. Parse a given version then return it if it's valid.
3838
* 2. Look package.json up and parse `engines.node` then return it if it's valid.
39-
* 3. Return `>=8.0.0`.
39+
* 3. Return `>=16.0.0`.
4040
*
4141
* @param {string|undefined} version The version range text.
4242
* @param {string} filename The path to the current linting file.
@@ -52,7 +52,7 @@ module.exports = function getConfiguredNodeVersion(context) {
5252
return (
5353
getSemverRange(version) ||
5454
getEnginesNode(filePath) ||
55-
getSemverRange(">=8.0.0")
55+
getSemverRange(">=16.0.0")
5656
)
5757
}
5858

tests/lib/rules/no-unsupported-features/es-syntax.js

+2
Original file line numberDiff line numberDiff line change
@@ -2663,6 +2663,7 @@ ruleTester.run(
26632663
{
26642664
filename: fixture("invalid/a.js"),
26652665
code: "var a = { ...obj }",
2666+
options: [{version: '>=8.0.0'}],
26662667
errors: [
26672668
{
26682669
messageId: "no-rest-spread-properties",
@@ -2683,6 +2684,7 @@ ruleTester.run(
26832684
{
26842685
filename: fixture("nothing/a.js"),
26852686
code: "var a = { ...obj }",
2687+
options: [{version: '>=8.0.0'}],
26862688
errors: [
26872689
{
26882690
messageId: "no-rest-spread-properties",

0 commit comments

Comments
 (0)