Skip to content

Commit

Permalink
fix(node-builtins): Remove "node:" prefix from "ignores" message (#277)
Browse files Browse the repository at this point in the history
* 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: 唯然 <weiran.zsd@outlook.com>
  • Loading branch information
scagood and aladdin-add authored May 14, 2024
1 parent 4a685c0 commit 704f0b9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 276 deletions.
278 changes: 11 additions & 267 deletions docs/rules/no-unsupported-features/node-builtins.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details>

**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"`

</details>
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

Expand Down
6 changes: 3 additions & 3 deletions lib/util/check-unsupported-builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -144,7 +144,7 @@ module.exports.checkUnsupportedBuiltins = function checkUnsupportedBuiltins(
node,
messageId: "not-supported-yet",
data: {
name: path.join("."),
name: name,
version: options.version.raw,
},
})
Expand Down
12 changes: 6 additions & 6 deletions tests/lib/rules/no-unsupported-features/node-builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -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",
},
Expand Down Expand Up @@ -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",
},
Expand All @@ -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",
},
Expand Down Expand Up @@ -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",
},
Expand All @@ -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",
},
Expand Down

0 comments on commit 704f0b9

Please sign in to comment.