File: node-builtins.js

package info (click to toggle)
node-eslint-plugin-node 11.1.0~ds-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 2,084 kB
  • sloc: javascript: 23,756; perl: 48; makefile: 38; sh: 32
file content (369 lines) | stat: -rw-r--r-- 14,585 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/**
 * @author Toru Nagashima
 * See LICENSE file in root directory for full license.
 */
"use strict"

const { READ } = require("eslint-utils")
const checkUnsupportedBuiltins = require("../../util/check-unsupported-builtins")
const enumeratePropertyNames = require("../../util/enumerate-property-names")

/*eslint-disable camelcase */
const trackMap = {
    globals: {
        queueMicrotask: {
            [READ]: { supported: "12.0.0", experimental: "11.0.0" },
        },
        require: {
            resolve: {
                paths: { [READ]: { supported: "8.9.0" } },
            },
        },
    },
    modules: {
        assert: {
            strict: {
                [READ]: { supported: "9.9.0", backported: ["8.13.0"] },
                doesNotReject: { [READ]: { supported: "10.0.0" } },
                rejects: { [READ]: { supported: "10.0.0" } },
            },
            deepStrictEqual: { [READ]: { supported: "4.0.0" } },
            doesNotReject: { [READ]: { supported: "10.0.0" } },
            notDeepStrictEqual: { [READ]: { supported: "4.0.0" } },
            rejects: { [READ]: { supported: "10.0.0" } },
        },
        async_hooks: {
            [READ]: { supported: "8.0.0" },
            createHook: { [READ]: { supported: "8.1.0" } },
        },
        buffer: {
            Buffer: {
                alloc: { [READ]: { supported: "4.5.0" } },
                allocUnsafe: { [READ]: { supported: "4.5.0" } },
                allocUnsafeSlow: { [READ]: { supported: "4.5.0" } },
                from: { [READ]: { supported: "4.5.0" } },
            },
            kMaxLength: { [READ]: { supported: "3.0.0" } },
            transcode: { [READ]: { supported: "7.1.0" } },
            constants: { [READ]: { supported: "8.2.0" } },
        },
        child_process: {
            ChildProcess: { [READ]: { supported: "2.2.0" } },
        },
        console: {
            clear: { [READ]: { supported: "8.3.0", backported: ["6.13.0"] } },
            count: { [READ]: { supported: "8.3.0", backported: ["6.13.0"] } },
            countReset: {
                [READ]: { supported: "8.3.0", backported: ["6.13.0"] },
            },
            debug: { [READ]: { supported: "8.0.0" } },
            dirxml: { [READ]: { supported: "8.0.0" } },
            group: { [READ]: { supported: "8.5.0" } },
            groupCollapsed: { [READ]: { supported: "8.5.0" } },
            groupEnd: { [READ]: { supported: "8.5.0" } },
            table: { [READ]: { supported: "10.0.0" } },
            markTimeline: { [READ]: { supported: "8.0.0" } },
            profile: { [READ]: { supported: "8.0.0" } },
            profileEnd: { [READ]: { supported: "8.0.0" } },
            timeLog: { [READ]: { supported: "10.7.0" } },
            timeStamp: { [READ]: { supported: "8.0.0" } },
            timeline: { [READ]: { supported: "8.0.0" } },
            timelineEnd: { [READ]: { supported: "8.0.0" } },
        },
        crypto: {
            Certificate: {
                exportChallenge: { [READ]: { supported: "9.0.0" } },
                exportPublicKey: { [READ]: { supported: "9.0.0" } },
                verifySpkac: { [READ]: { supported: "9.0.0" } },
            },
            ECDH: { [READ]: { supported: "8.8.0", backported: ["6.13.0"] } },
            KeyObject: { [READ]: { supported: "11.6.0" } },
            createPrivateKey: { [READ]: { supported: "11.6.0" } },
            createPublicKey: { [READ]: { supported: "11.6.0" } },
            createSecretKey: { [READ]: { supported: "11.6.0" } },
            constants: { [READ]: { supported: "6.3.0" } },
            fips: { [READ]: { supported: "6.0.0" } },
            generateKeyPair: { [READ]: { supported: "10.12.0" } },
            generateKeyPairSync: { [READ]: { supported: "10.12.0" } },
            getCurves: { [READ]: { supported: "2.3.0" } },
            getFips: { [READ]: { supported: "10.0.0" } },
            privateEncrypt: { [READ]: { supported: "1.1.0" } },
            publicDecrypt: { [READ]: { supported: "1.1.0" } },
            randomFillSync: {
                [READ]: { supported: "7.10.0", backported: ["6.13.0"] },
            },
            randomFill: {
                [READ]: { supported: "7.10.0", backported: ["6.13.0"] },
            },
            scrypt: { [READ]: { supported: "10.5.0" } },
            scryptSync: { [READ]: { supported: "10.5.0" } },
            setFips: { [READ]: { supported: "10.0.0" } },
            sign: { [READ]: { supported: "12.0.0" } },
            timingSafeEqual: { [READ]: { supported: "6.6.0" } },
            verify: { [READ]: { supported: "12.0.0" } },
        },
        dns: {
            Resolver: { [READ]: { supported: "8.3.0" } },
            resolvePtr: { [READ]: { supported: "6.0.0" } },
            promises: {
                [READ]: {
                    supported: "11.14.0",
                    backported: ["10.17.0"],
                    experimental: "10.6.0",
                },
            },
        },
        events: {
            EventEmitter: {
                once: {
                    [READ]: { supported: "11.13.0", backported: ["10.16.0"] },
                },
            },
            once: { [READ]: { supported: "11.13.0", backported: ["10.16.0"] } },
        },
        fs: {
            Dirent: { [READ]: { supported: "10.10.0" } },
            copyFile: { [READ]: { supported: "8.5.0" } },
            copyFileSync: { [READ]: { supported: "8.5.0" } },
            mkdtemp: { [READ]: { supported: "5.10.0" } },
            mkdtempSync: { [READ]: { supported: "5.10.0" } },
            realpath: {
                native: { [READ]: { supported: "9.2.0" } },
            },
            realpathSync: {
                native: { [READ]: { supported: "9.2.0" } },
            },
            promises: {
                [READ]: {
                    supported: "11.14.0",
                    backported: ["10.17.0"],
                    experimental: "10.1.0",
                },
            },
            writev: { [READ]: { supported: "12.9.0" } },
            writevSync: { [READ]: { supported: "12.9.0" } },
        },
        http2: {
            [READ]: {
                supported: "10.10.0",
                backported: ["8.13.0"],
                experimental: "8.4.0",
            },
        },
        inspector: {
            [READ]: { supported: null, experimental: "8.0.0" },
        },
        module: {
            Module: {
                builtinModules: {
                    [READ]: {
                        supported: "9.3.0",
                        backported: ["6.13.0", "8.10.0"],
                    },
                },
                createRequireFromPath: { [READ]: { supported: "10.12.0" } },
                createRequire: { [READ]: { supported: "12.2.0" } },
                syncBuiltinESMExports: { [READ]: { supported: "12.12.0" } },
            },
            builtinModules: {
                [READ]: {
                    supported: "9.3.0",
                    backported: ["6.13.0", "8.10.0"],
                },
            },
            createRequireFromPath: { [READ]: { supported: "10.12.0" } },
            createRequire: { [READ]: { supported: "12.2.0" } },
            syncBuiltinESMExports: { [READ]: { supported: "12.12.0" } },
        },
        os: {
            constants: {
                [READ]: { supported: "6.3.0" },
                priority: { [READ]: { supported: "10.10.0" } },
            },
            getPriority: { [READ]: { supported: "10.10.0" } },
            homedir: { [READ]: { supported: "2.3.0" } },
            setPriority: { [READ]: { supported: "10.10.0" } },
            userInfo: { [READ]: { supported: "6.0.0" } },
        },
        path: {
            toNamespacedPath: { [READ]: { supported: "9.0.0" } },
        },
        perf_hooks: {
            [READ]: { supported: "8.5.0" },
            monitorEventLoopDelay: { [READ]: { supported: "11.10.0" } },
        },
        process: {
            allowedNodeEnvironmentFlags: { [READ]: { supported: "10.10.0" } },
            argv0: { [READ]: { supported: "6.4.0" } },
            channel: { [READ]: { supported: "7.1.0" } },
            cpuUsage: { [READ]: { supported: "6.1.0" } },
            emitWarning: { [READ]: { supported: "6.0.0" } },
            getegid: { [READ]: { supported: "2.0.0" } },
            geteuid: { [READ]: { supported: "2.0.0" } },
            hasUncaughtExceptionCaptureCallback: {
                [READ]: { supported: "9.3.0" },
            },
            hrtime: {
                bigint: { [READ]: { supported: "10.7.0" } },
            },
            ppid: {
                [READ]: {
                    supported: "9.2.0",
                    backported: ["6.13.0", "8.10.0"],
                },
            },
            release: { [READ]: { supported: "3.0.0" } },
            report: { [READ]: { supported: null, experimental: "11.8.0" } },
            resourceUsage: { [READ]: { supported: "12.6.0" } },
            setegid: { [READ]: { supported: "2.0.0" } },
            seteuid: { [READ]: { supported: "2.0.0" } },
            setUncaughtExceptionCaptureCallback: {
                [READ]: { supported: "9.3.0" },
            },
            stdout: {
                getColorDepth: { [READ]: { supported: "9.9.0" } },
                hasColor: { [READ]: { supported: "11.13.0" } },
            },
            stderr: {
                getColorDepth: { [READ]: { supported: "9.9.0" } },
                hasColor: { [READ]: { supported: "11.13.0" } },
            },
        },
        stream: {
            Readable: {
                from: {
                    [READ]: { supported: "12.3.0", backported: ["10.17.0"] },
                },
            },
            finished: { [READ]: { supported: "10.0.0" } },
            pipeline: { [READ]: { supported: "10.0.0" } },
        },
        trace_events: {
            [READ]: { supported: "10.0.0" },
        },
        url: {
            URL: { [READ]: { supported: "7.0.0", backported: ["6.13.0"] } },
            URLSearchParams: {
                [READ]: { supported: "7.5.0", backported: ["6.13.0"] },
            },
            domainToASCII: { [READ]: { supported: "7.4.0" } },
            domainToUnicode: { [READ]: { supported: "7.4.0" } },
        },
        util: {
            callbackify: { [READ]: { supported: "8.2.0" } },
            formatWithOptions: { [READ]: { supported: "10.0.0" } },
            getSystemErrorName: {
                [READ]: { supported: "9.7.0", backported: ["8.12.0"] },
            },
            inspect: {
                custom: { [READ]: { supported: "6.6.0" } },
                defaultOptions: { [READ]: { supported: "6.4.0" } },
                replDefaults: { [READ]: { supported: "11.12.0" } },
            },
            isDeepStrictEqual: { [READ]: { supported: "9.0.0" } },
            promisify: { [READ]: { supported: "8.0.0" } },
            TextDecoder: {
                [READ]: { supported: "8.9.0", experimental: "8.3.0" },
            },
            TextEncoder: {
                [READ]: { supported: "8.9.0", experimental: "8.3.0" },
            },
            types: {
                [READ]: { supported: "10.0.0" },
                isBoxedPrimitive: { [READ]: { supported: "10.11.0" } },
            },
        },
        v8: {
            [READ]: { supported: "1.0.0" },
            DefaultDeserializer: { [READ]: { supported: "8.0.0" } },
            DefaultSerializer: { [READ]: { supported: "8.0.0" } },
            Deserializer: { [READ]: { supported: "8.0.0" } },
            Serializer: { [READ]: { supported: "8.0.0" } },
            cachedDataVersionTag: { [READ]: { supported: "8.0.0" } },
            deserialize: { [READ]: { supported: "8.0.0" } },
            getHeapCodeStatistics: { [READ]: { supported: "12.8.0" } },
            getHeapSnapshot: { [READ]: { supported: "11.13.0" } },
            getHeapSpaceStatistics: { [READ]: { supported: "6.0.0" } },
            serialize: { [READ]: { supported: "8.0.0" } },
            writeHeapSnapshot: { [READ]: { supported: "11.13.0" } },
        },
        vm: {
            Module: { [READ]: { supported: "9.6.0" } },
            compileFunction: { [READ]: { supported: "10.10.0" } },
        },
        worker_threads: {
            [READ]: { supported: "12.11.0", experimental: "10.5.0" },
        },
    },
}
Object.assign(trackMap.globals, {
    Buffer: trackMap.modules.buffer.Buffer,
    TextDecoder: {
        ...trackMap.modules.util.TextDecoder,
        [READ]: { supported: "11.0.0" },
    },
    TextEncoder: {
        ...trackMap.modules.util.TextEncoder,
        [READ]: { supported: "11.0.0" },
    },
    URL: {
        ...trackMap.modules.url.URL,
        [READ]: { supported: "10.0.0" },
    },
    URLSearchParams: {
        ...trackMap.modules.url.URLSearchParams,
        [READ]: { supported: "10.0.0" },
    },
    console: trackMap.modules.console,
    process: trackMap.modules.process,
})
/*eslint-enable camelcase */

module.exports = {
    meta: {
        docs: {
            description:
                "disallow unsupported Node.js built-in APIs on the specified version",
            category: "Possible Errors",
            recommended: true,
            url:
                "https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/no-unsupported-features/node-builtins.md",
        },
        fixable: null,
        messages: {
            unsupported:
                "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.",
        },
        schema: [
            {
                type: "object",
                properties: {
                    version: {
                        type: "string",
                    },
                    ignores: {
                        type: "array",
                        items: {
                            enum: Array.from(
                                new Set([
                                    ...enumeratePropertyNames(trackMap.globals),
                                    ...enumeratePropertyNames(trackMap.modules),
                                ])
                            ),
                        },
                        uniqueItems: true,
                    },
                },
                additionalProperties: false,
            },
        ],
        type: "problem",
    },
    create(context) {
        return {
            "Program:exit"() {
                checkUnsupportedBuiltins(context, trackMap)
            },
        }
    },
}