From 704f0b9373542e03b42102d30bc44cb7e30fc5d8 Mon Sep 17 00:00:00 2001 From: Sebastian Good <2230835+scagood@users.noreply.github.com> Date: Tue, 14 May 2024 09:39:07 +0200 Subject: [PATCH] fix(node-builtins): Remove "node:" prefix from "ignores" message (#277) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Remove "node:" prefix from "no-unsupported-features/node-builtins" message * docs: Remove enumeration in docs for no-unsupported-features/node-builtins * chore: Remove accidental `gi` * Update docs/rules/no-unsupported-features/node-builtins.md Co-authored-by: Sebastian Good <2230835+scagood@users.noreply.github.com> --------- Co-authored-by: 唯然 --- .../no-unsupported-features/node-builtins.md | 278 +----------------- lib/util/check-unsupported-builtins.js | 6 +- .../no-unsupported-features/node-builtins.js | 12 +- 3 files changed, 20 insertions(+), 276 deletions(-) diff --git a/docs/rules/no-unsupported-features/node-builtins.md b/docs/rules/no-unsupported-features/node-builtins.md index 098f5a73..1a164826 100644 --- a/docs/rules/no-unsupported-features/node-builtins.md +++ b/docs/rules/no-unsupported-features/node-builtins.md @@ -49,273 +49,17 @@ The `"allowExperimental"` option accepts a boolean value (the default value is ` If you are using transpilers, maybe you want to ignore the warnings about some features. You can use this `ignores` option to ignore the given features. -The `"ignores"` option accepts an array of the following strings. - -
- -**Globals:** - -- `"Buffer.alloc"` -- `"Buffer.allocUnsafe"` -- `"Buffer.allocUnsafeSlow"` -- `"Buffer.from"` -- `"TextDecoder"` -- `"TextEncoder"` -- `"URL"` -- `"URLSearchParams"` -- `"console.clear"` -- `"console.count"` -- `"console.countReset"` -- `"console.debug"` -- `"console.dirxml"` -- `"console.group"` -- `"console.groupCollapsed"` -- `"console.groupEnd"` -- `"console.table"` -- `"console.markTimeline"` -- `"console.profile"` -- `"console.profileEnd"` -- `"console.timeLog"` -- `"console.timeStamp"` -- `"console.timeline"` -- `"console.timelineEnd"` -- `"process.allowedNodeEnvironmentFlags"` -- `"process.argv0"` -- `"process.channel"` -- `"process.cpuUsage"` -- `"process.emitWarning"` -- `"process.getegid"` -- `"process.geteuid"` -- `"process.hasUncaughtExceptionCaptureCallback"` -- `"process.hrtime.bigint"` -- `"process.ppid"` -- `"process.release"` -- `"process.report"` -- `"process.setegid"` -- `"process.seteuid"` -- `"process.setUncaughtExceptionCaptureCallback"` -- `"process.stdout.getColorDepth"` -- `"process.stdout.hasColor"` -- `"process.stderr.getColorDepth"` -- `"process.stderr.hasColor"` -- `"queueMicrotask"` -- `"require.resolve.paths"` - -**`assert` module:** - -- `"assert.deepStrictEqual"` -- `"assert.doesNotReject"` -- `"assert.notDeepStrictEqual"` -- `"assert.rejects"` -- `"assert.strict"` -- `"assert.strict.doesNotReject"` -- `"assert.strict.rejects"` - -**`async_hooks` module:** - -- `"async_hooks"` -- `"async_hooks.createHook"` - -**`buffer` module:** - -- `"buffer.Buffer.alloc"` -- `"buffer.Buffer.allocUnsafe"` -- `"buffer.Buffer.allocUnsafeSlow"` -- `"buffer.Buffer.from"` -- `"buffer.constants"` -- `"buffer.kMaxLength"` -- `"buffer.transcode"` - -**`child_process` module:** - -- `"child_process.ChildProcess"` - -**`console` module:** - -- `"console.clear"` -- `"console.count"` -- `"console.countReset"` -- `"console.debug"` -- `"console.dirxml"` -- `"console.group"` -- `"console.groupCollapsed"` -- `"console.groupEnd"` -- `"console.table"` -- `"console.markTimeline"` -- `"console.profile"` -- `"console.profileEnd"` -- `"console.timeLog"` -- `"console.timeStamp"` -- `"console.timeline"` -- `"console.timelineEnd"` - -**`crypto` module:** - -- `"crypto.Certificate.exportChallenge"` -- `"crypto.Certificate.exportPublicKey"` -- `"crypto.Certificate.verifySpkac"` -- `"crypto.KeyObject"` -- `"crypto.createPrivateKey"` -- `"crypto.createPublicKey"` -- `"crypto.createSecretKey"` -- `"crypto.constants"` -- `"crypto.fips"` -- `"crypto.generateKeyPair"` -- `"crypto.generateKeyPairSync"` -- `"crypto.getCurves"` -- `"crypto.getFips"` -- `"crypto.privateEncrypt"` -- `"crypto.publicDecrypt"` -- `"crypto.randomFillSync"` -- `"crypto.randomFill"` -- `"crypto.scrypt"` -- `"crypto.scryptSync"` -- `"crypto.setFips"` -- `"crypto.sign"` -- `"crypto.timingSafeEqual"` -- `"crypto.verify"` - -**`dns` module:** - -- `"dns.Resolver"` -- `"dns.resolvePtr"` -- `"dns.promises"` - -**`events` module:** - -- `"events.EventEmitter.once"` -- `"events.once"` - -**`fs` module:** - -- `"fs.Dirent"` -- `"fs.copyFile"` -- `"fs.copyFileSync"` -- `"fs.mkdtemp"` -- `"fs.mkdtempSync"` -- `"fs.realpath.native"` -- `"fs.realpathSync.native"` -- `"fs.promises"` -- `"fs.writev"` -- `"fs.writevSync"` - -**`http2` module:** - -- `"http2"` - -**`inspector` module:** - -- `"inspector"` - -**`module` module:** - -- `"module.Module.builtinModules"` -- `"module.Module.createRequireFromPath"` -- `"module.Module.createRequire"` -- `"module.Module.syncBuiltinESMExports"` -- `"module.builtinModules"` -- `"module.createRequireFromPath"` -- `"module.createRequire"` -- `"module.syncBuiltinESMExports"` - -**`os` module:** - -- `"os.constants"` -- `"os.constants.priority"` -- `"os.getPriority"` -- `"os.homedir"` -- `"os.setPriority"` -- `"os.userInfo"` - -**`path` module:** - -- `"path.toNamespacedPath"` - -**`perf_hooks` module:** - -- `"perf_hooks"` -- `"perf_hooks.monitorEventLoopDelay"` - -**`process` module:** - -- `"process.allowedNodeEnvironmentFlags"` -- `"process.argv0"` -- `"process.channel"` -- `"process.cpuUsage"` -- `"process.emitWarning"` -- `"process.getegid"` -- `"process.geteuid"` -- `"process.hasUncaughtExceptionCaptureCallback"` -- `"process.hrtime.bigint"` -- `"process.ppid"` -- `"process.release"` -- `"process.report"` -- `"process.resourceUsage"` -- `"process.setegid"` -- `"process.seteuid"` -- `"process.setUncaughtExceptionCaptureCallback"` -- `"process.stdout.getColorDepth"` -- `"process.stdout.hasColor"` -- `"process.stderr.getColorDepth"` -- `"process.stderr.hasColor"` - -**`stream` module:** - -- `"stream.Readable.from"` -- `"stream.finished"` -- `"stream.pipeline"` - -**`trace_events` module:** - -- `"trace_events"` - -**`url` module:** - -- `"url.URL"` -- `"url.URLSearchParams"` -- `"url.domainToASCII"` -- `"url.domainToUnicode"` - -**`util` module:** - -- `"util.callbackify"` -- `"util.formatWithOptions"` -- `"util.getSystemErrorName"` -- `"util.inspect.custom"` -- `"util.inspect.defaultOptions"` -- `"util.inspect.replDefaults"` -- `"util.isDeepStrictEqual"` -- `"util.promisify"` -- `"util.TextDecoder"` -- `"util.TextEncoder"` -- `"util.types"` -- `"util.types.isBoxedPrimitive"` - -**`v8` module:** - -- `"v8"` -- `"v8.DefaultDeserializer"` -- `"v8.DefaultSerializer"` -- `"v8.Deserializer"` -- `"v8.Serializer"` -- `"v8.cachedDataVersionTag"` -- `"v8.deserialize"` -- `"v8.getHeapCodeStatistics"` -- `"v8.getHeapSnapshot"` -- `"v8.getHeapSpaceStatistics"` -- `"v8.serialize"` -- `"v8.writeHeapSnapshot"` - -**`vm` module:** - -- `"vm.Module"` -- `"vm.compileFunction"` - -**`worker_threads` module:** - -- `"worker_threads"` - -
+The `"ignores"` option accepts an array of strings. + +> [!TIP] +> You will see the following error messages: +> +> - `The '{{name}}' is not an experimental feature until Node.js {{version}}.` +> - `The '{{name}}' is still an experimental feature and is not supported until Node.js {{version}}.` +> - `The '{{name}}' is still an experimental feature` +> +> The "name" property is what you can use in your `ignores` array +> You can find the full tree view of the list of the modules over in [lib/unsupported-features/node-builtins-modules](https://github.com/eslint-community/eslint-plugin-n/tree/HEAD/lib/unsupported-features/node-builtins-modules). and globals over in [lib/unsupported-features/node-globals.js](https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/lib/unsupported-features/node-globals.js) ### Shared Settings diff --git a/lib/util/check-unsupported-builtins.js b/lib/util/check-unsupported-builtins.js index 51af9d3e..0412fd03 100644 --- a/lib/util/check-unsupported-builtins.js +++ b/lib/util/check-unsupported-builtins.js @@ -113,7 +113,7 @@ module.exports.checkUnsupportedBuiltins = function checkUnsupportedBuiltins( node, messageId: "not-experimental-till", data: { - name: path.join("."), + name: name, experimental: experimentalVersion, version: options.version.raw, }, @@ -132,7 +132,7 @@ module.exports.checkUnsupportedBuiltins = function checkUnsupportedBuiltins( node, messageId: "not-supported-till", data: { - name: path.join("."), + name: name, supported: supportedVersion, version: options.version.raw, }, @@ -144,7 +144,7 @@ module.exports.checkUnsupportedBuiltins = function checkUnsupportedBuiltins( node, messageId: "not-supported-yet", data: { - name: path.join("."), + name: name, version: options.version.raw, }, }) diff --git a/tests/lib/rules/no-unsupported-features/node-builtins.js b/tests/lib/rules/no-unsupported-features/node-builtins.js index 9b3eb220..1c8295d8 100644 --- a/tests/lib/rules/no-unsupported-features/node-builtins.js +++ b/tests/lib/rules/no-unsupported-features/node-builtins.js @@ -433,7 +433,7 @@ new RuleTester({ languageOptions: { sourceType: "module" } }).run( { messageId: "not-supported-till", data: { - name: "node:assert", + name: "assert", supported: "14.13.1 (backported: ^12.20.0)", version: "3.9.9", }, @@ -447,7 +447,7 @@ new RuleTester({ languageOptions: { sourceType: "module" } }).run( { messageId: "not-supported-till", data: { - name: "node:assert", + name: "assert", supported: "14.13.1 (backported: ^12.20.0)", version: "3.9.9", }, @@ -626,7 +626,7 @@ new RuleTester({ languageOptions: { sourceType: "module" } }).run( { messageId: "not-supported-till", data: { - name: "node:async_hooks", + name: "async_hooks", supported: "16.4.0", version: "7.9.9", }, @@ -640,7 +640,7 @@ new RuleTester({ languageOptions: { sourceType: "module" } }).run( { messageId: "not-supported-till", data: { - name: "node:async_hooks", + name: "async_hooks", supported: "16.4.0", version: "7.9.9", }, @@ -2940,7 +2940,7 @@ new RuleTester({ languageOptions: { sourceType: "module" } }).run( { messageId: "not-supported-till", data: { - name: "node:fs/promises", + name: "fs/promises", supported: "14.13.1", version: "13.14.0", }, @@ -2954,7 +2954,7 @@ new RuleTester({ languageOptions: { sourceType: "module" } }).run( { messageId: "not-supported-till", data: { - name: "node:fs/promises", + name: "fs/promises", supported: "14.13.1", version: "13.14.0", },