Skip to content

Commit 5d79f2d

Browse files
committedMay 2, 2019
💥 update no-unsupported-features/node-builtins for Node 12
1 parent 7e0c2c5 commit 5d79f2d

File tree

3 files changed

+88
-33
lines changed

3 files changed

+88
-33
lines changed
 

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

+35-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Editor integrations of ESLint would be useful to know it in real-time.
88

99
## Rule Details
1010

11-
This rule reports APIs of Node.js built-in APIs on the basis of [Node.js v11.0.0 Documentation](https://nodejs.org/docs/v11.0.0/api/).
11+
This rule reports APIs of Node.js built-in APIs on the basis of [Node.js v12.0.0 Documentation](https://nodejs.org/docs/v12.0.0/api/).
1212

1313
### Configured Node.js version range
1414

@@ -22,19 +22,19 @@ For example of `package.json`:
2222
"name": "your-module",
2323
"version": "1.0.0",
2424
"engines": {
25-
"node": ">=6.0.0"
25+
"node": ">=8.0.0"
2626
}
2727
}
2828
```
2929

30-
If you omit the [engines] field, this rule chooses `>=6.0.0` as the configured Node.js version since `6` is the minimum version the community is maintaining (see also [Node.js Release Working Group](https://github.com/nodejs/Release#readme)).
30+
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)).
3131

3232
### Options
3333

3434
```json
3535
{
3636
"node/no-unsupported-features/node-builtins": ["error", {
37-
"version": ">=6.0.0",
37+
"version": ">=8.0.0",
3838
"ignores": []
3939
}]
4040
}
@@ -82,6 +82,7 @@ The `"ignores"` option accepts an array of the following strings.
8282
- `"console.timeStamp"`
8383
- `"console.timeline"`
8484
- `"console.timelineEnd"`
85+
- `"process.allowedNodeEnvironmentFlags"`
8586
- `"process.argv0"`
8687
- `"process.channel"`
8788
- `"process.cpuUsage"`
@@ -92,9 +93,14 @@ The `"ignores"` option accepts an array of the following strings.
9293
- `"process.hrtime.bigint"`
9394
- `"process.ppid"`
9495
- `"process.release"`
96+
- `"process.report"`
9597
- `"process.setegid"`
9698
- `"process.seteuid"`
9799
- `"process.setUncaughtExceptionCaptureCallback"`
100+
- `"process.stdout.getColorDepth"`
101+
- `"process.stdout.hasColor"`
102+
- `"process.stderr.getColorDepth"`
103+
- `"process.stderr.hasColor"`
98104
- `"queueMicrotask"`
99105
- `"require.resolve.paths"`
100106

@@ -151,6 +157,10 @@ The `"ignores"` option accepts an array of the following strings.
151157
- `"crypto.Certificate.exportChallenge"`
152158
- `"crypto.Certificate.exportPublicKey"`
153159
- `"crypto.Certificate.verifySpkac"`
160+
- `"crypto.KeyObject"`
161+
- `"crypto.createPrivateKey"`
162+
- `"crypto.createPublicKey"`
163+
- `"crypto.createSecretKey"`
154164
- `"crypto.constants"`
155165
- `"crypto.fips"`
156166
- `"crypto.generateKeyPair"`
@@ -164,14 +174,21 @@ The `"ignores"` option accepts an array of the following strings.
164174
- `"crypto.scrypt"`
165175
- `"crypto.scryptSync"`
166176
- `"crypto.setFips"`
177+
- `"crypto.sign"`
167178
- `"crypto.timingSafeEqual"`
179+
- `"crypto.verify"`
168180

169181
**`dns` module:**
170182

171183
- `"dns.Resolver"`
172184
- `"dns.resolvePtr"`
173185
- `"dns.promises"`
174186

187+
**`events` module:**
188+
189+
- `"events.EventEmitter.once"`
190+
- `"events.once"`
191+
175192
**`fs` module:**
176193

177194
- `"fs.Dirent"`
@@ -211,6 +228,7 @@ The `"ignores"` option accepts an array of the following strings.
211228
**`perf_hooks` module:**
212229

213230
- `"perf_hooks"`
231+
- `"perf_hooks.monitorEventLoopDelay"`
214232

215233
**`process` module:**
216234

@@ -225,9 +243,14 @@ The `"ignores"` option accepts an array of the following strings.
225243
- `"process.hrtime.bigint"`
226244
- `"process.ppid"`
227245
- `"process.release"`
246+
- `"process.report"`
228247
- `"process.setegid"`
229248
- `"process.seteuid"`
230249
- `"process.setUncaughtExceptionCaptureCallback"`
250+
- `"process.stdout.getColorDepth"`
251+
- `"process.stdout.hasColor"`
252+
- `"process.stderr.getColorDepth"`
253+
- `"process.stderr.hasColor"`
231254

232255
**`stream` module:**
233256

@@ -252,6 +275,7 @@ The `"ignores"` option accepts an array of the following strings.
252275
- `"util.getSystemErrorName"`
253276
- `"util.inspect.custom"`
254277
- `"util.inspect.defaultOptions"`
278+
- `"util.inspect.replDefaults"`
255279
- `"util.isDeepStrictEqual"`
256280
- `"util.promisify"`
257281
- `"util.TextDecoder"`
@@ -262,14 +286,16 @@ The `"ignores"` option accepts an array of the following strings.
262286
**`v8` module:**
263287

264288
- `"v8"`
289+
- `"v8.DefaultDeserializer"`
290+
- `"v8.DefaultSerializer"`
291+
- `"v8.Deserializer"`
292+
- `"v8.Serializer"`
265293
- `"v8.cachedDataVersionTag"`
294+
- `"v8.deserialize"`
295+
- `"v8.getHeapSnapshot"`
266296
- `"v8.getHeapSpaceStatistics"`
267297
- `"v8.serialize"`
268-
- `"v8.deserialize"`
269-
- `"v8.Serializer"`
270-
- `"v8.Deserializer"`
271-
- `"v8.DefaultSerializer"`
272-
- `"v8.DefaultDeserializer"`
298+
- `"v8.writeHeapSnapshot"`
273299

274300
**`vm` module:**
275301

‎lib/rules/no-unsupported-features/node-builtins.js

+48-17
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const enumeratePropertyNames = require("../../util/enumerate-property-names")
1111
/*eslint-disable camelcase */
1212
const trackMap = {
1313
globals: {
14-
queueMicrotask: { [READ]: { supported: "11.0.0" } },
14+
queueMicrotask: {
15+
[READ]: { supported: "12.0.0", experimental: "11.0.0" },
16+
},
1517
require: {
1618
resolve: {
1719
paths: { [READ]: { supported: "8.9.0" } },
@@ -72,6 +74,10 @@ const trackMap = {
7274
exportPublicKey: { [READ]: { supported: "9.0.0" } },
7375
verifySpkac: { [READ]: { supported: "9.0.0" } },
7476
},
77+
KeyObject: { [READ]: { supported: "11.6.0" } },
78+
createPrivateKey: { [READ]: { supported: "11.6.0" } },
79+
createPublicKey: { [READ]: { supported: "11.6.0" } },
80+
createSecretKey: { [READ]: { supported: "11.6.0" } },
7581
constants: { [READ]: { supported: "6.3.0" } },
7682
fips: { [READ]: { supported: "6.0.0" } },
7783
generateKeyPair: { [READ]: { supported: "10.12.0" } },
@@ -85,14 +91,22 @@ const trackMap = {
8591
scrypt: { [READ]: { supported: "10.5.0" } },
8692
scryptSync: { [READ]: { supported: "10.5.0" } },
8793
setFips: { [READ]: { supported: "10.0.0" } },
94+
sign: { [READ]: { supported: "12.0.0" } },
8895
timingSafeEqual: { [READ]: { supported: "6.6.0" } },
96+
verify: { [READ]: { supported: "12.0.0" } },
8997
},
9098
dns: {
9199
Resolver: { [READ]: { supported: "8.3.0" } },
92100
resolvePtr: { [READ]: { supported: "6.0.0" } },
93101
promises: {
94-
[READ]: { supported: "10.6.0" },
102+
[READ]: { supported: "11.14.0", experimental: "10.6.0" },
103+
},
104+
},
105+
events: {
106+
EventEmitter: {
107+
once: { [READ]: { supported: "11.13.0" } },
95108
},
109+
once: { [READ]: { supported: "11.13.0" } },
96110
},
97111
fs: {
98112
Dirent: { [READ]: { supported: "10.10.0" } },
@@ -107,7 +121,7 @@ const trackMap = {
107121
native: { [READ]: { supported: "9.2.0" } },
108122
},
109123
promises: {
110-
[READ]: { supported: "10.1.0" },
124+
[READ]: { supported: "11.14.0", experimental: "10.1.0" },
111125
},
112126
},
113127
http2: {
@@ -134,6 +148,7 @@ const trackMap = {
134148
},
135149
perf_hooks: {
136150
[READ]: { supported: "8.5.0" },
151+
monitorEventLoopDelay: { [READ]: { supported: "11.10.0" } },
137152
},
138153
process: {
139154
allowedNodeEnvironmentFlags: { [READ]: { supported: "10.10.0" } },
@@ -151,11 +166,20 @@ const trackMap = {
151166
},
152167
ppid: { [READ]: { supported: "9.2.0" } },
153168
release: { [READ]: { supported: "3.0.0" } },
169+
report: { [READ]: { supported: null, experimental: "11.8.0" } },
154170
setegid: { [READ]: { supported: "2.0.0" } },
155171
seteuid: { [READ]: { supported: "2.0.0" } },
156172
setUncaughtExceptionCaptureCallback: {
157173
[READ]: { supported: "9.3.0" },
158174
},
175+
stdout: {
176+
getColorDepth: { [READ]: { supported: "9.9.0" } },
177+
hasColor: { [READ]: { supported: "11.13.0" } },
178+
},
179+
stderr: {
180+
getColorDepth: { [READ]: { supported: "9.9.0" } },
181+
hasColor: { [READ]: { supported: "11.13.0" } },
182+
},
159183
},
160184
stream: {
161185
finished: { [READ]: { supported: "10.0.0" } },
@@ -177,6 +201,7 @@ const trackMap = {
177201
inspect: {
178202
custom: { [READ]: { supported: "6.6.0" } },
179203
defaultOptions: { [READ]: { supported: "6.4.0" } },
204+
replDefaults: { [READ]: { supported: "11.12.0" } },
180205
},
181206
isDeepStrictEqual: { [READ]: { supported: "9.0.0" } },
182207
promisify: { [READ]: { supported: "8.0.0" } },
@@ -189,38 +214,44 @@ const trackMap = {
189214
},
190215
v8: {
191216
[READ]: { supported: "1.0.0" },
217+
DefaultDeserializer: { [READ]: { supported: "8.0.0" } },
218+
DefaultSerializer: { [READ]: { supported: "8.0.0" } },
219+
Deserializer: { [READ]: { supported: "8.0.0" } },
220+
Serializer: { [READ]: { supported: "8.0.0" } },
192221
cachedDataVersionTag: { [READ]: { supported: "8.0.0" } },
222+
deserialize: { [READ]: { supported: "8.0.0" } },
223+
getHeapSnapshot: { [READ]: { supported: "11.13.0" } },
193224
getHeapSpaceStatistics: { [READ]: { supported: "6.0.0" } },
194225
serialize: { [READ]: { supported: "8.0.0" } },
195-
deserialize: { [READ]: { supported: "8.0.0" } },
196-
Serializer: { [READ]: { supported: "8.0.0" } },
197-
Deserializer: { [READ]: { supported: "8.0.0" } },
198-
DefaultSerializer: { [READ]: { supported: "8.0.0" } },
199-
DefaultDeserializer: { [READ]: { supported: "8.0.0" } },
226+
writeHeapSnapshot: { [READ]: { supported: "11.13.0" } },
200227
},
201228
vm: {
202229
Module: { [READ]: { supported: "9.6.0" } },
203230
compileFunction: { [READ]: { supported: "10.10.0" } },
204231
},
205232
worker_threads: {
206-
[READ]: { supported: "10.5.0" },
233+
[READ]: { supported: null, experimental: "10.5.0" },
207234
},
208235
},
209236
}
210237
Object.assign(trackMap.globals, {
211238
Buffer: trackMap.modules.buffer.Buffer,
212-
TextDecoder: Object.assign({}, trackMap.modules.util.TextDecoder, {
239+
TextDecoder: {
240+
...trackMap.modules.util.TextDecoder,
213241
[READ]: { supported: "11.0.0" },
214-
}),
215-
TextEncoder: Object.assign({}, trackMap.modules.util.TextEncoder, {
242+
},
243+
TextEncoder: {
244+
...trackMap.modules.util.TextEncoder,
216245
[READ]: { supported: "11.0.0" },
217-
}),
218-
URL: Object.assign({}, trackMap.modules.url.URL, {
246+
},
247+
URL: {
248+
...trackMap.modules.url.URL,
219249
[READ]: { supported: "10.0.0" },
220-
}),
221-
URLSearchParams: Object.assign({}, trackMap.modules.url.URLSearchParams, {
250+
},
251+
URLSearchParams: {
252+
...trackMap.modules.url.URLSearchParams,
222253
[READ]: { supported: "10.0.0" },
223-
}),
254+
},
224255
console: trackMap.modules.console,
225256
process: trackMap.modules.process,
226257
})

‎lib/util/check-unsupported-builtins.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ function parseOptions(context) {
3131
*/
3232
module.exports = function checkUnsupportedBuiltins(context, trackMap) {
3333
const options = parseOptions(context)
34-
const tracker = new ReferenceTracker(context.getScope(), {
35-
mode: "legacy",
36-
})
34+
const tracker = new ReferenceTracker(context.getScope(), { mode: "legacy" })
3735
const references = [
3836
...tracker.iterateCjsReferences(trackMap.modules || {}),
3937
...tracker.iterateEsmReferences(trackMap.modules || {}),
@@ -42,11 +40,11 @@ module.exports = function checkUnsupportedBuiltins(context, trackMap) {
4240

4341
for (const { node, path, info } of references) {
4442
const name = path.join(".")
45-
const supported = options.version.intersects(
46-
getSemverRange(`<${info.supported}`)
47-
)
43+
const supported =
44+
Boolean(info.supported) &&
45+
!options.version.intersects(getSemverRange(`<${info.supported}`))
4846

49-
if (supported && !options.ignores.has(name)) {
47+
if (!supported && !options.ignores.has(name)) {
5048
context.report({
5149
node,
5250
messageId: "unsupported",

0 commit comments

Comments
 (0)
Please sign in to comment.