Skip to content

Commit fd9d19d

Browse files
Lalem001mysticatea
authored andcommitted
no-deprecated-api adheres to targeted node version (fixes #141) (#164)
1 parent bc02c52 commit fd9d19d

File tree

3 files changed

+464
-62
lines changed

3 files changed

+464
-62
lines changed

docs/rules/no-deprecated-api.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,48 @@ This rule reports the following deprecated API.
143143
> For example, `require("punycode")` still imports the deprecated core module even if you executed `npm install punycode`.
144144
> Use `require("punycode/")` to import userland modules rather than core modules.
145145
146+
### Configured Node.js version range
147+
148+
This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting.
149+
150+
I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting.
151+
For example of `package.json`:
152+
153+
```json
154+
{
155+
"name": "your-module",
156+
"version": "1.0.0",
157+
"engines": {
158+
"node": ">=8.0.0"
159+
}
160+
}
161+
```
162+
163+
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)).
164+
146165
### Options
147166

148-
This rule has 2 options.
167+
This rule has 3 options.
149168

150169
```json
151170
{
152171
"rules": {
153172
"node/no-deprecated-api": ["error", {
173+
"version": ">=8.0.0",
154174
"ignoreModuleItems": [],
155175
"ignoreGlobalItems": []
156176
}]
157177
}
158178
}
159179
```
160180

181+
#### version
182+
183+
As mentioned above, this rule reads the [engines] field of `package.json`.
184+
But, you can overwrite the version by `version` option.
185+
186+
The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar).
187+
161188
#### ignoreModuleItems
162189

163190
This is the array of module names and module's member names.

0 commit comments

Comments
 (0)