diff --git a/README.md b/README.md index ac6358ad..0d387e50 100644 --- a/README.md +++ b/README.md @@ -59,29 +59,9 @@ $ npm install --save-dev eslint eslint-plugin-node | [node/no-unpublished-bin](./docs/rules/no-unpublished-bin.md) | disallow 'bin' files which are ignored by npm | ⭐️ | | [node/no-unpublished-import](./docs/rules/no-unpublished-import.md) | disallow `import` declarations of private things | | | [node/no-unpublished-require](./docs/rules/no-unpublished-require.md) | disallow `require()` expressions of private things | ⭐️ | -| [node/no-unsupported-features/assert](./docs/rules/no-unsupported-features/assert.md) | disallow unsupported `assert` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/async_hooks](./docs/rules/no-unsupported-features/async_hooks.md) | disallow unsupported `async_hooks` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/buffer](./docs/rules/no-unsupported-features/buffer.md) | disallow unsupported `buffer` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/child_process](./docs/rules/no-unsupported-features/child_process.md) | disallow unsupported `child_process` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/console](./docs/rules/no-unsupported-features/console.md) | disallow unsupported `console` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/crypto](./docs/rules/no-unsupported-features/crypto.md) | disallow unsupported `crypto` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/dns](./docs/rules/no-unsupported-features/dns.md) | disallow unsupported `dns` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/ecma](./docs/rules/no-unsupported-features/ecma.md) | disallow unsupported ECMAScript features on the specified version | ⭐️ | -| [node/no-unsupported-features/fs](./docs/rules/no-unsupported-features/fs.md) | disallow unsupported `fs` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/http2](./docs/rules/no-unsupported-features/http2.md) | disallow unsupported `http2` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/inspector](./docs/rules/no-unsupported-features/inspector.md) | disallow unsupported `inspector` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/module](./docs/rules/no-unsupported-features/module.md) | disallow unsupported `module` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/os](./docs/rules/no-unsupported-features/os.md) | disallow unsupported `os` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/path](./docs/rules/no-unsupported-features/path.md) | disallow unsupported `path` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/perf_hooks](./docs/rules/no-unsupported-features/perf_hooks.md) | disallow unsupported `perf_hooks` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/process](./docs/rules/no-unsupported-features/process.md) | disallow unsupported `process` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/stream](./docs/rules/no-unsupported-features/stream.md) | disallow unsupported `stream` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/trace_events](./docs/rules/no-unsupported-features/trace_events.md) | disallow unsupported `trace_events` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/url](./docs/rules/no-unsupported-features/url.md) | disallow unsupported `url` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/util](./docs/rules/no-unsupported-features/util.md) | disallow unsupported `util` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/v8](./docs/rules/no-unsupported-features/v8.md) | disallow unsupported `v8` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/vm](./docs/rules/no-unsupported-features/vm.md) | disallow unsupported `vm` APIs on the specified version | ⭐️ | -| [node/no-unsupported-features/worker_threads](./docs/rules/no-unsupported-features/worker_threads.md) | disallow unsupported `worker_threads` APIs on the specified version | ⭐️ | +| [node/no-unsupported-features/es-builtins](./docs/rules/no-unsupported-features/es-builtins.md) | disallow unsupported ECMAScript built-ins on the specified version | ⭐️ | +| [node/no-unsupported-features/es-syntax](./docs/rules/no-unsupported-features/es-syntax.md) | disallow unsupported ECMAScript syntax on the specified version | ⭐️ | +| [node/no-unsupported-features/node-builtins](./docs/rules/no-unsupported-features/node-builtins.md) | disallow unsupported Node.js built-in APIs on the specified version | ⭐️ | | [node/process-exit-as-throw](./docs/rules/process-exit-as-throw.md) | make `process.exit()` expressions the same code path as `throw` | ⭐️ | | [node/shebang](./docs/rules/shebang.md) | enforce the correct usage of shebang | ⭐️✒️ | diff --git a/docs/rules/no-unsupported-features/assert.md b/docs/rules/no-unsupported-features/assert.md deleted file mode 100644 index ad67ec34..00000000 --- a/docs/rules/no-unsupported-features/assert.md +++ /dev/null @@ -1,65 +0,0 @@ -# Disallow unsupported `assert` APIs on the specified version (no-unsupported-features/assert) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `assert` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `assert` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/assert.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/assert": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"assert.strict"` -- `"assert.strict.doesNotReject"` -- `"assert.strict.rejects"` -- `"assert.deepStrictEqual"` -- `"assert.doesNotReject"` -- `"assert.notDeepStrictEqual"` -- `"assert.rejects"` - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/async_hooks.md b/docs/rules/no-unsupported-features/async_hooks.md deleted file mode 100644 index fdd481bf..00000000 --- a/docs/rules/no-unsupported-features/async_hooks.md +++ /dev/null @@ -1,69 +0,0 @@ -# Disallow unsupported `async_hooks` APIs on the specified version (no-unsupported-features/async_hooks) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `async_hooks` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `async_hooks` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/async_hooks.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/async_hooks": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"async_hooks"` -- `"async_hooks.createHook"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -This means the following methods are not reported: - -- [asyncResource.runInAsyncScope(fn[, thisArg, ...args])](https://nodejs.org/docs/v10.6.0/api/async_hooks.html#async_hooks_asyncresource_runinasyncscope_fn_thisarg_args) (Added in v9.6.0) - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/buffer.md b/docs/rules/no-unsupported-features/buffer.md deleted file mode 100644 index 6c44ea2e..00000000 --- a/docs/rules/no-unsupported-features/buffer.md +++ /dev/null @@ -1,79 +0,0 @@ -# Disallow unsupported `buffer` APIs on the specified version (no-unsupported-features/buffer) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `buffer` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `buffer` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/buffer.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/buffer": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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"` - -(`buffer` module): - -- `"buffer.Buffer.alloc"` -- `"buffer.Buffer.allocUnsafe"` -- `"buffer.Buffer.allocUnsafeSlow"` -- `"buffer.Buffer.from"` -- `"buffer.kMaxLength"` -- `"buffer.transcode"` -- `"buffer.constants"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/child_process.md b/docs/rules/no-unsupported-features/child_process.md deleted file mode 100644 index beca4b2d..00000000 --- a/docs/rules/no-unsupported-features/child_process.md +++ /dev/null @@ -1,87 +0,0 @@ -# Disallow unsupported `child_process` APIs on the specified version (no-unsupported-features/child_process) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `child_process` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `child_process` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/child_process.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/child_process": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"child_process.ChildProcess"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -This means the following methods are not reported: - -- [child_process.exec(command[, options][, callback])](https://nodejs.org/docs/v10.6.0/api/child_process.html#child_process_child_process_exec_command_options_callback) - - `options.windowsHide` (Added in v8.8.0) -- [child_process.execFile(file[, args][, options][, callback])](https://nodejs.org/docs/v10.6.0/api/child_process.html#child_process_child_process_execfile_file_args_options_callback) - - `options.windowsHide` (Added in v8.8.0) -- [child_process.fork(modulePath[, args][, options])](https://nodejs.org/docs/v10.6.0/api/child_process.html#child_process_child_process_fork_modulepath_args_options) - - `options.stdio` (Added in v6.4.0. Can be a string in v8.0.0) -- [child_process.spawn(command[, args][, options])](https://nodejs.org/docs/v10.6.0/api/child_process.html#child_process_child_process_spawn_command_args_options) - - `options.shell` (Added in v5.7.0) - - `options.argv0` (Added in v6.4.0) - - `options.windowsHide` (Added in v8.8.0) -- [child_process.execFileSync(file[, args][, options])](https://nodejs.org/docs/v10.6.0/api/child_process.html#child_process_child_process_execfilesync_file_args_options) - - `options.windowsHide` (Added in v8.8.0) -- [child_process.execSync(command[, options])](https://nodejs.org/docs/v10.6.0/api/child_process.html#child_process_child_process_execsync_command_options) - - `options.windowsHide` (Added in v8.8.0) -- [child_process.spawnSync(command[, args][, options])](https://nodejs.org/docs/v10.6.0/api/child_process.html#child_process_child_process_spawnsync_command_args_options) - - `options.shell` (Added in v5.7.0) - - `options.windowsHide` (Added in v8.8.0) -- [subprocess.send(message[, sendHandle[, options]][, callback])](https://nodejs.org/docs/v10.6.0/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) - - `callback` (Added in v4.0.0) - - `options` (Added in v5.8.0) - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/console.md b/docs/rules/no-unsupported-features/console.md deleted file mode 100644 index eedfb3d0..00000000 --- a/docs/rules/no-unsupported-features/console.md +++ /dev/null @@ -1,78 +0,0 @@ -# Disallow unsupported `console` APIs on the specified version (no-unsupported-features/console) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `console` APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `console` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/console.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/console": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"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.timeStamp"` -- `"console.timeline"` -- `"console.timelineEnd"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/crypto.md b/docs/rules/no-unsupported-features/crypto.md deleted file mode 100644 index 84b110b5..00000000 --- a/docs/rules/no-unsupported-features/crypto.md +++ /dev/null @@ -1,78 +0,0 @@ -# Disallow unsupported `crypto` APIs on the specified version (no-unsupported-features/crypto) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `crypto` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `crypto` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/crypto.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/crypto": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"crypto.Certificate.exportChallenge"` -- `"crypto.Certificate.exportPublicKey"` -- `"crypto.Certificate.verifySpkac"` -- `"crypto.constants"` -- `"crypto.fips"` -- `"crypto.getCurves"` -- `"crypto.getFips"` -- `"crypto.privateEncrypt"` -- `"crypto.publicDecrypt"` -- `"crypto.randomFillSync"` -- `"crypto.randomFill"` -- `"crypto.scrypt"` -- `"crypto.scryptSync"` -- `"crypto.setFips"` -- `"crypto.timingSafeEqual"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/dns.md b/docs/rules/no-unsupported-features/dns.md deleted file mode 100644 index 44e88225..00000000 --- a/docs/rules/no-unsupported-features/dns.md +++ /dev/null @@ -1,66 +0,0 @@ -# Disallow unsupported `dns` APIs on the specified version (no-unsupported-features/dns) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `dns` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `dns` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/dns.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/dns": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"dns.Resolver"` -- `"dns.resolvePtr"` -- `"dns.promises"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/ecma.md b/docs/rules/no-unsupported-features/ecma.md deleted file mode 100644 index 312e37fc..00000000 --- a/docs/rules/no-unsupported-features/ecma.md +++ /dev/null @@ -1,196 +0,0 @@ -# Disallow unsupported ECMAScript features on the specified version (no-unsupported-features/ecma) - -ECMAScript standard is updating every two months. -You can check [node.green](https://node.green/) to know which Node.js version supports each ECMAScript feature. - -This rule reports unsupported ECMAScript features on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Supported ECMAScript features - -This rule supports ECMAScript 2018 and the features which are arrived at Stage 4 by May 2018. -See also [TC39 finished proposals](https://github.com/tc39/proposals/blob/master/finished-proposals.md). - -Please configure your `.eslintrc` file to succeed to succeed in parsing those features. -For example of `.eslintrc.json`: - -```json -{ - "env": { - "es6": true - }, - "parserOptions": { - "ecmaVersion": 2019 - }, - "globals": { - "Atomics": false, - "SharedArrayBuffer": false - } -} -``` - -### Options - -```json -{ - "node/no-unsupported-features/ecma": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -
- -**ES2019:** - -- `"syntax"` - - (nothing) -- `"runtime"` - - (nothing) - -**ES2018:** - -- `"syntax"` - - `"asyncIteration"` - - `"malformedTemplateLiterals"` - - `"regexpLookbehind"` - - `"regexpNamedCaptureGroups"` - - `"regexpS"` - - `"regexpUnicodeProperties"` - - `"restSpreadProperties"` -- `"runtime"` - - (nothing) - -**ES2017:** - -- `"syntax"` - - `"asyncFunctions"` - - `"trailingCommasInFunctions"` -- `"runtime"` - - `"Atomics"` - - `"Object.values"` - - `"Object.entries"` - - `"Object.getOwnPropertyDescriptors"` - - `"SharedArrayBuffer"` - -**ES2016:** - -- `"syntax"` - - `"exponentialOperators"` -- `"runtime"` - - (nothing) - -**ES2015:** - -- `"syntax"` - - `"arrowFunctions"` - - `"binaryNumericLiterals"` - - `"blockScopedFunctions"` - - `"blockScopedVariables"` - - `"classes"` - - `"computedProperties"` - - `"defaultParameters"` - - `"destructuring"` - - `"forOfLoops"` - - `"generators"` - - `"modules"` - - `"new.target"` - - `"objectSuperProperties"` - - `"octalNumericLiterals"` - - `"propertyShorthands"` - - `"regexpU"` - - `"regexpY"` - - `"restParameters"` - - `"spreadElements"` - - `"templateLiterals"` - - `"unicodeCodePointEscapes"` -- `"runtime"` - - `"Array.from"` - - `"Array.of"` - - `"Map"` - - `"Math.acosh"` - - `"Math.asinh"` - - `"Math.atanh"` - - `"Math.cbrt"` - - `"Math.clz32"` - - `"Math.cosh"` - - `"Math.expm1"` - - `"Math.fround"` - - `"Math.hypot"` - - `"Math.imul"` - - `"Math.log10"` - - `"Math.log1p"` - - `"Math.log2"` - - `"Math.sign"` - - `"Math.sinh"` - - `"Math.tanh"` - - `"Math.trunc"` - - `"Number.EPSILON"` - - `"Number.isFinite"` - - `"Number.isInteger"` - - `"Number.isNaN"` - - `"Number.isSafeInteger"` - - `"Number.MAX_SAFE_INTEGER"` - - `"Number.MIN_SAFE_INTEGER"` - - `"Number.parseFloat"` - - `"Number.parseInt"` - - `"Object.assign"` - - `"Object.getOwnPropertySymbols"` - - `"Object.is"` - - `"Object.setPrototypeOf"` - - `"Promise"` - - `"Proxy"` - - `"Reflect"` - - `"Set"` - - `"String.fromCodePoint"` - - `"String.raw"` - - `"subclassingBuiltins"` - - `"Symbol"` - - `"TypedArrays"` - - `"WeakMap"` - - `"WeakSet"` - -
- -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/es-builtins.md b/docs/rules/no-unsupported-features/es-builtins.md new file mode 100644 index 00000000..084519f1 --- /dev/null +++ b/docs/rules/no-unsupported-features/es-builtins.md @@ -0,0 +1,137 @@ +# Disallow unsupported ECMAScript features on the specified version (no-unsupported-features/es-builtins) + +ECMAScript standard is updating every two months. +You can check [node.green](https://node.green/) to know which Node.js version supports each ECMAScript feature. + +This rule reports unsupported ECMAScript built-in variables on the configured Node.js version as lint errors. +Editor integrations of ESLint would be useful to know it in real-time. + +## Rule Details + +### Supported ECMAScript features + +This rule supports ECMAScript 2018 and the features which are arrived at Stage 4 by May 2018. +See also [TC39 finished proposals](https://github.com/tc39/proposals/blob/master/finished-proposals.md). + +### Configured Node.js version range + +This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. + +I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. +For example of `package.json`: + +```json +{ + "name": "your-module", + "version": "1.0.0", + "engines": { + "node": ">=6.0.0" + } +} +``` + +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)). + +### Options + +```json +{ + "node/no-unsupported-features/es-builtins": ["error", { + "version": ">=6.0.0", + "ignores": [] + }] +} +``` + +#### version + +As mentioned above, this rule reads the [engines] field of `package.json`. +But, you can overwrite the version by `version` option. + +The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). + +#### ignores + +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. + +
+ +**ES2017:** + +- `"Atomics"` +- `"Object.values"` +- `"Object.entries"` +- `"Object.getOwnPropertyDescriptors"` +- `"SharedArrayBuffer"` + +**ES2015:** + +- `"Array.from"` +- `"Array.of"` +- `"Map"` +- `"Math.acosh"` +- `"Math.asinh"` +- `"Math.atanh"` +- `"Math.cbrt"` +- `"Math.clz32"` +- `"Math.cosh"` +- `"Math.expm1"` +- `"Math.fround"` +- `"Math.hypot"` +- `"Math.imul"` +- `"Math.log10"` +- `"Math.log1p"` +- `"Math.log2"` +- `"Math.sign"` +- `"Math.sinh"` +- `"Math.tanh"` +- `"Math.trunc"` +- `"Number.EPSILON"` +- `"Number.isFinite"` +- `"Number.isInteger"` +- `"Number.isNaN"` +- `"Number.isSafeInteger"` +- `"Number.MAX_SAFE_INTEGER"` +- `"Number.MIN_SAFE_INTEGER"` +- `"Number.parseFloat"` +- `"Number.parseInt"` +- `"Object.assign"` +- `"Object.getOwnPropertySymbols"` +- `"Object.is"` +- `"Object.setPrototypeOf"` +- `"Promise"` +- `"Proxy"` +- `"Reflect"` +- `"Set"` +- `"String.fromCodePoint"` +- `"String.raw"` +- `"Symbol"` +- `"Int8Array"` +- `"Uint8Array"` +- `"Uint8ClampedArray"` +- `"Int16Array"` +- `"Uint16Array"` +- `"Int32Array"` +- `"Uint32Array"` +- `"Float32Array"` +- `"Float64Array"` +- `"DataView"` +- `"WeakMap"` +- `"WeakSet"` + +
+ +### Known limitations + +This rule cannot find non-static things. +For example: + +- New properties and methods of instances. +- New parameters of functions. +- New `options` properties of function parameters. +- New events. + +[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/es-syntax.md b/docs/rules/no-unsupported-features/es-syntax.md new file mode 100644 index 00000000..74c680d6 --- /dev/null +++ b/docs/rules/no-unsupported-features/es-syntax.md @@ -0,0 +1,114 @@ +# Disallow unsupported ECMAScript syntax on the specified version (no-unsupported-features/es-syntax) + +ECMAScript standard is updating every two months. +You can check [node.green](https://node.green/) to know which Node.js version supports each ECMAScript feature. + +This rule reports unsupported ECMAScript syntax on the configured Node.js version as lint errors. +Editor integrations of ESLint would be useful to know it in real-time. + +## Rule Details + +### Supported ECMAScript features + +This rule supports ECMAScript 2018 and the syntax which are arrived at Stage 4 by May 2018. +See also [TC39 finished proposals](https://github.com/tc39/proposals/blob/master/finished-proposals.md). + +Please configure your `.eslintrc` file to succeed to succeed in parsing the syntax. +For example, set `2019` to `parserOptions.ecmaVersion`. + +### Configured Node.js version range + +This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. + +I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. +For example of `package.json`: + +```json +{ + "name": "your-module", + "version": "1.0.0", + "engines": { + "node": ">=6.0.0" + } +} +``` + +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)). + +### Options + +```json +{ + "node/no-unsupported-features/es-syntax": ["error", { + "version": ">=6.0.0", + "ignores": [] + }] +} +``` + +#### version + +As mentioned above, this rule reads the [engines] field of `package.json`. +But, you can overwrite the version by `version` option. + +The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). + +#### ignores + +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. + +
+ +**ES2019:** + +(nothing) + +**ES2018:** + +- `"asyncIteration"` +- `"malformedTemplateLiterals"` +- `"regexpLookbehind"` +- `"regexpNamedCaptureGroups"` +- `"regexpS"` +- `"regexpUnicodeProperties"` +- `"restSpreadProperties"` + +**ES2017:** + +- `"asyncFunctions"` +- `"trailingCommasInFunctions"` + +**ES2016:** + +- `"exponentialOperators"` + +**ES2015:** + +- `"arrowFunctions"` +- `"binaryNumericLiterals"` +- `"blockScopedFunctions"` +- `"blockScopedVariables"` +- `"classes"` +- `"computedProperties"` +- `"defaultParameters"` +- `"destructuring"` +- `"forOfLoops"` +- `"generators"` +- `"modules"` +- `"new.target"` +- `"objectSuperProperties"` +- `"octalNumericLiterals"` +- `"propertyShorthands"` +- `"regexpU"` +- `"regexpY"` +- `"restParameters"` +- `"spreadElements"` +- `"templateLiterals"` +- `"unicodeCodePointEscapes"` + +
+ +[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/fs.md b/docs/rules/no-unsupported-features/fs.md deleted file mode 100644 index d97188f8..00000000 --- a/docs/rules/no-unsupported-features/fs.md +++ /dev/null @@ -1,70 +0,0 @@ -# Disallow unsupported `fs` APIs on the specified version (no-unsupported-features/fs) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `fs` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `fs` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/fs.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/fs": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"fs.copyFile"` -- `"fs.copyFileSync"` -- `"fs.mkdtemp"` -- `"fs.mkdtempSync"` -- `"fs.realpath.native"` -- `"fs.realpathSync.native"` -- `"fs.promises"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/http2.md b/docs/rules/no-unsupported-features/http2.md deleted file mode 100644 index e5e71b71..00000000 --- a/docs/rules/no-unsupported-features/http2.md +++ /dev/null @@ -1,64 +0,0 @@ -# Disallow unsupported `http2` APIs on the specified version (no-unsupported-features/http2) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `http2` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `http2` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/http2.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/http2": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"http2"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/inspector.md b/docs/rules/no-unsupported-features/inspector.md deleted file mode 100644 index 7a67fcbd..00000000 --- a/docs/rules/no-unsupported-features/inspector.md +++ /dev/null @@ -1,64 +0,0 @@ -# Disallow unsupported `inspector` APIs on the specified version (no-unsupported-features/inspector) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `inspector` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `inspector` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/inspector.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/inspector": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"inspector"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/module.md b/docs/rules/no-unsupported-features/module.md deleted file mode 100644 index 4fa1b230..00000000 --- a/docs/rules/no-unsupported-features/module.md +++ /dev/null @@ -1,65 +0,0 @@ -# Disallow unsupported `module` APIs on the specified version (no-unsupported-features/module) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `module` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `module` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/module.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/module": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"require.resolve.paths"` -- `"module.builtinModules"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/node-builtins.md b/docs/rules/no-unsupported-features/node-builtins.md new file mode 100644 index 00000000..05cd1f65 --- /dev/null +++ b/docs/rules/no-unsupported-features/node-builtins.md @@ -0,0 +1,279 @@ +# Disallow unsupported Node.js built-in APIs on the specified version (no-unsupported-features/node-builtins) + +Node.js community is improving built-in APIs continuously. +You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. + +This rule reports unsupported Node.js built-in APIs on the configured Node.js version as lint errors. +Editor integrations of ESLint would be useful to know it in real-time. + +## Rule Details + +This rule reports APIs of Node.js built-in APIs on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/). + +### Configured Node.js version range + +This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. + +I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. +For example of `package.json`: + +```json +{ + "name": "your-module", + "version": "1.0.0", + "engines": { + "node": ">=6.0.0" + } +} +``` + +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)). + +### Options + +```json +{ + "node/no-unsupported-features/node-builtins": ["error", { + "version": ">=6.0.0", + "ignores": [] + }] +} +``` + +#### version + +As mentioned above, this rule reads the [engines] field of `package.json`. +But, you can overwrite the version by `version` option. + +The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). + +#### ignores + +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"` +- `"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.timeStamp"` +- `"console.timeline"` +- `"console.timelineEnd"` +- `"process.argv0"` +- `"process.channel"` +- `"process.cpuUsage"` +- `"process.emitWarning"` +- `"process.getegid"` +- `"process.geteuid"` +- `"process.hasUncaughtExceptionCaptureCallback"` +- `"process.ppid"` +- `"process.release"` +- `"process.setegid"` +- `"process.seteuid"` +- `"process.setUncaughtExceptionCaptureCallback"` +- `"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.timeStamp"` +- `"console.timeline"` +- `"console.timelineEnd"` + +**`crypto` module:** + +- `"crypto.Certificate.exportChallenge"` +- `"crypto.Certificate.exportPublicKey"` +- `"crypto.Certificate.verifySpkac"` +- `"crypto.constants"` +- `"crypto.fips"` +- `"crypto.getCurves"` +- `"crypto.getFips"` +- `"crypto.privateEncrypt"` +- `"crypto.publicDecrypt"` +- `"crypto.randomFillSync"` +- `"crypto.randomFill"` +- `"crypto.scrypt"` +- `"crypto.scryptSync"` +- `"crypto.setFips"` +- `"crypto.timingSafeEqual"` + +**`dns` module:** + +- `"dns.Resolver"` +- `"dns.resolvePtr"` +- `"dns.promises"` + +**`fs` module:** + +- `"fs.copyFile"` +- `"fs.copyFileSync"` +- `"fs.mkdtemp"` +- `"fs.mkdtempSync"` +- `"fs.realpath.native"` +- `"fs.realpathSync.native"` +- `"fs.promises"` + +**`http2` module:** + +- `"http2"` + +**`inspector` module:** + +- `"inspector"` + +**`module` module:** + +- `"module.builtinModules"` + +**`os` module:** + +- `"os.constants"` +- `"os.homedir"` +- `"os.userInfo"` + +**`path` module:** + +- `"path.toNamespacedPath"` + +**`perf_hooks` module:** + +- `"perf_hooks"` + +**`process` module:** + +- `"process.argv0"` +- `"process.channel"` +- `"process.cpuUsage"` +- `"process.emitWarning"` +- `"process.getegid"` +- `"process.geteuid"` +- `"process.hasUncaughtExceptionCaptureCallback"` +- `"process.ppid"` +- `"process.release"` +- `"process.setegid"` +- `"process.seteuid"` +- `"process.setUncaughtExceptionCaptureCallback"` + +**`stream` module:** + +- `"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.isDeepStrictEqual"` +- `"util.promisify"` +- `"util.TextDecoder"` +- `"util.TextEncoder"` +- `"util.types"` + +**`v8` module:** + +- `"v8"` +- `"v8.cachedDataVersionTag"` +- `"v8.getHeapSpaceStatistics"` +- `"v8.serialize"` +- `"v8.deserialize"` +- `"v8.Serializer"` +- `"v8.Deserializer"` +- `"v8.DefaultSerializer"` +- `"v8.DefaultDeserializer"` + +**`vm` module:** + +- `"vm.Module"` + +**`worker_threads` module:** + +- `"worker_threads"` + +
+ +### Known limitations + +This rule cannot find non-static things. +For example: + +- New properties and methods of instances. +- New parameters of functions. +- New `options` properties of function parameters. +- New events. + +[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/os.md b/docs/rules/no-unsupported-features/os.md deleted file mode 100644 index 356d52d9..00000000 --- a/docs/rules/no-unsupported-features/os.md +++ /dev/null @@ -1,66 +0,0 @@ -# Disallow unsupported `os` APIs on the specified version (no-unsupported-features/os) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `os` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `os` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/os.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/os": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"os.constants"` -- `"os.homedir"` -- `"os.userInfo"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/path.md b/docs/rules/no-unsupported-features/path.md deleted file mode 100644 index 22652462..00000000 --- a/docs/rules/no-unsupported-features/path.md +++ /dev/null @@ -1,64 +0,0 @@ -# Disallow unsupported `path` APIs on the specified version (no-unsupported-features/path) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `path` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `path` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/path.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/path": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"path.toNamespacedPath"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/perf_hooks.md b/docs/rules/no-unsupported-features/perf_hooks.md deleted file mode 100644 index 1256e1ef..00000000 --- a/docs/rules/no-unsupported-features/perf_hooks.md +++ /dev/null @@ -1,64 +0,0 @@ -# Disallow unsupported `perf_hooks` APIs on the specified version (no-unsupported-features/perf_hooks) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `perf_hooks` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `perf_hooks` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/perf_hooks.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/perf_hooks": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"perf_hooks"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/process.md b/docs/rules/no-unsupported-features/process.md deleted file mode 100644 index 51f00a2a..00000000 --- a/docs/rules/no-unsupported-features/process.md +++ /dev/null @@ -1,75 +0,0 @@ -# Disallow unsupported `process` APIs on the specified version (no-unsupported-features/process) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `process` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `process` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/process.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/process": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"process.argv0"` -- `"process.channel"` -- `"process.cpuUsage"` -- `"process.emitWarning"` -- `"process.getegid"` -- `"process.geteuid"` -- `"process.hasUncaughtExceptionCaptureCallback"` -- `"process.ppid"` -- `"process.release"` -- `"process.setegid"` -- `"process.seteuid"` -- `"process.setUncaughtExceptionCaptureCallback"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/stream.md b/docs/rules/no-unsupported-features/stream.md deleted file mode 100644 index 117f8117..00000000 --- a/docs/rules/no-unsupported-features/stream.md +++ /dev/null @@ -1,65 +0,0 @@ -# Disallow unsupported `stream` APIs on the specified version (no-unsupported-features/stream) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `stream` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `stream` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/stream.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/stream": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"stream.finished"` -- `"stream.pipeline"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/trace_events.md b/docs/rules/no-unsupported-features/trace_events.md deleted file mode 100644 index 7c128ec8..00000000 --- a/docs/rules/no-unsupported-features/trace_events.md +++ /dev/null @@ -1,64 +0,0 @@ -# Disallow unsupported `trace_events` APIs on the specified version (no-unsupported-features/trace_events) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `trace_events` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `trace_events` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/trace_events.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/trace_events": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"trace_events"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/url.md b/docs/rules/no-unsupported-features/url.md deleted file mode 100644 index 7584d102..00000000 --- a/docs/rules/no-unsupported-features/url.md +++ /dev/null @@ -1,74 +0,0 @@ -# Disallow unsupported `url` APIs on the specified version (no-unsupported-features/url) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `url` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `url` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/url.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/url": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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): - -- `"URL"` -- `"URLSearchParams"` - -(`url` module): - -- `"url.URL"` -- `"url.URLSearchParams"` -- `"url.domainToASCII"` -- `"url.domainToUnicode"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/util.md b/docs/rules/no-unsupported-features/util.md deleted file mode 100644 index 769554f4..00000000 --- a/docs/rules/no-unsupported-features/util.md +++ /dev/null @@ -1,73 +0,0 @@ -# Disallow unsupported `util` APIs on the specified version (no-unsupported-features/util) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `util` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `util` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/util.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/util": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"util.callbackify"` -- `"util.formatWithOptions"` -- `"util.getSystemErrorName"` -- `"util.inspect.custom"` -- `"util.inspect.defaultOptions"` -- `"util.isDeepStrictEqual"` -- `"util.promisify"` -- `"util.TextDecoder"` -- `"util.TextEncoder"` -- `"util.types"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/v8.md b/docs/rules/no-unsupported-features/v8.md deleted file mode 100644 index 1293138a..00000000 --- a/docs/rules/no-unsupported-features/v8.md +++ /dev/null @@ -1,72 +0,0 @@ -# Disallow unsupported `v8` APIs on the specified version (no-unsupported-features/v8) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `v8` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `v8` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/v8.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/v8": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"v8"` -- `"v8.cachedDataVersionTag"` -- `"v8.getHeapSpaceStatistics"` -- `"v8.serialize"` -- `"v8.deserialize"` -- `"v8.Serializer"` -- `"v8.Deserializer"` -- `"v8.DefaultSerializer"` -- `"v8.DefaultDeserializer"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/vm.md b/docs/rules/no-unsupported-features/vm.md deleted file mode 100644 index ec497115..00000000 --- a/docs/rules/no-unsupported-features/vm.md +++ /dev/null @@ -1,64 +0,0 @@ -# Disallow unsupported `vm` APIs on the specified version (no-unsupported-features/vm) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `vm` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `vm` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/vm.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/vm": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"vm.Module"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/docs/rules/no-unsupported-features/worker_threads.md b/docs/rules/no-unsupported-features/worker_threads.md deleted file mode 100644 index d574a21a..00000000 --- a/docs/rules/no-unsupported-features/worker_threads.md +++ /dev/null @@ -1,64 +0,0 @@ -# Disallow unsupported `worker_threads` APIs on the specified version (no-unsupported-features/worker_threads) - -Node.js community is improving built-in modules continuously. -You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API. - -This rule reports unsupported `worker_threads` module's APIs on the configured Node.js version as lint errors. -Editor integrations of ESLint would be useful to know it in real-time. - -## Rule Details - -This rule reports APIs of the `worker_threads` module on the basis of [Node.js v10.6.0 Documentation](https://nodejs.org/docs/v10.6.0/api/worker_threads.html). - -### Configured Node.js version range - -This rule reads the [engines] field of `package.json` to detect which Node.js versions your module is supporting. - -I recommend the use of the [engines] field because it's the official way that indicates which Node.js versions your module is supporting. -For example of `package.json`: - -```json -{ - "name": "your-module", - "version": "1.0.0", - "engines": { - "node": ">=6.0.0" - } -} -``` - -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)). - -### Options - -```json -{ - "node/no-unsupported-features/worker_threads": ["error", { - "version": ">=6.0.0", - "ignores": [] - }] -} -``` - -#### version - -As mentioned above, this rule reads the [engines] field of `package.json`. -But, you can overwrite the version by `version` option. - -The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar). - -#### ignores - -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. - -- `"worker_threads"` - -### Known limitations - -This rule cannot find non-static things. -E.g., the use of instance methods. - -[engines]: https://docs.npmjs.com/files/package.json#engines diff --git a/lib/index.js b/lib/index.js index a104f8de..c4843b7b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,29 +15,9 @@ module.exports = { "no-unpublished-bin": require("./rules/no-unpublished-bin"), "no-unpublished-import": require("./rules/no-unpublished-import"), "no-unpublished-require": require("./rules/no-unpublished-require"), - "no-unsupported-features/assert": require("./rules/no-unsupported-features/assert"), - "no-unsupported-features/async_hooks": require("./rules/no-unsupported-features/async_hooks"), - "no-unsupported-features/buffer": require("./rules/no-unsupported-features/buffer"), - "no-unsupported-features/child_process": require("./rules/no-unsupported-features/child_process"), - "no-unsupported-features/console": require("./rules/no-unsupported-features/console"), - "no-unsupported-features/crypto": require("./rules/no-unsupported-features/crypto"), - "no-unsupported-features/dns": require("./rules/no-unsupported-features/dns"), - "no-unsupported-features/ecma": require("./rules/no-unsupported-features/ecma"), - "no-unsupported-features/fs": require("./rules/no-unsupported-features/fs"), - "no-unsupported-features/http2": require("./rules/no-unsupported-features/http2"), - "no-unsupported-features/inspector": require("./rules/no-unsupported-features/inspector"), - "no-unsupported-features/module": require("./rules/no-unsupported-features/module"), - "no-unsupported-features/os": require("./rules/no-unsupported-features/os"), - "no-unsupported-features/path": require("./rules/no-unsupported-features/path"), - "no-unsupported-features/perf_hooks": require("./rules/no-unsupported-features/perf_hooks"), - "no-unsupported-features/process": require("./rules/no-unsupported-features/process"), - "no-unsupported-features/stream": require("./rules/no-unsupported-features/stream"), - "no-unsupported-features/trace_events": require("./rules/no-unsupported-features/trace_events"), - "no-unsupported-features/url": require("./rules/no-unsupported-features/url"), - "no-unsupported-features/util": require("./rules/no-unsupported-features/util"), - "no-unsupported-features/v8": require("./rules/no-unsupported-features/v8"), - "no-unsupported-features/vm": require("./rules/no-unsupported-features/vm"), - "no-unsupported-features/worker_threads": require("./rules/no-unsupported-features/worker_threads"), + "no-unsupported-features/es-builtins": require("./rules/no-unsupported-features/es-builtins"), + "no-unsupported-features/es-syntax": require("./rules/no-unsupported-features/es-syntax"), + "no-unsupported-features/node-builtins": require("./rules/no-unsupported-features/node-builtins"), "process-exit-as-throw": require("./rules/process-exit-as-throw"), shebang: require("./rules/shebang"), diff --git a/lib/rules/no-unsupported-features/assert.js b/lib/rules/no-unsupported-features/assert.js deleted file mode 100644 index 3b3cc2a8..00000000 --- a/lib/rules/no-unsupported-features/assert.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - assert: { - strict: { - [READ]: { supported: "9.9.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" } }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `assert` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/assert.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/async_hooks.js b/lib/rules/no-unsupported-features/async_hooks.js deleted file mode 100644 index ad6a2c7e..00000000 --- a/lib/rules/no-unsupported-features/async_hooks.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - //eslint-disable-next-line camelcase - async_hooks: { - [READ]: { supported: "8.0.0" }, - createHook: { [READ]: { supported: "8.1.0" } }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `async_hooks` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/async_hooks.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/buffer.js b/lib/rules/no-unsupported-features/buffer.js deleted file mode 100644 index 8b7c47a3..00000000 --- a/lib/rules/no-unsupported-features/buffer.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - 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" } }, - }, - }, - get globals() { - return { Buffer: this.modules.buffer.Buffer } - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `buffer` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/buffer.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: [ - ...enumeratePropertyNames(trackMap.modules), - ...enumeratePropertyNames(trackMap.globals), - ], - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/child_process.js b/lib/rules/no-unsupported-features/child_process.js deleted file mode 100644 index 927fa113..00000000 --- a/lib/rules/no-unsupported-features/child_process.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - //eslint-disable-next-line camelcase - child_process: { - ChildProcess: { [READ]: { supported: "2.2.0" } }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `child_process` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/child_process.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/console.js b/lib/rules/no-unsupported-features/console.js deleted file mode 100644 index 89102cca..00000000 --- a/lib/rules/no-unsupported-features/console.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - console: { - clear: { [READ]: { supported: "8.3.0" } }, - count: { [READ]: { supported: "8.3.0" } }, - countReset: { [READ]: { supported: "8.3.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" } }, - timeStamp: { [READ]: { supported: "8.0.0" } }, - timeline: { [READ]: { supported: "8.0.0" } }, - timelineEnd: { [READ]: { supported: "8.0.0" } }, - }, - }, - get globals() { - return this.modules - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `console` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/console.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/crypto.js b/lib/rules/no-unsupported-features/crypto.js deleted file mode 100644 index 4a1d2543..00000000 --- a/lib/rules/no-unsupported-features/crypto.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - crypto: { - Certificate: { - exportChallenge: { [READ]: { supported: "9.0.0" } }, - exportPublicKey: { [READ]: { supported: "9.0.0" } }, - verifySpkac: { [READ]: { supported: "9.0.0" } }, - }, - constants: { [READ]: { supported: "6.3.0" } }, - fips: { [READ]: { supported: "6.0.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" } }, - randomFill: { [READ]: { supported: "7.10.0" } }, - scrypt: { [READ]: { supported: "10.5.0" } }, - scryptSync: { [READ]: { supported: "10.5.0" } }, - setFips: { [READ]: { supported: "10.0.0" } }, - timingSafeEqual: { [READ]: { supported: "6.6.0" } }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `crypto` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/crypto.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/dns.js b/lib/rules/no-unsupported-features/dns.js deleted file mode 100644 index 3e4fff84..00000000 --- a/lib/rules/no-unsupported-features/dns.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - dns: { - Resolver: { [READ]: { supported: "8.3.0" } }, - resolvePtr: { [READ]: { supported: "6.0.0" } }, - promises: { - [READ]: { supported: "10.6.0" }, - }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `dns` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/dns.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/ecma.js b/lib/rules/no-unsupported-features/ecma.js deleted file mode 100644 index 63976d53..00000000 --- a/lib/rules/no-unsupported-features/ecma.js +++ /dev/null @@ -1,1229 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { rules: esRules } = require("eslint-plugin-es") -const { getInnermostScope } = require("eslint-utils") -const semver = require("semver") -const getEnginesNode = require("../../util/get-engines-node") - -const GET_OR_SET = /^(?:g|s)et$/ -const FEATURES = [ - //-------------------------------------------------------------------------- - // ES2015 - //-------------------------------------------------------------------------- - { - ruleId: "no-arrow-functions", - keywords: ["arrowFunctions", "syntax"], - cases: [ - { - supported: "4.0.0", - messageId: "no-arrow-functions", - }, - ], - }, - { - ruleId: "no-binary-numeric-literals", - keywords: ["binaryNumericLiterals", "syntax"], - cases: [ - { - supported: "4.0.0", - messageId: "no-binary-numeric-literals", - }, - ], - }, - { - ruleId: "no-block-scoped-functions", - keywords: ["blockScopedFunctions", "syntax"], - cases: [ - { - supported: "6.0.0", - test: ({ isStrict }) => !isStrict, - messageId: "no-block-scoped-functions-sloppy", - }, - { - supported: "4.0.0", - messageId: "no-block-scoped-functions-strict", - }, - ], - }, - { - ruleId: "no-block-scoped-variables", - keywords: ["blockScopedVariables", "syntax"], - cases: [ - { - supported: "6.0.0", - test: ({ isStrict }) => !isStrict, - messageId: "no-block-scoped-variables-sloppy", - }, - { - supported: "4.0.0", - messageId: "no-block-scoped-variables-strict", - }, - ], - }, - { - ruleId: "no-classes", - keywords: ["classes", "syntax"], - cases: [ - { - supported: "6.0.0", - test: ({ isStrict }) => !isStrict, - messageId: "no-classes-sloppy", - }, - { - supported: "4.0.0", - messageId: "no-classes-strict", - }, - ], - }, - { - ruleId: "no-computed-properties", - keywords: ["computedProperties", "syntax"], - cases: [ - { - supported: "4.0.0", - messageId: "no-computed-properties", - }, - ], - }, - { - ruleId: "no-default-parameters", - keywords: ["defaultParameters", "syntax"], - cases: [ - { - supported: "6.0.0", - messageId: "no-default-parameters", - }, - ], - }, - { - ruleId: "no-destructuring", - keywords: ["destructuring", "syntax"], - cases: [ - { - supported: "6.0.0", - messageId: "no-destructuring", - }, - ], - }, - { - ruleId: "no-for-of-loops", - keywords: ["forOfLoops", "syntax"], - cases: [ - { - supported: "0.12.0", - messageId: "no-for-of-loops", - }, - ], - }, - { - ruleId: "no-generators", - keywords: ["generators", "syntax"], - cases: [ - { - supported: "4.0.0", - messageId: "no-generators", - }, - ], - }, - { - ruleId: "no-modules", - keywords: ["modules", "syntax"], - cases: [ - { - supported: null, - messageId: "no-modules", - }, - ], - }, - { - ruleId: "no-new-target", - keywords: ["new.target", "syntax"], - cases: [ - { - supported: "5.0.0", - messageId: "no-new-target", - }, - ], - }, - { - ruleId: "no-object-super-properties", - keywords: ["objectSuperProperties", "syntax"], - cases: [ - { - supported: "4.0.0", - messageId: "no-object-super-properties", - }, - ], - }, - { - ruleId: "no-octal-numeric-literals", - keywords: ["octalNumericLiterals", "syntax"], - cases: [ - { - supported: "4.0.0", - messageId: "no-octal-numeric-literals", - }, - ], - }, - { - ruleId: "no-property-shorthands", - keywords: ["propertyShorthands", "syntax"], - cases: [ - { - supported: "6.0.0", - test: ({ node }) => - node.shorthand && GET_OR_SET.test(node.key.name), - messageId: "no-property-shorthands-getset", - }, - { - supported: "4.0.0", - messageId: "no-property-shorthands", - }, - ], - }, - { - ruleId: "no-regexp-u-flag", - keywords: ["regexpU", "syntax"], - cases: [ - { - supported: "6.0.0", - messageId: "no-regexp-u-flag", - }, - ], - }, - { - ruleId: "no-regexp-y-flag", - keywords: ["regexpY", "syntax"], - cases: [ - { - supported: "6.0.0", - messageId: "no-regexp-y-flag", - }, - ], - }, - { - ruleId: "no-rest-parameters", - keywords: ["restParameters", "syntax"], - cases: [ - { - supported: "6.0.0", - messageId: "no-rest-parameters", - }, - ], - }, - { - ruleId: "no-spread-elements", - keywords: ["spreadElements", "syntax"], - cases: [ - { - supported: "5.0.0", - messageId: "no-spread-elements", - }, - ], - }, - { - ruleId: "no-template-literals", - keywords: ["templateLiterals", "syntax"], - cases: [ - { - supported: "4.0.0", - messageId: "no-template-literals", - }, - ], - }, - { - ruleId: "no-unicode-codepoint-escapes", - keywords: ["unicodeCodePointEscapes", "syntax"], - cases: [ - { - supported: "4.0.0", - messageId: "no-unicode-codepoint-escapes", - }, - ], - }, - { - ruleId: "no-array-from", - keywords: ["Array.from", "Array.*", "runtime"], - cases: [ - { - supported: "4.0.0", - messageId: "no-array-from", - }, - ], - }, - { - ruleId: "no-array-of", - keywords: ["Array.of", "Array.*", "runtime"], - cases: [ - { - supported: "4.0.0", - messageId: "no-array-of", - }, - ], - }, - { - ruleId: "no-map", - keywords: ["Map", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-map", - }, - ], - }, - { - ruleId: "no-math-acosh", - keywords: ["Math.acosh", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-acosh", - }, - ], - }, - { - ruleId: "no-math-asinh", - keywords: ["Math.asinh", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-asinh", - }, - ], - }, - { - ruleId: "no-math-atanh", - keywords: ["Math.atanh", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-atanh", - }, - ], - }, - { - ruleId: "no-math-cbrt", - keywords: ["Math.cbrt", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-cbrt", - }, - ], - }, - { - ruleId: "no-math-clz32", - keywords: ["Math.clz32", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-clz32", - }, - ], - }, - { - ruleId: "no-math-cosh", - keywords: ["Math.cosh", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-cosh", - }, - ], - }, - { - ruleId: "no-math-expm1", - keywords: ["Math.expm1", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-expm1", - }, - ], - }, - { - ruleId: "no-math-fround", - keywords: ["Math.fround", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-fround", - }, - ], - }, - { - ruleId: "no-math-hypot", - keywords: ["Math.hypot", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-hypot", - }, - ], - }, - { - ruleId: "no-math-imul", - keywords: ["Math.imul", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-imul", - }, - ], - }, - { - ruleId: "no-math-log10", - keywords: ["Math.log10", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-log10", - }, - ], - }, - { - ruleId: "no-math-log1p", - keywords: ["Math.log1p", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-log1p", - }, - ], - }, - { - ruleId: "no-math-log2", - keywords: ["Math.log2", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-log2", - }, - ], - }, - { - ruleId: "no-math-sign", - keywords: ["Math.sign", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-sign", - }, - ], - }, - { - ruleId: "no-math-sinh", - keywords: ["Math.sinh", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-sinh", - }, - ], - }, - { - ruleId: "no-math-tanh", - keywords: ["Math.tanh", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-tanh", - }, - ], - }, - { - ruleId: "no-math-trunc", - keywords: ["Math.trunc", "Math.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-math-trunc", - }, - ], - }, - { - ruleId: "no-number-epsilon", - keywords: ["Number.EPSILON", "Number.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-number-epsilon", - }, - ], - }, - { - ruleId: "no-number-isfinite", - keywords: ["Number.isFinite", "Number.*", "runtime"], - cases: [ - { - supported: "0.10.0", - messageId: "no-number-isfinite", - }, - ], - }, - { - ruleId: "no-number-isinteger", - keywords: ["Number.isInteger", "Number.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-number-isinteger", - }, - ], - }, - { - ruleId: "no-number-isnan", - keywords: ["Number.isNaN", "Number.*", "runtime"], - cases: [ - { - supported: "0.10.0", - messageId: "no-number-isnan", - }, - ], - }, - { - ruleId: "no-number-issafeinteger", - keywords: ["Number.isSafeInteger", "Number.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-number-issafeinteger", - }, - ], - }, - { - ruleId: "no-number-maxsafeinteger", - keywords: ["Number.MAX_SAFE_INTEGER", "Number.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-number-maxsafeinteger", - }, - ], - }, - { - ruleId: "no-number-minsafeinteger", - keywords: ["Number.MIN_SAFE_INTEGER", "Number.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-number-minsafeinteger", - }, - ], - }, - { - ruleId: "no-number-parsefloat", - keywords: ["Number.parseFloat", "Number.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-number-parsefloat", - }, - ], - }, - { - ruleId: "no-number-parseint", - keywords: ["Number.parseInt", "Number.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-number-parseint", - }, - ], - }, - { - ruleId: "no-object-assign", - keywords: ["Object.assign", "Object.*", "runtime"], - cases: [ - { - supported: "4.0.0", - messageId: "no-object-assign", - }, - ], - }, - { - ruleId: "no-object-getownpropertysymbols", - keywords: ["Object.getOwnPropertySymbols", "Object.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-object-getownpropertysymbols", - }, - ], - }, - { - ruleId: "no-object-is", - keywords: ["Object.is", "Object.*", "runtime"], - cases: [ - { - supported: "0.10.0", - messageId: "no-object-is", - }, - ], - }, - { - ruleId: "no-object-setprototypeof", - keywords: ["Object.setPrototypeOf", "Object.*", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-object-setprototypeof", - }, - ], - }, - { - ruleId: "no-promise", - keywords: ["Promise", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-promise", - }, - ], - }, - { - ruleId: "no-proxy", - keywords: ["Proxy", "runtime"], - cases: [ - { - supported: "6.0.0", - messageId: "no-proxy", - }, - ], - }, - { - ruleId: "no-reflect", - keywords: ["Reflect", "runtime"], - cases: [ - { - supported: "6.0.0", - messageId: "no-reflect", - }, - ], - }, - { - ruleId: "no-set", - keywords: ["Set", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-set", - }, - ], - }, - { - ruleId: "no-string-fromcodepoint", - keywords: ["String.fromCodePoint", "String.*", "runtime"], - cases: [ - { - supported: "4.0.0", - messageId: "no-string-fromcodepoint", - }, - ], - }, - { - ruleId: "no-string-raw", - keywords: ["String.raw", "String.*", "runtime"], - cases: [ - { - supported: "4.0.0", - messageId: "no-string-raw", - }, - ], - }, - { - ruleId: "no-subclassing-builtins", - keywords: ["subclassingBuiltins", "runtime"], - cases: [ - { - supported: "6.5.0", - test: ({ node }) => node.name === "Array", - messageId: "no-subclassing-builtins-array", - }, - { - supported: "6.0.0", - test: ({ node }) => - node.name === "Function" || node.name === "String", - messageId: "no-subclassing-builtins-function-string", - }, - { - supported: "4.0.0", - messageId: "no-subclassing-builtins", - }, - ], - }, - { - ruleId: "no-symbol", - keywords: ["Symbol", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-symbol", - }, - ], - }, - { - ruleId: "no-typed-arrays", - keywords: ["TypedArrays", "runtime"], - cases: [ - { - supported: "0.10.0", - messageId: "no-typed-arrays", - }, - ], - }, - { - ruleId: "no-weak-map", - keywords: ["WeakMap", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-weak-map", - }, - ], - }, - { - ruleId: "no-weak-set", - keywords: ["WeakSet", "runtime"], - cases: [ - { - supported: "0.12.0", - messageId: "no-weak-set", - }, - ], - }, - - //-------------------------------------------------------------------------- - // ES2016 - //-------------------------------------------------------------------------- - { - ruleId: "no-exponential-operators", - keywords: ["exponentialOperators", "syntax"], - cases: [ - { - supported: "7.0.0", - messageId: "no-exponential-operators", - }, - ], - }, - - //-------------------------------------------------------------------------- - // ES2017 - //-------------------------------------------------------------------------- - { - ruleId: "no-async-functions", - keywords: ["asyncFunctions", "syntax"], - cases: [ - { - supported: "7.6.0", - messageId: "no-async-functions", - }, - ], - }, - { - ruleId: "no-trailing-function-commas", - keywords: ["trailingCommasInFunctions", "syntax"], - cases: [ - { - supported: "8.0.0", - messageId: "no-trailing-function-commas", - }, - ], - }, - { - ruleId: "no-atomics", - keywords: ["Atomics", "runtime"], - cases: [ - { - supported: "8.10.0", - messageId: "no-atomics", - }, - ], - }, - { - ruleId: "no-object-values", - keywords: ["Object.values", "Object.*", "runtime"], - cases: [ - { - supported: "7.0.0", - messageId: "no-object-values", - }, - ], - }, - { - ruleId: "no-object-entries", - keywords: ["Object.entries", "Object.*", "runtime"], - cases: [ - { - supported: "7.0.0", - messageId: "no-object-entries", - }, - ], - }, - { - ruleId: "no-object-getownpropertydescriptors", - keywords: ["Object.getOwnPropertyDescriptors", "Object.*", "runtime"], - cases: [ - { - supported: "7.0.0", - messageId: "no-object-getownpropertydescriptors", - }, - ], - }, - { - ruleId: "no-shared-array-buffer", - keywords: ["SharedArrayBuffer", "runtime"], - cases: [ - { - supported: "8.10.0", - messageId: "no-shared-array-buffer", - }, - ], - }, - - //-------------------------------------------------------------------------- - // ES2018 - //-------------------------------------------------------------------------- - { - ruleId: "no-async-iteration", - keywords: ["asyncIteration", "syntax"], - cases: [ - { - supported: "10.0.0", - messageId: "no-async-iteration", - }, - ], - }, - { - ruleId: "no-malformed-template-literals", - keywords: ["malformedTemplateLiterals", "syntax"], - cases: [ - { - supported: "8.10.0", - messageId: "no-malformed-template-literals", - }, - ], - }, - { - ruleId: "no-regexp-lookbehind-assertions", - keywords: ["regexpLookbehind", "syntax"], - cases: [ - { - supported: "8.10.0", - messageId: "no-regexp-lookbehind-assertions", - }, - ], - }, - { - ruleId: "no-regexp-named-capture-groups", - keywords: ["regexpNamedCaptureGroups", "syntax"], - cases: [ - { - supported: "10.0.0", - messageId: "no-regexp-named-capture-groups", - }, - ], - }, - { - ruleId: "no-regexp-s-flag", - keywords: ["regexpS", "syntax"], - cases: [ - { - supported: "8.10.0", - messageId: "no-regexp-s-flag", - }, - ], - }, - { - ruleId: "no-regexp-unicode-property-escapes", - keywords: ["regexpUnicodeProperties", "syntax"], - cases: [ - { - supported: "10.0.0", - messageId: "no-regexp-unicode-property-escapes", - }, - ], - }, - { - ruleId: "no-rest-spread-properties", - keywords: ["restSpreadProperties", "syntax"], - cases: [ - { - supported: "8.3.0", - messageId: "no-rest-spread-properties", - }, - ], - }, -] - -/** - * Parses the options. - * @param {object|undefined} options - An option object to parse. - * @param {string} defaultVersion - The default version to use if the version option was omitted. - * @returns {{version:string,ignores:Set}} Parsed value. - */ -function parseOptions(options, defaultVersion) { - const version = - semver.validRange(options && options.version) || defaultVersion - const ignores = new Set((options && options.ignores) || []) - - return Object.freeze({ version, ignores }) -} - -/** - * Define the case selector with given information. - * @param {RuleContext} context The rule context to get scopes. - * @param {string} version The configured version range. - * @param {Node|null} node The node at the current location, for additional conditions. - * @returns {function(aCase:object):boolean} The case selector. - */ -function defineSelector(context, version, node) { - return aCase => - // Version. - (!aCase.supported || - semver.intersects(`<${aCase.supported}`, version)) && - // Additional conditions. - (!aCase.test || - aCase.test({ - node, - get isStrict() { - return Boolean( - node && nomalizeScope(context.getScope(), node).isStrict - ) - }, - })) -} - -/** - * Find the scope that a given node belongs to. - * @param {Scope} initialScope The initial scope to find. - * @param {Node} node The AST node. - * @returns {Scope} The scope that the node belongs to. - */ -function nomalizeScope(initialScope, node) { - let scope = getInnermostScope(initialScope, node) - - while (scope && scope.block === node) { - scope = scope.upper - } - - return scope -} - -/** - * Merge two visitors. - * @param {Visitor} x The visitor which is assigned. - * @param {Visitor} y The visitor which is assigning. - * @returns {Visitor} `x`. - */ -function merge(x, y) { - for (const key of Object.keys(y)) { - if (typeof x[key] === "function") { - if (x[key]._handlers == null) { - const fs = [x[key], y[key]] - x[key] = dispatch.bind(null, fs) - x[key]._handlers = fs - } else { - x[key]._handlers.push(y[key]) - } - } else { - x[key] = y[key] - } - } - return x -} - -/** - * Dispatch all given functions with a node. - * @param {function[]} handlers The function list to call. - * @param {Node} node The AST node to be handled. - * @returns {void} - */ -function dispatch(handlers, node) { - for (const h of handlers) { - h(node) - } -} - -/** - * Define the visitor object as merging the rules of eslint-plugin-es. - * @param {RuleContext} context The rule context. - * @param {{version:string,ignores:Set}} options The options. - * @returns {object} The defined visitor. - */ -function defineVisitor(context, options) { - return FEATURES.filter( - // Omit full-supported features and ignored features by options because - // this rule never reports those. - f => - !f.keywords.some(Set.prototype.has, options.ignores) && - f.cases.some( - c => - !c.supported || - semver.intersects(options.version, `<${c.supported}`) - ) - ).reduce((visitor, f) => { - const rule = esRules[f.ruleId] - const thisContext = { - __proto__: context, - - // Override `context.report()` then: - // - ignore if it's supported. - // - override reporting messages. - report(descriptor) { - // Set additional information. - if (descriptor.data) { - descriptor.data.version = options.version - } else { - descriptor.data = { version: options.version } - } - descriptor.fix = undefined - - // Test and report. - const hitCase = f.cases.find( - defineSelector(this, options.version, descriptor.node) - ) - if (hitCase) { - descriptor.messageId = hitCase.messageId - descriptor.data.supported = hitCase.supported - super.report(descriptor) - } - }, - } - return merge(visitor, rule.create(thisContext)) - }, {}) -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported ECMAScript features on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/ecma.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - new Set( - [].concat(...FEATURES.map(f => f.keywords)) - ) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - //-------------------------------------------------------------------------- - // ES2015 - //-------------------------------------------------------------------------- - "no-arrow-functions": - "Arrow functions are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-binary-numeric-literals": - "Binary numeric literals are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-block-scoped-functions-strict": - "Block-scoped functions in strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-block-scoped-functions-sloppy": - "Block-scoped functions in non-strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-block-scoped-variables-strict": - "Block-scoped variables in strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-block-scoped-variables-sloppy": - "Block-scoped variables in non-strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-classes-strict": - "Classes in strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-classes-sloppy": - "Classes in non-strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-computed-properties": - "Computed properties are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-default-parameters": - "Default parameters are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-destructuring": - "Destructuring is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-for-of-loops": - "'for-of' loops are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-generators": - "Generator functions are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-modules": - "Import and export declarations are not supported yet.", - "no-new-target": - "'new.target' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-object-super-properties": - "'super' in object literals is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-octal-numeric-literals": - "Octal numeric literals are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-property-shorthands": - "Property shorthands are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-property-shorthands-getset": - "Property shorthands of 'get' and 'set' are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-regexp-u-flag": - "RegExp 'u' flag is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-regexp-y-flag": - "RegExp 'y' flag is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-rest-parameters": - "Rest parameters are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-spread-elements": - "Spread elements are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-template-literals": - "Template literals are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-unicode-codepoint-escapes": - "Unicode code point escapes are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-array-from": - "The 'Array.from' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-array-of": - "The 'Array.of' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-map": - "The 'Map' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-acosh": - "The 'Math.acosh' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-asinh": - "The 'Math.asinh' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-atanh": - "The 'Math.atanh' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-cbrt": - "The 'Math.cbrt' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-clz32": - "The 'Math.clz32' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-cosh": - "The 'Math.cosh' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-expm1": - "The 'Math.expm1' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-fround": - "The 'Math.fround' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-hypot": - "The 'Math.hypot' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-imul": - "The 'Math.imul' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-log10": - "The 'Math.log10' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-log1p": - "The 'Math.log1p' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-log2": - "The 'Math.log2' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-sign": - "The 'Math.sign' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-sinh": - "The 'Math.sinh' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-tanh": - "The 'Math.tanh' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-math-trunc": - "The 'Math.trunc' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-number-epsilon": - "The 'Number.EPSILON' property is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-number-isfinite": - "The 'Number.isFinite' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-number-isinteger": - "The 'Number.isInteger' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-number-isnan": - "The 'Number.isNaN' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-number-issafeinteger": - "The 'Number.isSafeInteger' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-number-maxsafeinteger": - "The 'Number.MAX_SAFE_INTEGER' property is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-number-minsafeinteger": - "The 'Number.MIN_SAFE_INTEGER' property is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-number-parsefloat": - "The 'Number.parseFloat' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-number-parseint": - "The 'Number.parseInt' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-object-assign": - "The 'Object.assign' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-object-getownpropertysymbols": - "The 'Object.getOwnPropertySymbols' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-object-is": - "The 'Object.is' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-object-setprototypeof": - "The 'Object.setPrototypeOf' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-promise": - "The 'Promise' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-proxy": - "The 'Proxy' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-reflect": - "The 'Reflect' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-set": - "The 'Set' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-string-fromcodepoint": - "The 'String.fromCodePoint' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-string-raw": - "The 'String.raw' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-subclassing-builtins-array": - "Subclassing '{{name}}' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-subclassing-builtins-function-string": - "Subclassing '{{name}}' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-subclassing-builtins": - "Subclassing '{{name}}' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-symbol": - "The 'Symbol' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-typed-arrays": - "Typed array classes are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-weak-map": - "The 'WeakMap' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-weak-set": - "The 'WeakSet' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - - //-------------------------------------------------------------------------- - // ES2016 - //-------------------------------------------------------------------------- - "no-exponential-operators": - "Exponential operators are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - - //-------------------------------------------------------------------------- - // ES2017 - //-------------------------------------------------------------------------- - "no-async-functions": - "Async functions are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-trailing-function-commas": - "Trailing commas in function syntax are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-atomics": - "The 'Atomics' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-object-values": - "The 'Object.values' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-object-entries": - "The 'Object.entries' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-object-getownpropertydescriptors": - "The 'Object.getOwnPropertyDescriptors' method is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-shared-array-buffer": - "The 'SharedArrayBuffer' class is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - - //-------------------------------------------------------------------------- - // ES2018 - //-------------------------------------------------------------------------- - "no-async-iteration": - "Async iteration is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-malformed-template-literals": - "Malformed template literals are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-regexp-lookbehind-assertions": - "RegExp lookbehind assertions are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-regexp-named-capture-groups": - "RegExp named capture groups are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-regexp-s-flag": - "RegExp 's' flag is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-regexp-unicode-property-escapes": - "RegExp Unicode property escapes are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - "no-rest-spread-properties": - "Rest/spread properties are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - const defaultVersion = getEnginesNode(context.getFilename()) - const options = parseOptions(context.options[0], defaultVersion) - return defineVisitor(context, options) - }, -} diff --git a/lib/rules/no-unsupported-features/es-builtins.js b/lib/rules/no-unsupported-features/es-builtins.js new file mode 100644 index 00000000..d3f2d03b --- /dev/null +++ b/lib/rules/no-unsupported-features/es-builtins.js @@ -0,0 +1,162 @@ +/** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */ +"use strict" + +const { READ } = require("eslint-utils") +const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") +const enumeratePropertyNames = require("../../util/enumerate-property-names") + +const trackMap = { + globals: { + Array: { + from: { [READ]: { supported: "4.0.0" } }, + of: { [READ]: { supported: "4.0.0" } }, + }, + Map: { + [READ]: { supported: "0.12.0" }, + }, + Math: { + acosh: { [READ]: { supported: "0.12.0" } }, + asinh: { [READ]: { supported: "0.12.0" } }, + atanh: { [READ]: { supported: "0.12.0" } }, + cbrt: { [READ]: { supported: "0.12.0" } }, + clz32: { [READ]: { supported: "0.12.0" } }, + cosh: { [READ]: { supported: "0.12.0" } }, + expm1: { [READ]: { supported: "0.12.0" } }, + fround: { [READ]: { supported: "0.12.0" } }, + hypot: { [READ]: { supported: "0.12.0" } }, + imul: { [READ]: { supported: "0.12.0" } }, + log10: { [READ]: { supported: "0.12.0" } }, + log1p: { [READ]: { supported: "0.12.0" } }, + log2: { [READ]: { supported: "0.12.0" } }, + sign: { [READ]: { supported: "0.12.0" } }, + sinh: { [READ]: { supported: "0.12.0" } }, + tanh: { [READ]: { supported: "0.12.0" } }, + trunc: { [READ]: { supported: "0.12.0" } }, + }, + Number: { + EPSILON: { [READ]: { supported: "0.12.0" } }, + isFinite: { [READ]: { supported: "0.10.0" } }, + isInteger: { [READ]: { supported: "0.12.0" } }, + isNaN: { [READ]: { supported: "0.10.0" } }, + isSafeInteger: { [READ]: { supported: "0.12.0" } }, + MAX_SAFE_INTEGER: { [READ]: { supported: "0.12.0" } }, + MIN_SAFE_INTEGER: { [READ]: { supported: "0.12.0" } }, + parseFloat: { [READ]: { supported: "0.12.0" } }, + parseInt: { [READ]: { supported: "0.12.0" } }, + }, + Object: { + assign: { [READ]: { supported: "4.0.0" } }, + getOwnPropertySymbols: { [READ]: { supported: "0.12.0" } }, + is: { [READ]: { supported: "0.10.0" } }, + setPrototypeOf: { [READ]: { supported: "0.12.0" } }, + values: { [READ]: { supported: "7.0.0" } }, + entries: { [READ]: { supported: "7.0.0" } }, + getOwnPropertyDescriptors: { [READ]: { supported: "7.0.0" } }, + }, + Promise: { + [READ]: { supported: "0.12.0" }, + }, + Proxy: { + [READ]: { supported: "6.0.0" }, + }, + Reflect: { + [READ]: { supported: "6.0.0" }, + }, + Set: { + [READ]: { supported: "0.12.0" }, + }, + String: { + fromCodePoint: { [READ]: { supported: "4.0.0" } }, + raw: { [READ]: { supported: "4.0.0" } }, + }, + Symbol: { + [READ]: { supported: "0.12.0" }, + }, + Int8Array: { + [READ]: { supported: "0.10.0" }, + }, + Uint8Array: { + [READ]: { supported: "0.10.0" }, + }, + Uint8ClampedArray: { + [READ]: { supported: "0.10.0" }, + }, + Int16Array: { + [READ]: { supported: "0.10.0" }, + }, + Uint16Array: { + [READ]: { supported: "0.10.0" }, + }, + Int32Array: { + [READ]: { supported: "0.10.0" }, + }, + Uint32Array: { + [READ]: { supported: "0.10.0" }, + }, + Float32Array: { + [READ]: { supported: "0.10.0" }, + }, + Float64Array: { + [READ]: { supported: "0.10.0" }, + }, + DataView: { + [READ]: { supported: "0.10.0" }, + }, + WeakMap: { + [READ]: { supported: "0.12.0" }, + }, + WeakSet: { + [READ]: { supported: "0.12.0" }, + }, + Atomics: { + [READ]: { supported: "8.10.0" }, + }, + SharedArrayBuffer: { + [READ]: { supported: "8.10.0" }, + }, + }, +} + +module.exports = { + meta: { + docs: { + description: + "disallow unsupported ECMAScript built-ins on the specified version", + category: "Possible Errors", + recommended: true, + url: + "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/es-builtins.md", + }, + fixable: null, + schema: [ + { + type: "object", + properties: { + version: { + type: "string", + }, + ignores: { + type: "array", + items: { + enum: Array.from( + enumeratePropertyNames(trackMap.globals) + ), + }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + messages: { + unsupported: + "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + }, + }, + create(context) { + return defineUnsupportedModuleHandlers(context, trackMap) + }, +} diff --git a/lib/rules/no-unsupported-features/es-syntax.js b/lib/rules/no-unsupported-features/es-syntax.js new file mode 100644 index 00000000..415ca5e8 --- /dev/null +++ b/lib/rules/no-unsupported-features/es-syntax.js @@ -0,0 +1,605 @@ +/** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */ +"use strict" + +const { rules: esRules } = require("eslint-plugin-es") +const { getInnermostScope } = require("eslint-utils") +const semver = require("semver") +const getEnginesNode = require("../../util/get-engines-node") + +const getOrSet = /^(?:g|s)et$/ +const features = { + //-------------------------------------------------------------------------- + // ES2015 + //-------------------------------------------------------------------------- + arrowFunctions: { + ruleId: "no-arrow-functions", + cases: [ + { + supported: "4.0.0", + messageId: "no-arrow-functions", + }, + ], + }, + binaryNumericLiterals: { + ruleId: "no-binary-numeric-literals", + cases: [ + { + supported: "4.0.0", + messageId: "no-binary-numeric-literals", + }, + ], + }, + blockScopedFunctions: { + ruleId: "no-block-scoped-functions", + cases: [ + { + supported: "6.0.0", + test: info => !info.isStrict, + messageId: "no-block-scoped-functions-sloppy", + }, + { + supported: "4.0.0", + messageId: "no-block-scoped-functions-strict", + }, + ], + }, + blockScopedVariables: { + ruleId: "no-block-scoped-variables", + cases: [ + { + supported: "6.0.0", + test: info => !info.isStrict, + messageId: "no-block-scoped-variables-sloppy", + }, + { + supported: "4.0.0", + messageId: "no-block-scoped-variables-strict", + }, + ], + }, + classes: { + ruleId: "no-classes", + cases: [ + { + supported: "6.0.0", + test: info => !info.isStrict, + messageId: "no-classes-sloppy", + }, + { + supported: "4.0.0", + messageId: "no-classes-strict", + }, + ], + }, + computedProperties: { + ruleId: "no-computed-properties", + cases: [ + { + supported: "4.0.0", + messageId: "no-computed-properties", + }, + ], + }, + defaultParameters: { + ruleId: "no-default-parameters", + cases: [ + { + supported: "6.0.0", + messageId: "no-default-parameters", + }, + ], + }, + destructuring: { + ruleId: "no-destructuring", + cases: [ + { + supported: "6.0.0", + messageId: "no-destructuring", + }, + ], + }, + forOfLoops: { + ruleId: "no-for-of-loops", + cases: [ + { + supported: "0.12.0", + messageId: "no-for-of-loops", + }, + ], + }, + generators: { + ruleId: "no-generators", + cases: [ + { + supported: "4.0.0", + messageId: "no-generators", + }, + ], + }, + modules: { + ruleId: "no-modules", + cases: [ + { + supported: null, + messageId: "no-modules", + }, + ], + }, + "new.target": { + ruleId: "no-new-target", + cases: [ + { + supported: "5.0.0", + messageId: "no-new-target", + }, + ], + }, + objectSuperProperties: { + ruleId: "no-object-super-properties", + cases: [ + { + supported: "4.0.0", + messageId: "no-object-super-properties", + }, + ], + }, + octalNumericLiterals: { + ruleId: "no-octal-numeric-literals", + cases: [ + { + supported: "4.0.0", + messageId: "no-octal-numeric-literals", + }, + ], + }, + propertyShorthands: { + ruleId: "no-property-shorthands", + cases: [ + { + supported: "6.0.0", + test: info => + info.node.shorthand && getOrSet.test(info.node.key.name), + messageId: "no-property-shorthands-getset", + }, + { + supported: "4.0.0", + messageId: "no-property-shorthands", + }, + ], + }, + regexpU: { + ruleId: "no-regexp-u-flag", + cases: [ + { + supported: "6.0.0", + messageId: "no-regexp-u-flag", + }, + ], + }, + regexpY: { + ruleId: "no-regexp-y-flag", + cases: [ + { + supported: "6.0.0", + messageId: "no-regexp-y-flag", + }, + ], + }, + restParameters: { + ruleId: "no-rest-parameters", + cases: [ + { + supported: "6.0.0", + messageId: "no-rest-parameters", + }, + ], + }, + spreadElements: { + ruleId: "no-spread-elements", + cases: [ + { + supported: "5.0.0", + messageId: "no-spread-elements", + }, + ], + }, + templateLiterals: { + ruleId: "no-template-literals", + cases: [ + { + supported: "4.0.0", + messageId: "no-template-literals", + }, + ], + }, + unicodeCodePointEscapes: { + ruleId: "no-unicode-codepoint-escapes", + cases: [ + { + supported: "4.0.0", + messageId: "no-unicode-codepoint-escapes", + }, + ], + }, + + //-------------------------------------------------------------------------- + // ES2016 + //-------------------------------------------------------------------------- + exponentialOperators: { + ruleId: "no-exponential-operators", + cases: [ + { + supported: "7.0.0", + messageId: "no-exponential-operators", + }, + ], + }, + + //-------------------------------------------------------------------------- + // ES2017 + //-------------------------------------------------------------------------- + asyncFunctions: { + ruleId: "no-async-functions", + cases: [ + { + supported: "7.6.0", + messageId: "no-async-functions", + }, + ], + }, + trailingCommasInFunctions: { + ruleId: "no-trailing-function-commas", + cases: [ + { + supported: "8.0.0", + messageId: "no-trailing-function-commas", + }, + ], + }, + + //-------------------------------------------------------------------------- + // ES2018 + //-------------------------------------------------------------------------- + asyncIteration: { + ruleId: "no-async-iteration", + cases: [ + { + supported: "10.0.0", + messageId: "no-async-iteration", + }, + ], + }, + malformedTemplateLiterals: { + ruleId: "no-malformed-template-literals", + cases: [ + { + supported: "8.10.0", + messageId: "no-malformed-template-literals", + }, + ], + }, + regexpLookbehind: { + ruleId: "no-regexp-lookbehind-assertions", + cases: [ + { + supported: "8.10.0", + messageId: "no-regexp-lookbehind-assertions", + }, + ], + }, + regexpNamedCaptureGroups: { + ruleId: "no-regexp-named-capture-groups", + cases: [ + { + supported: "10.0.0", + messageId: "no-regexp-named-capture-groups", + }, + ], + }, + regexpS: { + ruleId: "no-regexp-s-flag", + cases: [ + { + supported: "8.10.0", + messageId: "no-regexp-s-flag", + }, + ], + }, + regexpUnicodeProperties: { + ruleId: "no-regexp-unicode-property-escapes", + cases: [ + { + supported: "10.0.0", + messageId: "no-regexp-unicode-property-escapes", + }, + ], + }, + restSpreadProperties: { + ruleId: "no-rest-spread-properties", + cases: [ + { + supported: "8.3.0", + messageId: "no-rest-spread-properties", + }, + ], + }, +} +const keywords = Object.keys(features) + +/** + * Parses the options. + * @param {object|undefined} options - An option object to parse. + * @param {string} defaultVersion - The default version to use if the version option was omitted. + * @returns {{version:string,ignores:Set}} Parsed value. + */ +function parseOptions(options, defaultVersion) { + const version = + semver.validRange(options && options.version) || defaultVersion + const ignores = new Set((options && options.ignores) || []) + + return Object.freeze({ version, ignores }) +} + +/** + * Define the case selector with given information. + * @param {RuleContext} context The rule context to get scopes. + * @param {string} version The configured version range. + * @param {Node|null} node The node at the current location, for additional conditions. + * @returns {function(aCase:object):boolean} The case selector. + */ +function defineSelector(context, version, node) { + return aCase => + // Version. + (!aCase.supported || + semver.intersects(`<${aCase.supported}`, version)) && + // Additional conditions. + (!aCase.test || + aCase.test({ + node, + get isStrict() { + return Boolean( + node && nomalizeScope(context.getScope(), node).isStrict + ) + }, + })) +} + +/** + * Find the scope that a given node belongs to. + * @param {Scope} initialScope The initial scope to find. + * @param {Node} node The AST node. + * @returns {Scope} The scope that the node belongs to. + */ +function nomalizeScope(initialScope, node) { + let scope = getInnermostScope(initialScope, node) + + while (scope && scope.block === node) { + scope = scope.upper + } + + return scope +} + +/** + * Merge two visitors. + * @param {Visitor} x The visitor which is assigned. + * @param {Visitor} y The visitor which is assigning. + * @returns {Visitor} `x`. + */ +function merge(x, y) { + for (const key of Object.keys(y)) { + if (typeof x[key] === "function") { + if (x[key]._handlers == null) { + const fs = [x[key], y[key]] + x[key] = dispatch.bind(null, fs) + x[key]._handlers = fs + } else { + x[key]._handlers.push(y[key]) + } + } else { + x[key] = y[key] + } + } + return x +} + +/** + * Dispatch all given functions with a node. + * @param {function[]} handlers The function list to call. + * @param {Node} node The AST node to be handled. + * @returns {void} + */ +function dispatch(handlers, node) { + for (const h of handlers) { + h(node) + } +} + +/** + * Define the visitor object as merging the rules of eslint-plugin-es. + * @param {RuleContext} context The rule context. + * @param {{version:string,ignores:Set}} options The options. + * @returns {object} The defined visitor. + */ +function defineVisitor(context, options) { + return ( + keywords + // Omit full-supported features and ignored features by options + // because this rule never reports those. + .filter( + keyword => + !options.ignores.has(keyword) && + features[keyword].cases.some( + c => + !c.supported || + semver.intersects( + options.version, + `<${c.supported}` + ) + ) + ) + // Merge remaining features with overriding `context.report()`. + .reduce((visitor, keyword) => { + const { ruleId, cases } = features[keyword] + const rule = esRules[ruleId] + const thisContext = { + __proto__: context, + + // Override `context.report()` then: + // - ignore if it's supported. + // - override reporting messages. + report(descriptor) { + // Set additional information. + if (descriptor.data) { + descriptor.data.version = options.version + } else { + descriptor.data = { version: options.version } + } + descriptor.fix = undefined + + // Test and report. + const hitCase = cases.find( + defineSelector( + this, + options.version, + descriptor.node + ) + ) + if (hitCase) { + descriptor.messageId = hitCase.messageId + descriptor.data.supported = hitCase.supported + super.report(descriptor) + } + }, + } + return merge(visitor, rule.create(thisContext)) + }, {}) + ) +} + +module.exports = { + meta: { + docs: { + description: + "disallow unsupported ECMAScript syntax on the specified version", + category: "Possible Errors", + recommended: true, + url: + "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/es-syntax.md", + }, + fixable: null, + schema: [ + { + type: "object", + properties: { + version: { + type: "string", + }, + ignores: { + type: "array", + items: { + enum: Object.keys(features), + }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + messages: { + //------------------------------------------------------------------ + // ES2015 + //------------------------------------------------------------------ + "no-arrow-functions": + "Arrow functions are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-binary-numeric-literals": + "Binary numeric literals are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-block-scoped-functions-strict": + "Block-scoped functions in strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-block-scoped-functions-sloppy": + "Block-scoped functions in non-strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-block-scoped-variables-strict": + "Block-scoped variables in strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-block-scoped-variables-sloppy": + "Block-scoped variables in non-strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-classes-strict": + "Classes in strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-classes-sloppy": + "Classes in non-strict mode are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-computed-properties": + "Computed properties are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-default-parameters": + "Default parameters are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-destructuring": + "Destructuring is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-for-of-loops": + "'for-of' loops are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-generators": + "Generator functions are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-modules": + "Import and export declarations are not supported yet.", + "no-new-target": + "'new.target' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-object-super-properties": + "'super' in object literals is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-octal-numeric-literals": + "Octal numeric literals are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-property-shorthands": + "Property shorthands are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-property-shorthands-getset": + "Property shorthands of 'get' and 'set' are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-regexp-u-flag": + "RegExp 'u' flag is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-regexp-y-flag": + "RegExp 'y' flag is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-rest-parameters": + "Rest parameters are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-spread-elements": + "Spread elements are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-template-literals": + "Template literals are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-unicode-codepoint-escapes": + "Unicode code point escapes are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + + //------------------------------------------------------------------ + // ES2016 + //------------------------------------------------------------------ + "no-exponential-operators": + "Exponential operators are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + + //------------------------------------------------------------------ + // ES2017 + //------------------------------------------------------------------ + "no-async-functions": + "Async functions are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-trailing-function-commas": + "Trailing commas in function syntax are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + + //------------------------------------------------------------------ + // ES2018 + //------------------------------------------------------------------ + "no-async-iteration": + "Async iteration is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-malformed-template-literals": + "Malformed template literals are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-regexp-lookbehind-assertions": + "RegExp lookbehind assertions are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-regexp-named-capture-groups": + "RegExp named capture groups are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-regexp-s-flag": + "RegExp 's' flag is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-regexp-unicode-property-escapes": + "RegExp Unicode property escapes are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + "no-rest-spread-properties": + "Rest/spread properties are not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + }, + }, + create(context) { + const defaultVersion = getEnginesNode(context.getFilename()) + const options = parseOptions(context.options[0], defaultVersion) + return defineVisitor(context, options) + }, +} diff --git a/lib/rules/no-unsupported-features/fs.js b/lib/rules/no-unsupported-features/fs.js deleted file mode 100644 index ae55714c..00000000 --- a/lib/rules/no-unsupported-features/fs.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - fs: { - 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: "10.1.0" }, - }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `fs` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/fs.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/http2.js b/lib/rules/no-unsupported-features/http2.js deleted file mode 100644 index 9f88d819..00000000 --- a/lib/rules/no-unsupported-features/http2.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - http2: { - [READ]: { supported: "8.4.0" }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `http2` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/http2.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/inspector.js b/lib/rules/no-unsupported-features/inspector.js deleted file mode 100644 index 3e50cb28..00000000 --- a/lib/rules/no-unsupported-features/inspector.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - inspector: { - [READ]: { supported: "8.0.0" }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `inspector` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/inspector.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/module.js b/lib/rules/no-unsupported-features/module.js deleted file mode 100644 index 1a0c595a..00000000 --- a/lib/rules/no-unsupported-features/module.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - module: { - builtinModules: { [READ]: { supported: "9.3.0" } }, - }, - }, - globals: { - require: { - resolve: { - paths: { [READ]: { supported: "8.9.0" } }, - }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `module` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/module.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: [ - ...enumeratePropertyNames(trackMap.modules), - ...enumeratePropertyNames(trackMap.globals), - ], - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/node-builtins.js b/lib/rules/no-unsupported-features/node-builtins.js new file mode 100644 index 00000000..5e3fe54f --- /dev/null +++ b/lib/rules/no-unsupported-features/node-builtins.js @@ -0,0 +1,249 @@ +/** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */ +"use strict" + +const { READ } = require("eslint-utils") +const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") +const enumeratePropertyNames = require("../../util/enumerate-property-names") + +/*eslint-disable camelcase */ +const trackMap = { + globals: { + require: { + resolve: { + paths: { [READ]: { supported: "8.9.0" } }, + }, + }, + }, + modules: { + assert: { + strict: { + [READ]: { supported: "9.9.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" } }, + count: { [READ]: { supported: "8.3.0" } }, + countReset: { [READ]: { supported: "8.3.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" } }, + 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" } }, + }, + constants: { [READ]: { supported: "6.3.0" } }, + fips: { [READ]: { supported: "6.0.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" } }, + randomFill: { [READ]: { supported: "7.10.0" } }, + scrypt: { [READ]: { supported: "10.5.0" } }, + scryptSync: { [READ]: { supported: "10.5.0" } }, + setFips: { [READ]: { supported: "10.0.0" } }, + timingSafeEqual: { [READ]: { supported: "6.6.0" } }, + }, + dns: { + Resolver: { [READ]: { supported: "8.3.0" } }, + resolvePtr: { [READ]: { supported: "6.0.0" } }, + promises: { + [READ]: { supported: "10.6.0" }, + }, + }, + fs: { + 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: "10.1.0" }, + }, + }, + http2: { + [READ]: { supported: "8.4.0" }, + }, + inspector: { + [READ]: { supported: "8.0.0" }, + }, + module: { + builtinModules: { [READ]: { supported: "9.3.0" } }, + }, + os: { + constants: { [READ]: { supported: "6.3.0" } }, + homedir: { [READ]: { supported: "2.3.0" } }, + userInfo: { [READ]: { supported: "6.0.0" } }, + }, + path: { + toNamespacedPath: { [READ]: { supported: "9.0.0" } }, + }, + perf_hooks: { + [READ]: { supported: "8.5.0" }, + }, + process: { + argv0: { [READ]: { supported: "6.4.0" } }, + channel: { [READ]: { supported: "7.1.0" } }, + cpuUsage: { [READ]: { supported: "6.1.0" } }, + emitWarning: { [READ]: { supported: "8.0.0" } }, + getegid: { [READ]: { supported: "2.0.0" } }, + geteuid: { [READ]: { supported: "2.0.0" } }, + hasUncaughtExceptionCaptureCallback: { + [READ]: { supported: "9.3.0" }, + }, + ppid: { [READ]: { supported: "9.2.0" } }, + release: { [READ]: { supported: "3.0.0" } }, + setegid: { [READ]: { supported: "2.0.0" } }, + seteuid: { [READ]: { supported: "2.0.0" } }, + setUncaughtExceptionCaptureCallback: { + [READ]: { supported: "9.3.0" }, + }, + }, + stream: { + 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" } }, + URLSearchParams: { [READ]: { supported: "7.5.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" } }, + inspect: { + custom: { [READ]: { supported: "6.6.0" } }, + defaultOptions: { [READ]: { supported: "6.4.0" } }, + }, + isDeepStrictEqual: { [READ]: { supported: "9.0.0" } }, + promisify: { [READ]: { supported: "8.0.0" } }, + TextDecoder: { [READ]: { supported: "8.3.0" } }, + TextEncoder: { [READ]: { supported: "8.3.0" } }, + types: { + [READ]: { supported: "10.0.0" }, + }, + }, + v8: { + [READ]: { supported: "1.0.0" }, + cachedDataVersionTag: { [READ]: { supported: "8.0.0" } }, + getHeapSpaceStatistics: { [READ]: { supported: "6.0.0" } }, + serialize: { [READ]: { supported: "8.0.0" } }, + deserialize: { [READ]: { supported: "8.0.0" } }, + Serializer: { [READ]: { supported: "8.0.0" } }, + Deserializer: { [READ]: { supported: "8.0.0" } }, + DefaultSerializer: { [READ]: { supported: "8.0.0" } }, + DefaultDeserializer: { [READ]: { supported: "8.0.0" } }, + }, + vm: { + Module: { [READ]: { supported: "9.6.0" } }, + }, + worker_threads: { + [READ]: { supported: "10.5.0" }, + }, + }, +} +Object.assign(trackMap.globals, { + Buffer: trackMap.modules.buffer.Buffer, + URL: Object.assign({}, trackMap.modules.url.URL, { + [READ]: { supported: "10.0.0" }, + }), + URLSearchParams: Object.assign({}, 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/v6.0.1/docs/rules/no-unsupported-features/node-builtins.md", + }, + fixable: null, + 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, + }, + ], + messages: { + unsupported: + "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", + }, + }, + create(context) { + return defineUnsupportedModuleHandlers(context, trackMap) + }, +} diff --git a/lib/rules/no-unsupported-features/os.js b/lib/rules/no-unsupported-features/os.js deleted file mode 100644 index 42a7ee95..00000000 --- a/lib/rules/no-unsupported-features/os.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - os: { - constants: { [READ]: { supported: "6.3.0" } }, - homedir: { [READ]: { supported: "2.3.0" } }, - userInfo: { [READ]: { supported: "6.0.0" } }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `os` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/os.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/path.js b/lib/rules/no-unsupported-features/path.js deleted file mode 100644 index a7ab6a84..00000000 --- a/lib/rules/no-unsupported-features/path.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - path: { - toNamespacedPath: { [READ]: { supported: "9.0.0" } }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `path` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/path.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/perf_hooks.js b/lib/rules/no-unsupported-features/perf_hooks.js deleted file mode 100644 index d9d26d41..00000000 --- a/lib/rules/no-unsupported-features/perf_hooks.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - //eslint-disable-next-line camelcase - perf_hooks: { - [READ]: { supported: "8.5.0" }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `perf_hooks` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/perf_hooks.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/process.js b/lib/rules/no-unsupported-features/process.js deleted file mode 100644 index 5da01f7b..00000000 --- a/lib/rules/no-unsupported-features/process.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - process: { - argv0: { [READ]: { supported: "6.4.0" } }, - channel: { [READ]: { supported: "7.1.0" } }, - cpuUsage: { [READ]: { supported: "6.1.0" } }, - emitWarning: { [READ]: { supported: "8.0.0" } }, - getegid: { [READ]: { supported: "2.0.0" } }, - geteuid: { [READ]: { supported: "2.0.0" } }, - hasUncaughtExceptionCaptureCallback: { - [READ]: { supported: "9.3.0" }, - }, - ppid: { [READ]: { supported: "9.2.0" } }, - release: { [READ]: { supported: "3.0.0" } }, - setegid: { [READ]: { supported: "2.0.0" } }, - seteuid: { [READ]: { supported: "2.0.0" } }, - setUncaughtExceptionCaptureCallback: { - [READ]: { supported: "9.3.0" }, - }, - }, - }, - get globals() { - return this.modules - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `process` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/process.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/stream.js b/lib/rules/no-unsupported-features/stream.js deleted file mode 100644 index 6288a187..00000000 --- a/lib/rules/no-unsupported-features/stream.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - stream: { - finished: { [READ]: { supported: "10.0.0" } }, - pipeline: { [READ]: { supported: "10.0.0" } }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `stream` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/stream.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/trace_events.js b/lib/rules/no-unsupported-features/trace_events.js deleted file mode 100644 index 136ecc70..00000000 --- a/lib/rules/no-unsupported-features/trace_events.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - //eslint-disable-next-line camelcase - trace_events: { - [READ]: { supported: "10.0.0" }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `trace_events` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/trace_events.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/url.js b/lib/rules/no-unsupported-features/url.js deleted file mode 100644 index 27e1fa43..00000000 --- a/lib/rules/no-unsupported-features/url.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - url: { - URL: { [READ]: { supported: "7.0.0" } }, - URLSearchParams: { [READ]: { supported: "7.5.0" } }, - domainToASCII: { [READ]: { supported: "7.4.0" } }, - domainToUnicode: { [READ]: { supported: "7.4.0" } }, - }, - }, - globals: { - URL: { [READ]: { supported: "10.0.0" } }, - URLSearchParams: { [READ]: { supported: "10.0.0" } }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `url` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/url.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: [ - ...enumeratePropertyNames(trackMap.globals), - ...enumeratePropertyNames(trackMap.modules), - ], - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/util.js b/lib/rules/no-unsupported-features/util.js deleted file mode 100644 index 80fe527d..00000000 --- a/lib/rules/no-unsupported-features/util.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - util: { - callbackify: { [READ]: { supported: "8.2.0" } }, - formatWithOptions: { [READ]: { supported: "10.0.0" } }, - getSystemErrorName: { [READ]: { supported: "9.7.0" } }, - inspect: { - custom: { [READ]: { supported: "6.6.0" } }, - defaultOptions: { [READ]: { supported: "6.4.0" } }, - }, - isDeepStrictEqual: { [READ]: { supported: "9.0.0" } }, - promisify: { [READ]: { supported: "8.0.0" } }, - TextDecoder: { [READ]: { supported: "8.3.0" } }, - TextEncoder: { [READ]: { supported: "8.3.0" } }, - types: { - [READ]: { supported: "10.0.0" }, - }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `util` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/util.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/v8.js b/lib/rules/no-unsupported-features/v8.js deleted file mode 100644 index 8d44ded4..00000000 --- a/lib/rules/no-unsupported-features/v8.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - v8: { - [READ]: { supported: "1.0.0" }, - cachedDataVersionTag: { [READ]: { supported: "8.0.0" } }, - getHeapSpaceStatistics: { [READ]: { supported: "6.0.0" } }, - serialize: { [READ]: { supported: "8.0.0" } }, - deserialize: { [READ]: { supported: "8.0.0" } }, - Serializer: { [READ]: { supported: "8.0.0" } }, - Deserializer: { [READ]: { supported: "8.0.0" } }, - DefaultSerializer: { [READ]: { supported: "8.0.0" } }, - DefaultDeserializer: { [READ]: { supported: "8.0.0" } }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `v8` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/v8.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/vm.js b/lib/rules/no-unsupported-features/vm.js deleted file mode 100644 index 211e8f31..00000000 --- a/lib/rules/no-unsupported-features/vm.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - vm: { - Module: { [READ]: { supported: "9.6.0" } }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `vm` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/vm.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/lib/rules/no-unsupported-features/worker_threads.js b/lib/rules/no-unsupported-features/worker_threads.js deleted file mode 100644 index 868177db..00000000 --- a/lib/rules/no-unsupported-features/worker_threads.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const { READ } = require("eslint-utils") -const defineUnsupportedModuleHandlers = require("../../util/define-unsupported-module-handlers") -const enumeratePropertyNames = require("../../util/enumerate-property-names") - -const trackMap = { - modules: { - //eslint-disable-next-line camelcase - worker_threads: { - [READ]: { supported: "10.5.0" }, - }, - }, -} - -module.exports = { - meta: { - docs: { - description: - "disallow unsupported `worker_threads` APIs on the specified version", - category: "Possible Errors", - recommended: true, - url: - "https://github.com/mysticatea/eslint-plugin-node/blob/v6.0.1/docs/rules/no-unsupported-features/worker_threads.md", - }, - fixable: null, - schema: [ - { - type: "object", - properties: { - version: { - type: "string", - }, - ignores: { - type: "array", - items: { - enum: Array.from( - enumeratePropertyNames(trackMap.modules) - ), - }, - uniqueItems: true, - }, - }, - additionalProperties: false, - }, - ], - messages: { - unsupported: - "The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.", - }, - }, - create(context) { - return defineUnsupportedModuleHandlers(context, trackMap) - }, -} diff --git a/tests/lib/rules/no-unsupported-features/assert.js b/tests/lib/rules/no-unsupported-features/assert.js deleted file mode 100644 index cbef1560..00000000 --- a/tests/lib/rules/no-unsupported-features/assert.js +++ /dev/null @@ -1,326 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/assert") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/assert", rule, { - valid: [ - { - code: "require('assert').strictEqual()", - options: [{ version: "0.12.0" }], - }, - { - code: - "var assert = require('assert'); assert(); assert.strictEqual()", - options: [{ version: "0.12.0" }], - }, - { - code: "require('assert').deepStrictEqual()", - options: [{ version: "4.0.0" }], - }, - { - code: "var assert = require('assert'); assert.deepStrictEqual()", - options: [{ version: "4.0.0" }], - }, - { - code: - "var { deepStrictEqual } = require('assert'); deepStrictEqual()", - options: [{ version: "4.0.0" }], - }, - { - code: "import assert from 'assert'; assert.deepStrictEqual()", - options: [{ version: "4.0.0" }], - }, - { - code: "import { deepStrictEqual } from 'assert'; deepStrictEqual()", - options: [{ version: "4.0.0" }], - }, - { - code: "require('assert').notDeepStrictEqual()", - options: [{ version: "4.0.0" }], - }, - { - code: "require('assert').rejects()", - options: [{ version: "10.0.0" }], - }, - { - code: "require('assert').doesNotReject()", - options: [{ version: "10.0.0" }], - }, - { - code: "require('assert').strict.rejects()", - options: [{ version: "10.0.0" }], - }, - { - code: "require('assert').strict.doesNotReject()", - options: [{ version: "10.0.0" }], - }, - { - code: "var assert = require('assert').strict", - options: [{ version: "9.9.0" }], - }, - { - code: "var {strict: assert} = require('assert'); assert.rejects()", - options: [{ version: "10.0.0" }], - }, - { - code: "require('assert').deepStrictEqual()", - options: [ - { version: "3.9.9", ignores: ["assert.deepStrictEqual"] }, - ], - }, - { - code: "var assert = require('assert'); assert.deepStrictEqual()", - options: [ - { version: "3.9.9", ignores: ["assert.deepStrictEqual"] }, - ], - }, - { - code: - "var { deepStrictEqual } = require('assert'); deepStrictEqual()", - options: [ - { version: "3.9.9", ignores: ["assert.deepStrictEqual"] }, - ], - }, - { - code: "import assert from 'assert'; assert.deepStrictEqual()", - options: [ - { version: "3.9.9", ignores: ["assert.deepStrictEqual"] }, - ], - }, - { - code: "import { deepStrictEqual } from 'assert'; deepStrictEqual()", - options: [ - { version: "3.9.9", ignores: ["assert.deepStrictEqual"] }, - ], - }, - { - code: "require('assert').notDeepStrictEqual()", - options: [ - { version: "3.9.9", ignores: ["assert.notDeepStrictEqual"] }, - ], - }, - { - code: "require('assert').rejects()", - options: [{ version: "9.9.9", ignores: ["assert.rejects"] }], - }, - { - code: "require('assert').doesNotReject()", - options: [{ version: "9.9.9", ignores: ["assert.doesNotReject"] }], - }, - { - code: "require('assert').strict.rejects()", - options: [{ version: "9.9.9", ignores: ["assert.strict.rejects"] }], - }, - { - code: "require('assert').strict.doesNotReject()", - options: [ - { version: "9.9.9", ignores: ["assert.strict.doesNotReject"] }, - ], - }, - { - code: "var assert = require('assert').strict", - options: [{ version: "9.8.9", ignores: ["assert.strict"] }], - }, - { - code: "var {strict: assert} = require('assert'); assert.rejects()", - options: [ - { - version: "9.8.9", - ignores: ["assert.strict", "assert.strict.rejects"], - }, - ], - }, - ], - invalid: [ - { - code: "require('assert').deepStrictEqual()", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.deepStrictEqual", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "var assert = require('assert'); assert.deepStrictEqual()", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.deepStrictEqual", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: - "var { deepStrictEqual } = require('assert'); deepStrictEqual()", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.deepStrictEqual", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "import assert from 'assert'; assert.deepStrictEqual()", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.deepStrictEqual", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "import { deepStrictEqual } from 'assert'; deepStrictEqual()", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.deepStrictEqual", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "require('assert').notDeepStrictEqual()", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.notDeepStrictEqual", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "require('assert').rejects()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.rejects", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "require('assert').doesNotReject()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.doesNotReject", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "require('assert').strict.rejects()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.strict.rejects", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "require('assert').strict.doesNotReject()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.strict.doesNotReject", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "var assert = require('assert').strict", - options: [{ version: "9.8.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.strict", - supported: "9.9.0", - version: "9.8.9", - }, - }, - ], - }, - { - code: "var {strict: assert} = require('assert'); assert.rejects()", - options: [{ version: "9.8.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "assert.strict", - supported: "9.9.0", - version: "9.8.9", - }, - }, - { - messageId: "unsupported", - data: { - name: "assert.strict.rejects", - supported: "10.0.0", - version: "9.8.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/async_hooks.js b/tests/lib/rules/no-unsupported-features/async_hooks.js deleted file mode 100644 index c10bf9d0..00000000 --- a/tests/lib/rules/no-unsupported-features/async_hooks.js +++ /dev/null @@ -1,222 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/async_hooks") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/async_hooks", rule, { - valid: [ - { - code: "require('async_hooks')", - options: [{ version: "8.0.0" }], - }, - { - code: "import hooks from 'async_hooks'", - options: [{ version: "8.0.0" }], - }, - { - code: "require('async_hooks').createHook()", - options: [{ version: "8.1.0" }], - }, - { - code: "var hooks = require('async_hooks'); hooks.createHook()", - options: [{ version: "8.1.0" }], - }, - { - code: "var { createHook } = require('async_hooks'); createHook()", - options: [{ version: "8.1.0" }], - }, - { - code: "import hooks from 'async_hooks'; hooks.createHook()", - options: [{ version: "8.1.0" }], - }, - { - code: "import { createHook } from 'async_hooks'; createHook()", - options: [{ version: "8.1.0" }], - }, - - // Ignores - { - code: "require('async_hooks')", - options: [{ version: "7.9.9", ignores: ["async_hooks"] }], - }, - { - code: "import hooks from 'async_hooks'", - options: [{ version: "7.9.9", ignores: ["async_hooks"] }], - }, - { - code: "import { createHook } from 'async_hooks'", - options: [ - { - version: "7.9.9", - ignores: ["async_hooks", "async_hooks.createHook"], - }, - ], - }, - { - code: "require('async_hooks').createHook()", - options: [ - { version: "8.0.9", ignores: ["async_hooks.createHook"] }, - ], - }, - { - code: "var hooks = require('async_hooks'); hooks.createHook()", - options: [ - { version: "8.0.9", ignores: ["async_hooks.createHook"] }, - ], - }, - { - code: "var { createHook } = require('async_hooks'); createHook()", - options: [ - { version: "8.0.9", ignores: ["async_hooks.createHook"] }, - ], - }, - { - code: - "import async_hooks from 'async_hooks'; async_hooks.createHook()", - options: [ - { version: "8.0.9", ignores: ["async_hooks.createHook"] }, - ], - }, - { - code: "import { createHook } from 'async_hooks'; createHook()", - options: [ - { version: "8.0.9", ignores: ["async_hooks.createHook"] }, - ], - }, - ], - invalid: [ - { - code: "require('async_hooks')", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "async_hooks", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "import hooks from 'async_hooks'", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "async_hooks", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "import { createHook } from 'async_hooks'", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "async_hooks", - supported: "8.0.0", - version: "7.9.9", - }, - }, - { - messageId: "unsupported", - data: { - name: "async_hooks.createHook", - supported: "8.1.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('async_hooks').createHook()", - options: [{ version: "8.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "async_hooks.createHook", - supported: "8.1.0", - version: "8.0.9", - }, - }, - ], - }, - { - code: "var hooks = require('async_hooks'); hooks.createHook()", - options: [{ version: "8.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "async_hooks.createHook", - supported: "8.1.0", - version: "8.0.9", - }, - }, - ], - }, - { - code: "var { createHook } = require('async_hooks'); createHook()", - options: [{ version: "8.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "async_hooks.createHook", - supported: "8.1.0", - version: "8.0.9", - }, - }, - ], - }, - { - code: - "import async_hooks from 'async_hooks'; async_hooks.createHook()", - options: [{ version: "8.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "async_hooks.createHook", - supported: "8.1.0", - version: "8.0.9", - }, - }, - ], - }, - { - code: "import { createHook } from 'async_hooks'; createHook()", - options: [{ version: "8.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "async_hooks.createHook", - supported: "8.1.0", - version: "8.0.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/buffer.js b/tests/lib/rules/no-unsupported-features/buffer.js deleted file mode 100644 index 0e5a7df1..00000000 --- a/tests/lib/rules/no-unsupported-features/buffer.js +++ /dev/null @@ -1,365 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/buffer") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - Buffer: false, - require: false, - }, -}).run("no-unsupported-features/buffer", rule, { - valid: [ - { - code: "Buffer.alloc", - options: [{ version: "4.5.0" }], - }, - { - code: "Buffer.allocUnsafe", - options: [{ version: "4.5.0" }], - }, - { - code: "Buffer.allocUnsafeSlow", - options: [{ version: "4.5.0" }], - }, - { - code: "Buffer.from", - options: [{ version: "4.5.0" }], - }, - { - code: "require('buffer').constants", - options: [{ version: "8.2.0" }], - }, - { - code: "var cp = require('buffer'); cp.constants", - options: [{ version: "8.2.0" }], - }, - { - code: "var { constants } = require('buffer');", - options: [{ version: "8.2.0" }], - }, - { - code: "import cp from 'buffer'; cp.constants", - options: [{ version: "8.2.0" }], - }, - { - code: "import { constants } from 'buffer'", - options: [{ version: "8.2.0" }], - }, - { - code: "var {Buffer: b} = require('buffer'); b.alloc", - options: [{ version: "4.5.0" }], - }, - { - code: "var {Buffer: b} = require('buffer'); b.allocUnsafe", - options: [{ version: "4.5.0" }], - }, - { - code: "var {Buffer: b} = require('buffer'); b.allocUnsafeSlow", - options: [{ version: "4.5.0" }], - }, - { - code: "var {Buffer: b} = require('buffer'); b.from", - options: [{ version: "4.5.0" }], - }, - { - code: "require('buffer').kMaxLength", - options: [{ version: "3.0.0" }], - }, - { - code: "require('buffer').transcode", - options: [{ version: "7.1.0" }], - }, - - // Ignores - { - code: "Buffer.alloc", - options: [{ version: "4.4.9", ignores: ["Buffer.alloc"] }], - }, - { - code: "Buffer.allocUnsafe", - options: [{ version: "4.4.9", ignores: ["Buffer.allocUnsafe"] }], - }, - { - code: "Buffer.allocUnsafeSlow", - options: [ - { version: "4.4.9", ignores: ["Buffer.allocUnsafeSlow"] }, - ], - }, - { - code: "Buffer.from", - options: [{ version: "4.4.9", ignores: ["Buffer.from"] }], - }, - { - code: "require('buffer').constants", - options: [{ version: "8.1.9", ignores: ["buffer.constants"] }], - }, - { - code: "var cp = require('buffer'); cp.constants", - options: [{ version: "8.1.9", ignores: ["buffer.constants"] }], - }, - { - code: "var { constants } = require('buffer');", - options: [{ version: "8.1.9", ignores: ["buffer.constants"] }], - }, - { - code: "import cp from 'buffer'; cp.constants", - options: [{ version: "8.1.9", ignores: ["buffer.constants"] }], - }, - { - code: "import { constants } from 'buffer'", - options: [{ version: "8.1.9", ignores: ["buffer.constants"] }], - }, - { - code: "var {Buffer: b} = require('buffer'); b.alloc", - options: [{ version: "4.4.9", ignores: ["buffer.Buffer.alloc"] }], - }, - { - code: "var {Buffer: b} = require('buffer'); b.allocUnsafe", - options: [ - { version: "4.4.9", ignores: ["buffer.Buffer.allocUnsafe"] }, - ], - }, - { - code: "var {Buffer: b} = require('buffer'); b.allocUnsafeSlow", - options: [ - { - version: "4.4.9", - ignores: ["buffer.Buffer.allocUnsafeSlow"], - }, - ], - }, - { - code: "var {Buffer: b} = require('buffer'); b.from", - options: [{ version: "4.4.9", ignores: ["buffer.Buffer.from"] }], - }, - { - code: "require('buffer').kMaxLength", - options: [{ version: "2.9.9", ignores: ["buffer.kMaxLength"] }], - }, - { - code: "require('buffer').transcode", - options: [{ version: "7.0.9", ignores: ["buffer.transcode"] }], - }, - ], - invalid: [ - { - code: "Buffer.alloc", - options: [{ version: "4.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "Buffer.alloc", - supported: "4.5.0", - version: "4.4.9", - }, - }, - ], - }, - { - code: "Buffer.allocUnsafe", - options: [{ version: "4.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "Buffer.allocUnsafe", - supported: "4.5.0", - version: "4.4.9", - }, - }, - ], - }, - { - code: "Buffer.allocUnsafeSlow", - options: [{ version: "4.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "Buffer.allocUnsafeSlow", - supported: "4.5.0", - version: "4.4.9", - }, - }, - ], - }, - { - code: "Buffer.from", - options: [{ version: "4.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "Buffer.from", - supported: "4.5.0", - version: "4.4.9", - }, - }, - ], - }, - { - code: "require('buffer').constants", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.constants", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "var cp = require('buffer'); cp.constants", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.constants", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "var { constants } = require('buffer');", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.constants", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "import cp from 'buffer'; cp.constants", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.constants", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "import { constants } from 'buffer'", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.constants", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "var {Buffer: b} = require('buffer'); b.alloc", - options: [{ version: "4.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.Buffer.alloc", - supported: "4.5.0", - version: "4.4.9", - }, - }, - ], - }, - { - code: "var {Buffer: b} = require('buffer'); b.allocUnsafe", - options: [{ version: "4.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.Buffer.allocUnsafe", - supported: "4.5.0", - version: "4.4.9", - }, - }, - ], - }, - { - code: "var {Buffer: b} = require('buffer'); b.allocUnsafeSlow", - options: [{ version: "4.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.Buffer.allocUnsafeSlow", - supported: "4.5.0", - version: "4.4.9", - }, - }, - ], - }, - { - code: "var {Buffer: b} = require('buffer'); b.from", - options: [{ version: "4.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.Buffer.from", - supported: "4.5.0", - version: "4.4.9", - }, - }, - ], - }, - { - code: "require('buffer').kMaxLength", - options: [{ version: "2.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.kMaxLength", - supported: "3.0.0", - version: "2.9.9", - }, - }, - ], - }, - { - code: "require('buffer').transcode", - options: [{ version: "7.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "buffer.transcode", - supported: "7.1.0", - version: "7.0.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/child_process.js b/tests/lib/rules/no-unsupported-features/child_process.js deleted file mode 100644 index 0a067538..00000000 --- a/tests/lib/rules/no-unsupported-features/child_process.js +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/child_process") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/child_process", rule, { - valid: [ - { - code: "require('child_process').ChildProcess", - options: [{ version: "2.2.0" }], - }, - { - code: "var cp = require('child_process'); cp.ChildProcess", - options: [{ version: "2.2.0" }], - }, - { - code: - "var { ChildProcess } = require('child_process'); ChildProcess", - options: [{ version: "2.2.0" }], - }, - { - code: "import cp from 'child_process'; cp.ChildProcess", - options: [{ version: "2.2.0" }], - }, - { - code: "import { ChildProcess } from 'child_process'", - options: [{ version: "2.2.0" }], - }, - - // Ignores. - { - code: "require('child_process').ChildProcess", - options: [ - { version: "2.1.9", ignores: ["child_process.ChildProcess"] }, - ], - }, - { - code: "var cp = require('child_process'); cp.ChildProcess", - options: [ - { version: "2.1.9", ignores: ["child_process.ChildProcess"] }, - ], - }, - { - code: - "var { ChildProcess } = require('child_process'); ChildProcess", - options: [ - { version: "2.1.9", ignores: ["child_process.ChildProcess"] }, - ], - }, - { - code: "import cp from 'child_process'; cp.ChildProcess", - options: [ - { version: "2.1.9", ignores: ["child_process.ChildProcess"] }, - ], - }, - { - code: "import { ChildProcess } from 'child_process'", - options: [ - { version: "2.1.9", ignores: ["child_process.ChildProcess"] }, - ], - }, - ], - invalid: [ - { - code: "require('child_process').ChildProcess", - options: [{ version: "2.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "child_process.ChildProcess", - supported: "2.2.0", - version: "2.1.9", - }, - }, - ], - }, - { - code: "var cp = require('child_process'); cp.ChildProcess", - options: [{ version: "2.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "child_process.ChildProcess", - supported: "2.2.0", - version: "2.1.9", - }, - }, - ], - }, - { - code: - "var { ChildProcess } = require('child_process'); ChildProcess", - options: [{ version: "2.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "child_process.ChildProcess", - supported: "2.2.0", - version: "2.1.9", - }, - }, - ], - }, - { - code: "import cp from 'child_process'; cp.ChildProcess", - options: [{ version: "2.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "child_process.ChildProcess", - supported: "2.2.0", - version: "2.1.9", - }, - }, - ], - }, - { - code: "import { ChildProcess } from 'child_process'", - options: [{ version: "2.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "child_process.ChildProcess", - supported: "2.2.0", - version: "2.1.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/console.js b/tests/lib/rules/no-unsupported-features/console.js deleted file mode 100644 index 60dab8ea..00000000 --- a/tests/lib/rules/no-unsupported-features/console.js +++ /dev/null @@ -1,446 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/console") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - console: false, - require: false, - }, -}).run("no-unsupported-features/console", rule, { - valid: [ - { - code: "console.clear()", - options: [{ version: "8.3.0" }], - }, - { - code: "require('console').clear()", - options: [{ version: "8.3.0" }], - }, - { - code: "var c = require('console'); c.clear()", - options: [{ version: "8.3.0" }], - }, - { - code: "var { clear } = require('console'); clear()", - options: [{ version: "8.3.0" }], - }, - { - code: "import c from 'console'; c.clear()", - options: [{ version: "8.3.0" }], - }, - { - code: "console.count()", - options: [{ version: "8.3.0" }], - }, - { - code: "console.countReset()", - options: [{ version: "8.3.0" }], - }, - { - code: "console.debug()", - options: [{ version: "8.0.0" }], - }, - { - code: "console.dirxml()", - options: [{ version: "8.0.0" }], - }, - { - code: "console.group()", - options: [{ version: "8.5.0" }], - }, - { - code: "console.groupCollapsed()", - options: [{ version: "8.5.0" }], - }, - { - code: "console.groupEnd()", - options: [{ version: "8.5.0" }], - }, - { - code: "console.table()", - options: [{ version: "10.0.0" }], - }, - { - code: "console.markTimeline()", - options: [{ version: "8.0.0" }], - }, - { - code: "console.profile()", - options: [{ version: "8.0.0" }], - }, - { - code: "console.profileEnd()", - options: [{ version: "8.0.0" }], - }, - { - code: "console.timeStamp()", - options: [{ version: "8.0.0" }], - }, - { - code: "console.timeline()", - options: [{ version: "8.0.0" }], - }, - { - code: "console.timelineEnd()", - options: [{ version: "8.0.0" }], - }, - - // Ignores. - { - code: "console.clear()", - options: [{ version: "8.2.9", ignores: ["console.clear"] }], - }, - { - code: "require('console').clear()", - options: [{ version: "8.2.9", ignores: ["console.clear"] }], - }, - { - code: "var c = require('console'); c.clear()", - options: [{ version: "8.2.9", ignores: ["console.clear"] }], - }, - { - code: "var { clear } = require('console'); clear()", - options: [{ version: "8.2.9", ignores: ["console.clear"] }], - }, - { - code: "import c from 'console'; c.clear()", - options: [{ version: "8.2.9", ignores: ["console.clear"] }], - }, - { - code: "console.count()", - options: [{ version: "8.2.9", ignores: ["console.count"] }], - }, - { - code: "console.countReset()", - options: [{ version: "8.2.9", ignores: ["console.countReset"] }], - }, - { - code: "console.debug()", - options: [{ version: "7.9.9", ignores: ["console.debug"] }], - }, - { - code: "console.dirxml()", - options: [{ version: "7.9.9", ignores: ["console.dirxml"] }], - }, - { - code: "console.group()", - options: [{ version: "8.4.9", ignores: ["console.group"] }], - }, - { - code: "console.groupCollapsed()", - options: [ - { version: "8.4.9", ignores: ["console.groupCollapsed"] }, - ], - }, - { - code: "console.groupEnd()", - options: [{ version: "8.4.9", ignores: ["console.groupEnd"] }], - }, - { - code: "console.table()", - options: [{ version: "9.9.9", ignores: ["console.table"] }], - }, - { - code: "console.markTimeline()", - options: [{ version: "7.9.9", ignores: ["console.markTimeline"] }], - }, - { - code: "console.profile()", - options: [{ version: "7.9.9", ignores: ["console.profile"] }], - }, - { - code: "console.profileEnd()", - options: [{ version: "7.9.9", ignores: ["console.profileEnd"] }], - }, - { - code: "console.timeStamp()", - options: [{ version: "7.9.9", ignores: ["console.timeStamp"] }], - }, - { - code: "console.timeline()", - options: [{ version: "7.9.9", ignores: ["console.timeline"] }], - }, - { - code: "console.timelineEnd()", - options: [{ version: "7.9.9", ignores: ["console.timelineEnd"] }], - }, - ], - invalid: [ - { - code: "console.clear()", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.clear", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "require('console').clear()", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.clear", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "var c = require('console'); c.clear()", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.clear", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "var { clear } = require('console'); clear()", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.clear", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "import c from 'console'; c.clear()", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.clear", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "console.count()", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.count", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "console.countReset()", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.countReset", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "console.debug()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.debug", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "console.dirxml()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.dirxml", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "console.group()", - options: [{ version: "8.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.group", - supported: "8.5.0", - version: "8.4.9", - }, - }, - ], - }, - { - code: "console.groupCollapsed()", - options: [{ version: "8.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.groupCollapsed", - supported: "8.5.0", - version: "8.4.9", - }, - }, - ], - }, - { - code: "console.groupEnd()", - options: [{ version: "8.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.groupEnd", - supported: "8.5.0", - version: "8.4.9", - }, - }, - ], - }, - { - code: "console.table()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.table", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "console.markTimeline()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.markTimeline", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "console.profile()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.profile", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "console.profileEnd()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.profileEnd", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "console.timeStamp()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.timeStamp", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "console.timeline()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.timeline", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "console.timelineEnd()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "console.timelineEnd", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/crypto.js b/tests/lib/rules/no-unsupported-features/crypto.js deleted file mode 100644 index 42c8493b..00000000 --- a/tests/lib/rules/no-unsupported-features/crypto.js +++ /dev/null @@ -1,493 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/crypto") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/crypto", rule, { - valid: [ - { - code: "require('crypto').constants", - options: [{ version: "6.3.0" }], - }, - { - code: "var hooks = require('crypto'); hooks.constants", - options: [{ version: "6.3.0" }], - }, - { - code: "var { constants } = require('crypto'); constants", - options: [{ version: "6.3.0" }], - }, - { - code: "import crypto from 'crypto'; crypto.constants", - options: [{ version: "6.3.0" }], - }, - { - code: "import { constants } from 'crypto'; constants", - options: [{ version: "6.3.0" }], - }, - { - code: "require('crypto').Certificate.exportChallenge()", - options: [{ version: "9.0.0" }], - }, - { - code: - "var { Certificate: c } = require('crypto'); c.exportChallenge()", - options: [{ version: "9.0.0" }], - }, - { - code: - "var { Certificate: c } = require('crypto'); c.exportPublicKey()", - options: [{ version: "9.0.0" }], - }, - { - code: "var { Certificate: c } = require('crypto'); c.verifySpkac()", - options: [{ version: "9.0.0" }], - }, - { - code: "require('crypto').fips", - options: [{ version: "6.0.0" }], - }, - { - code: "require('crypto').getCurves", - options: [{ version: "2.3.0" }], - }, - { - code: "require('crypto').getFips", - options: [{ version: "10.0.0" }], - }, - { - code: "require('crypto').privateEncrypt", - options: [{ version: "1.1.0" }], - }, - { - code: "require('crypto').publicDecrypt", - options: [{ version: "1.1.0" }], - }, - { - code: "require('crypto').randomFillSync", - options: [{ version: "7.10.0" }], - }, - { - code: "require('crypto').randomFill", - options: [{ version: "7.10.0" }], - }, - { - code: "require('crypto').scrypt", - options: [{ version: "10.5.0" }], - }, - { - code: "require('crypto').scryptSync", - options: [{ version: "10.5.0" }], - }, - { - code: "require('crypto').setFips", - options: [{ version: "10.0.0" }], - }, - { - code: "require('crypto').timingSafeEqual", - options: [{ version: "6.6.0" }], - }, - - // Ignores. - { - code: "require('crypto').constants", - options: [{ version: "6.2.9", ignores: ["crypto.constants"] }], - }, - { - code: "var hooks = require('crypto'); hooks.constants", - options: [{ version: "6.2.9", ignores: ["crypto.constants"] }], - }, - { - code: "var { constants } = require('crypto'); constants", - options: [{ version: "6.2.9", ignores: ["crypto.constants"] }], - }, - { - code: "import crypto from 'crypto'; crypto.constants", - options: [{ version: "6.2.9", ignores: ["crypto.constants"] }], - }, - { - code: "import { constants } from 'crypto'; constants", - options: [{ version: "6.2.9", ignores: ["crypto.constants"] }], - }, - { - code: "require('crypto').Certificate.exportChallenge()", - options: [ - { - version: "8.9.9", - ignores: ["crypto.Certificate.exportChallenge"], - }, - ], - }, - { - code: - "var { Certificate: c } = require('crypto'); c.exportChallenge()", - options: [ - { - version: "8.9.9", - ignores: ["crypto.Certificate.exportChallenge"], - }, - ], - }, - { - code: - "var { Certificate: c } = require('crypto'); c.exportPublicKey()", - options: [ - { - version: "8.9.9", - ignores: ["crypto.Certificate.exportPublicKey"], - }, - ], - }, - { - code: "var { Certificate: c } = require('crypto'); c.verifySpkac()", - options: [ - { - version: "8.9.9", - ignores: ["crypto.Certificate.verifySpkac"], - }, - ], - }, - { - code: "require('crypto').fips", - options: [{ version: "5.9.9", ignores: ["crypto.fips"] }], - }, - { - code: "require('crypto').getCurves", - options: [{ version: "2.2.9", ignores: ["crypto.getCurves"] }], - }, - { - code: "require('crypto').getFips", - options: [{ version: "9.9.9", ignores: ["crypto.getFips"] }], - }, - { - code: "require('crypto').privateEncrypt", - options: [{ version: "1.0.9", ignores: ["crypto.privateEncrypt"] }], - }, - { - code: "require('crypto').publicDecrypt", - options: [{ version: "1.0.9", ignores: ["crypto.publicDecrypt"] }], - }, - { - code: "require('crypto').randomFillSync", - options: [{ version: "7.9.9", ignores: ["crypto.randomFillSync"] }], - }, - { - code: "require('crypto').randomFill", - options: [{ version: "7.9.9", ignores: ["crypto.randomFill"] }], - }, - { - code: "require('crypto').scrypt", - options: [{ version: "10.4.9", ignores: ["crypto.scrypt"] }], - }, - { - code: "require('crypto').scryptSync", - options: [{ version: "10.4.9", ignores: ["crypto.scryptSync"] }], - }, - { - code: "require('crypto').setFips", - options: [{ version: "9.9.9", ignores: ["crypto.setFips"] }], - }, - { - code: "require('crypto').timingSafeEqual", - options: [ - { version: "6.5.9", ignores: ["crypto.timingSafeEqual"] }, - ], - }, - ], - invalid: [ - { - code: "require('crypto').constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "var hooks = require('crypto'); hooks.constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "var { constants } = require('crypto'); constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "import crypto from 'crypto'; crypto.constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "import { constants } from 'crypto'; constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "require('crypto').Certificate.exportChallenge()", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.Certificate.exportChallenge", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - { - code: - "var { Certificate: c } = require('crypto'); c.exportChallenge()", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.Certificate.exportChallenge", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - { - code: - "var { Certificate: c } = require('crypto'); c.exportPublicKey()", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.Certificate.exportPublicKey", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - { - code: "var { Certificate: c } = require('crypto'); c.verifySpkac()", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.Certificate.verifySpkac", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - { - code: "require('crypto').fips", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.fips", - supported: "6.0.0", - version: "5.9.9", - }, - }, - ], - }, - { - code: "require('crypto').getCurves", - options: [{ version: "2.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.getCurves", - supported: "2.3.0", - version: "2.2.9", - }, - }, - ], - }, - { - code: "require('crypto').getFips", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.getFips", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "require('crypto').privateEncrypt", - options: [{ version: "1.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.privateEncrypt", - supported: "1.1.0", - version: "1.0.9", - }, - }, - ], - }, - { - code: "require('crypto').publicDecrypt", - options: [{ version: "1.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.publicDecrypt", - supported: "1.1.0", - version: "1.0.9", - }, - }, - ], - }, - { - code: "require('crypto').randomFillSync", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.randomFillSync", - supported: "7.10.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('crypto').randomFill", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.randomFill", - supported: "7.10.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('crypto').scrypt", - options: [{ version: "10.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.scrypt", - supported: "10.5.0", - version: "10.4.9", - }, - }, - ], - }, - { - code: "require('crypto').scryptSync", - options: [{ version: "10.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.scryptSync", - supported: "10.5.0", - version: "10.4.9", - }, - }, - ], - }, - { - code: "require('crypto').setFips", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.setFips", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "require('crypto').timingSafeEqual", - options: [{ version: "6.5.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "crypto.timingSafeEqual", - supported: "6.6.0", - version: "6.5.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/dns.js b/tests/lib/rules/no-unsupported-features/dns.js deleted file mode 100644 index 202f57ec..00000000 --- a/tests/lib/rules/no-unsupported-features/dns.js +++ /dev/null @@ -1,179 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/dns") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/dns", rule, { - valid: [ - { - code: "require('dns').Resolver", - options: [{ version: "8.3.0" }], - }, - { - code: "var hooks = require('dns'); hooks.Resolver", - options: [{ version: "8.3.0" }], - }, - { - code: "var { Resolver } = require('dns'); Resolver", - options: [{ version: "8.3.0" }], - }, - { - code: "import dns from 'dns'; dns.Resolver", - options: [{ version: "8.3.0" }], - }, - { - code: "import { Resolver } from 'dns'; Resolver", - options: [{ version: "8.3.0" }], - }, - { - code: "require('dns').resolvePtr", - options: [{ version: "6.0.0" }], - }, - { - code: "require('dns').promises", - options: [{ version: "10.6.0" }], - }, - - // Ignores - { - code: "require('dns').Resolver", - options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], - }, - { - code: "var hooks = require('dns'); hooks.Resolver", - options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], - }, - { - code: "var { Resolver } = require('dns'); Resolver", - options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], - }, - { - code: "import dns from 'dns'; dns.Resolver", - options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], - }, - { - code: "import { Resolver } from 'dns'; Resolver", - options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], - }, - { - code: "require('dns').resolvePtr", - options: [{ version: "5.9.9", ignores: ["dns.resolvePtr"] }], - }, - { - code: "require('dns').promises", - options: [{ version: "10.5.9", ignores: ["dns.promises"] }], - }, - ], - invalid: [ - { - code: "require('dns').Resolver", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "dns.Resolver", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "var hooks = require('dns'); hooks.Resolver", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "dns.Resolver", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "var { Resolver } = require('dns'); Resolver", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "dns.Resolver", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "import dns from 'dns'; dns.Resolver", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "dns.Resolver", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "import { Resolver } from 'dns'; Resolver", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "dns.Resolver", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "require('dns').resolvePtr", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "dns.resolvePtr", - supported: "6.0.0", - version: "5.9.9", - }, - }, - ], - }, - { - code: "require('dns').promises", - options: [{ version: "10.5.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "dns.promises", - supported: "10.6.0", - version: "10.5.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/es-builtins.js b/tests/lib/rules/no-unsupported-features/es-builtins.js new file mode 100644 index 00000000..f79164a6 --- /dev/null +++ b/tests/lib/rules/no-unsupported-features/es-builtins.js @@ -0,0 +1,2056 @@ +/** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */ +"use strict" + +const RuleTester = require("eslint").RuleTester +const { configs } = require("@mysticatea/eslint-plugin") +const rule = require("../../../../lib/rules/no-unsupported-features/es-builtins") + +/** + * Clone given invalid patterns with adding `ignores` option. + * @param {string} keyword The keyword of `ignores` option. + * @returns {function(pattern:object):object} The cloned pattern. + */ +function ignores(keyword) { + return original => { + const pattern = Object.assign({}, original) + delete pattern.error + + pattern.options = pattern.options.slice() + pattern.options[0] = Object.assign({}, pattern.options[0]) + if (pattern.options[0].ignores) { + pattern.options[0].ignores = pattern.options[0].ignores.concat([ + keyword, + ]) + } else { + pattern.options[0].ignores = [keyword] + } + + return pattern + } +} + +/** + * Concatenate patterns. + * @param {Array<{valid:Array,invalid:Array}>} patterns The patterns to concat. + * @returns {{valid:Array,invalid:Array}} The concatenated patterns. + */ +function concat(patterns) { + const ret = { + valid: [], + invalid: [], + } + + for (const { keyword, valid, invalid } of patterns) { + ret.valid.push(...valid) + ret.invalid.push(...invalid) + + // Add the invalid patterns with `ignores` option into the valid patterns. + ret.valid.push(...invalid.map(ignores(keyword))) + } + + return ret +} + +const ruleTester = new RuleTester({ + parserOptions: { ecmaVersion: 2018 }, + globals: Object.assign({}, configs.es2015.globals, configs.es2017.globals), +}) +ruleTester.run( + "no-unsupported-features/es-builtins", + rule, + concat([ + { + keyword: "Array.from", + valid: [ + { + code: "Array.foo(a)", + options: [{ version: "3.9.9" }], + }, + { + code: "(function(Array) { Array.from(a) }(b))", + options: [{ version: "3.9.9" }], + }, + { + code: "Array.from(a)", + options: [{ version: "4.0.0" }], + }, + ], + invalid: [ + { + code: "Array.from(a)", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Array.from", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Array.of", + valid: [ + { + code: "Array.foo(a)", + options: [{ version: "3.9.9" }], + }, + { + code: "(function(Array) { Array.of(a) }(b))", + options: [{ version: "3.9.9" }], + }, + { + code: "Array.of(a)", + options: [{ version: "4.0.0" }], + }, + ], + invalid: [ + { + code: "Array.of(a)", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Array.of", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Map", + valid: [ + { + code: "map", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Map) { Map }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Map", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Map", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Map", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + { + code: "(function() { Map })()", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Map", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.acosh", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.acosh(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.acosh(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.acosh(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.acosh", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.asinh", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.asinh(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.asinh(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.asinh(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.asinh", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.atanh", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.atanh(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.atanh(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.atanh(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.atanh", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.cbrt", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.cbrt(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.cbrt(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.cbrt(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.cbrt", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.clz32", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.clz32(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.clz32(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.clz32(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.clz32", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.cosh", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.cosh(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.cosh(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.cosh(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.cosh", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.expm1", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.expm1(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.expm1(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.expm1(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.expm1", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.fround", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.fround(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.fround(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.fround(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.fround", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.hypot", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.hypot(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.hypot(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.hypot(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.hypot", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.imul", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.imul(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.imul(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.imul(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.imul", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.log10", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.log10(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.log10(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.log10(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.log10", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.log1p", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.log1p(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.log1p(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.log1p(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.log1p", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.log2", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.log2(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.log2(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.log2(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.log2", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.sign", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.sign(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.sign(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.sign(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.sign", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.sinh", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.sinh(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.sinh(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.sinh(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.sinh", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.tanh", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.tanh(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.tanh(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.tanh(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.tanh", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Math.trunc", + valid: [ + { + code: "Math.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Math) { Math.trunc(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Math.trunc(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Math.trunc(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Math.trunc", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Number.isFinite", + valid: [ + { + code: "Number.foo(a)", + options: [{ version: "0.9.9" }], + }, + { + code: "(function(Number) { Number.isFinite(a) }(b))", + options: [{ version: "0.9.9" }], + }, + { + code: "Number.isFinite(a)", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Number.isFinite(a)", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Number.isFinite", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Number.isInteger", + valid: [ + { + code: "Number.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Number) { Number.isInteger(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Number.isInteger(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Number.isInteger(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Number.isInteger", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Number.isNaN", + valid: [ + { + code: "Number.foo(a)", + options: [{ version: "0.9.9" }], + }, + { + code: "(function(Number) { Number.isNaN(a) }(b))", + options: [{ version: "0.9.9" }], + }, + { + code: "Number.isNaN(a)", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Number.isNaN(a)", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Number.isNaN", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Number.isSafeInteger", + valid: [ + { + code: "Number.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Number) { Number.isSafeInteger(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Number.isSafeInteger(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Number.isSafeInteger(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Number.isSafeInteger", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Number.parseFloat", + valid: [ + { + code: "Number.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Number) { Number.parseFloat(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Number.parseFloat(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Number.parseFloat(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Number.parseFloat", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Number.parseInt", + valid: [ + { + code: "Number.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Number) { Number.parseInt(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Number.parseInt(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Number.parseInt(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Number.parseInt", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Object.assign", + valid: [ + { + code: "Object.foo(a)", + options: [{ version: "3.9.9" }], + }, + { + code: "(function(Object) { Object.assign(a) }(b))", + options: [{ version: "3.9.9" }], + }, + { + code: "Object.assign(a)", + options: [{ version: "4.0.0" }], + }, + ], + invalid: [ + { + code: "Object.assign(a)", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Object.assign", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Object.getOwnPropertySymbols", + valid: [ + { + code: "Object.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: + "(function(Object) { Object.getOwnPropertySymbols(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Object.getOwnPropertySymbols(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Object.getOwnPropertySymbols(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Object.getOwnPropertySymbols", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Object.is", + valid: [ + { + code: "Object.foo(a)", + options: [{ version: "0.9.9" }], + }, + { + code: "(function(Object) { Object.is(a) }(b))", + options: [{ version: "0.9.9" }], + }, + { + code: "Object.is(a)", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Object.is(a)", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Object.is", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Object.setPrototypeOf", + valid: [ + { + code: "Object.foo(a)", + options: [{ version: "0.11.9" }], + }, + { + code: "(function(Object) { Object.setPrototypeOf(a) }(b))", + options: [{ version: "0.11.9" }], + }, + { + code: "Object.setPrototypeOf(a)", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Object.setPrototypeOf(a)", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Object.setPrototypeOf", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Promise", + valid: [ + { + code: "(function(Promise) { Promise }(a))", + options: [{ version: "0.11.9" }], + }, + { + code: "Promise", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Promise", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Promise", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + { + code: "function wrap() { Promise }", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Promise", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Proxy", + valid: [ + { + code: "(function(Proxy) { Proxy }(a))", + options: [{ version: "5.9.9" }], + }, + { + code: "Proxy", + options: [{ version: "6.0.0" }], + }, + ], + invalid: [ + { + code: "Proxy", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Proxy", + supported: "6.0.0", + version: "5.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Proxy }", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Proxy", + supported: "6.0.0", + version: "5.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Reflect", + valid: [ + { + code: "(function(Reflect) { Reflect }(a))", + options: [{ version: "5.9.9" }], + }, + { + code: "Reflect", + options: [{ version: "6.0.0" }], + }, + ], + invalid: [ + { + code: "Reflect", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Reflect", + supported: "6.0.0", + version: "5.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Reflect }", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Reflect", + supported: "6.0.0", + version: "5.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Set", + valid: [ + { + code: "(function(Set) { Set }(a))", + options: [{ version: "0.11.9" }], + }, + { + code: "Set", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Set", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Set", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + { + code: "function wrap() { Set }", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Set", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "String.fromCodePoint", + valid: [ + { + code: "String.foo(a)", + options: [{ version: "3.9.9" }], + }, + { + code: "(function(String) { String.fromCodePoint(a) }(b))", + options: [{ version: "3.9.9" }], + }, + { + code: "String.fromCodePoint(a)", + options: [{ version: "4.0.0" }], + }, + ], + invalid: [ + { + code: "String.fromCodePoint(a)", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "String.fromCodePoint", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "String.raw", + valid: [ + { + code: "String.foo(a)", + options: [{ version: "3.9.9" }], + }, + { + code: "(function(String) { String.raw(a) }(b))", + options: [{ version: "3.9.9" }], + }, + { + code: "String.raw(a)", + options: [{ version: "4.0.0" }], + }, + ], + invalid: [ + { + code: "String.raw(a)", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "String.raw", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Symbol", + valid: [ + { + code: "(function(Symbol) { Symbol }(a))", + options: [{ version: "0.11.9" }], + }, + { + code: "Symbol", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "Symbol", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Symbol", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + { + code: "function wrap() { Symbol }", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Symbol", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Int8Array", + valid: [ + { + code: "(function(Int8Array) { Int8Array }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "Int8Array", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Int8Array", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Int8Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Int8Array }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Int8Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Uint8Array", + valid: [ + { + code: "(function(Uint8Array) { Uint8Array }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "Uint8Array", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Uint8Array", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Uint8Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Uint8Array }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Uint8Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Uint8ClampedArray", + valid: [ + { + code: + "(function(Uint8ClampedArray) { Uint8ClampedArray }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "Uint8ClampedArray", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Uint8ClampedArray", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Uint8ClampedArray", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Uint8ClampedArray }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Uint8ClampedArray", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Int16Array", + valid: [ + { + code: "(function(Int16Array) { Int16Array }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "Int16Array", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Int16Array", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Int16Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Int16Array }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Int16Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Uint16Array", + valid: [ + { + code: "(function(Uint16Array) { Uint16Array }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "Uint16Array", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Uint16Array", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Uint16Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Uint16Array }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Uint16Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Int32Array", + valid: [ + { + code: "(function(Int32Array) { Int32Array }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "Int32Array", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Int32Array", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Int32Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Int32Array }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Int32Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Uint32Array", + valid: [ + { + code: "(function(Uint32Array) { Uint32Array }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "Uint32Array", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Uint32Array", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Uint32Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Uint32Array }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Uint32Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Float32Array", + valid: [ + { + code: "(function(Float32Array) { Float32Array }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "Float32Array", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Float32Array", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Float32Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Float32Array }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Float32Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Float64Array", + valid: [ + { + code: "(function(Float64Array) { Float64Array }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "Float64Array", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "Float64Array", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Float64Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Float64Array }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Float64Array", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "DataView", + valid: [ + { + code: "(function(DataView) { DataView }(a))", + options: [{ version: "0.9.9" }], + }, + { + code: "DataView", + options: [{ version: "0.10.0" }], + }, + ], + invalid: [ + { + code: "DataView", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "DataView", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + { + code: "function wrap() { DataView }", + options: [{ version: "0.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "DataView", + supported: "0.10.0", + version: "0.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "WeakMap", + valid: [ + { + code: "(function(WeakMap) { WeakMap }(a))", + options: [{ version: "0.11.9" }], + }, + { + code: "WeakMap", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "WeakMap", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "WeakMap", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + { + code: "function wrap() { WeakMap }", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "WeakMap", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "WeakSet", + valid: [ + { + code: "(function(WeakSet) { WeakSet }(a))", + options: [{ version: "0.11.9" }], + }, + { + code: "WeakSet", + options: [{ version: "0.12.0" }], + }, + ], + invalid: [ + { + code: "WeakSet", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "WeakSet", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + { + code: "function wrap() { WeakSet }", + options: [{ version: "0.11.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "WeakSet", + supported: "0.12.0", + version: "0.11.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Atomics", + valid: [ + { + code: "(function(Atomics) { Atomics }(a))", + options: [{ version: "8.9.9" }], + }, + { + code: "Atomics", + options: [{ version: "8.10.0" }], + }, + ], + invalid: [ + { + code: "Atomics", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Atomics", + supported: "8.10.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: "function wrap() { Atomics }", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Atomics", + supported: "8.10.0", + version: "8.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Object.values", + valid: [ + { + code: "Object.foo(a)", + options: [{ version: "6.9.9" }], + }, + { + code: "(function(Object) { Object.values(a) }(b))", + options: [{ version: "6.9.9" }], + }, + { + code: "Object.values(a)", + options: [{ version: "7.0.0" }], + }, + ], + invalid: [ + { + code: "Object.values(a)", + options: [{ version: "6.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Object.values", + supported: "7.0.0", + version: "6.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Object.entries", + valid: [ + { + code: "Object.foo(a)", + options: [{ version: "6.9.9" }], + }, + { + code: "(function(Object) { Object.entries(a) }(b))", + options: [{ version: "6.9.9" }], + }, + { + code: "Object.entries(a)", + options: [{ version: "7.0.0" }], + }, + ], + invalid: [ + { + code: "Object.entries(a)", + options: [{ version: "6.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Object.entries", + supported: "7.0.0", + version: "6.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "Object.getOwnPropertyDescriptors", + valid: [ + { + code: "Object.foo(a)", + options: [{ version: "6.9.9" }], + }, + { + code: + "(function(Object) { Object.getOwnPropertyDescriptors(a) }(b))", + options: [{ version: "6.9.9" }], + }, + { + code: "Object.getOwnPropertyDescriptors(a)", + options: [{ version: "7.0.0" }], + }, + ], + invalid: [ + { + code: "Object.getOwnPropertyDescriptors(a)", + options: [{ version: "6.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Object.getOwnPropertyDescriptors", + supported: "7.0.0", + version: "6.9.9", + }, + }, + ], + }, + ], + }, + { + keyword: "SharedArrayBuffer", + valid: [ + { + code: + "(function(SharedArrayBuffer) { SharedArrayBuffer }(a))", + options: [{ version: "8.9.9" }], + }, + { + code: "SharedArrayBuffer", + options: [{ version: "8.10.0" }], + }, + ], + invalid: [ + { + code: "SharedArrayBuffer", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "SharedArrayBuffer", + supported: "8.10.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: "function wrap() { SharedArrayBuffer }", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "SharedArrayBuffer", + supported: "8.10.0", + version: "8.9.9", + }, + }, + ], + }, + ], + }, + ]) +) diff --git a/tests/lib/rules/no-unsupported-features/ecma.js b/tests/lib/rules/no-unsupported-features/es-syntax.js similarity index 54% rename from tests/lib/rules/no-unsupported-features/ecma.js rename to tests/lib/rules/no-unsupported-features/es-syntax.js index e5a2b986..c179b6f5 100644 --- a/tests/lib/rules/no-unsupported-features/ecma.js +++ b/tests/lib/rules/no-unsupported-features/es-syntax.js @@ -7,7 +7,7 @@ const path = require("path") const RuleTester = require("eslint").RuleTester const { configs } = require("@mysticatea/eslint-plugin") -const rule = require("../../../../lib/rules/no-unsupported-features/ecma") +const rule = require("../../../../lib/rules/no-unsupported-features/es-syntax") /** * Makes a file path to a fixture. @@ -24,27 +24,26 @@ function fixture(name) { /** * Clone given invalid patterns with adding `ignores` option. - * @param {string[]} keywords The keywords of `ignores` option. + * @param {string} keyword The keyword of `ignores` option. * @returns {function(pattern:object):object} The cloned pattern. */ -function ignores(keywords) { - return original => - keywords.map(key => { - const pattern = Object.assign({}, original) - delete pattern.error +function ignores(keyword) { + return original => { + const pattern = Object.assign({}, original) + delete pattern.error - pattern.options = pattern.options.slice() - pattern.options[0] = Object.assign({}, pattern.options[0]) - if (pattern.options[0].ignores) { - pattern.options[0].ignores = pattern.options[0].ignores.concat([ - key, - ]) - } else { - pattern.options[0].ignores = [key] - } + pattern.options = pattern.options.slice() + pattern.options[0] = Object.assign({}, pattern.options[0]) + if (pattern.options[0].ignores) { + pattern.options[0].ignores = pattern.options[0].ignores.concat([ + keyword, + ]) + } else { + pattern.options[0].ignores = [keyword] + } - return pattern - }) + return pattern + } } /** @@ -58,13 +57,13 @@ function concat(patterns) { invalid: [], } - for (const { keywords, valid, invalid } of patterns) { + for (const { keyword, valid, invalid } of patterns) { ret.valid.push(...valid) ret.invalid.push(...invalid) // Add the invalid patterns with `ignores` option into the valid patterns. - for (const ignoringPatterns of invalid.map(ignores(keywords))) { - ret.valid.push(...ignoringPatterns) + if (keyword) { + ret.valid.push(...invalid.map(ignores(keyword))) } } @@ -76,14 +75,14 @@ const ruleTester = new RuleTester({ globals: Object.assign({}, configs.es2015.globals, configs.es2017.globals), }) ruleTester.run( - "no-unsupported-features/ecma", + "no-unsupported-features/es-syntax", rule, concat([ //---------------------------------------------------------------------- // ES2015 //---------------------------------------------------------------------- { - keywords: ["arrowFunctions", "syntax"], + keyword: "arrowFunctions", valid: [ { code: "function f() {}", @@ -126,7 +125,7 @@ ruleTester.run( ], }, { - keywords: ["binaryNumericLiterals", "syntax"], + keyword: "binaryNumericLiterals", valid: [ { code: "0x01", @@ -155,7 +154,7 @@ ruleTester.run( ], }, { - keywords: ["blockScopedFunctions", "syntax"], + keyword: "blockScopedFunctions", valid: [ { code: "'use strict'; if (a) { function f() {} }", @@ -200,7 +199,7 @@ ruleTester.run( ], }, { - keywords: ["blockScopedVariables", "syntax"], + keyword: "blockScopedVariables", valid: [ { code: "var a = 0", @@ -275,7 +274,7 @@ ruleTester.run( ], }, { - keywords: ["classes", "syntax"], + keyword: "classes", valid: [ { code: "'use strict'; class A {}", @@ -318,7 +317,7 @@ ruleTester.run( ], }, { - keywords: ["computedProperties", "syntax"], + keyword: "computedProperties", valid: [ { code: "({ 0: 0, key: 1, 'key2': 2, key3, key4() {} })", @@ -389,7 +388,7 @@ ruleTester.run( ], }, { - keywords: ["defaultParameters", "syntax"], + keyword: "defaultParameters", valid: [ { code: "a = 0", @@ -431,30 +430,6 @@ ruleTester.run( code: "(class { key(a = 0) {} })", options: [{ version: "6.0.0" }], }, - { - code: "function f(a = 0) {}", - options: [{ version: "5.9.9", ignores: ["syntax"] }], - }, - { - code: "(function(a = 0) {})", - options: [{ version: "5.9.9", ignores: ["syntax"] }], - }, - { - code: "((a = 0) => a)", - options: [{ version: "5.9.9", ignores: ["syntax"] }], - }, - { - code: "({ key(a = 0) {} })", - options: [{ version: "5.9.9", ignores: ["syntax"] }], - }, - { - code: "class A { key(a = 0) {} }", - options: [{ version: "5.9.9", ignores: ["syntax"] }], - }, - { - code: "(class { key(a = 0) {} })", - options: [{ version: "5.9.9", ignores: ["syntax"] }], - }, { code: "function f(a = 0) {}", options: [ @@ -562,7 +537,7 @@ ruleTester.run( ], }, { - keywords: ["destructuring", "syntax"], + keyword: "destructuring", valid: [ { code: "function f(a = 0) {}", @@ -688,7 +663,7 @@ ruleTester.run( ], }, { - keywords: ["forOfLoops", "syntax"], + keyword: "forOfLoops", valid: [ { code: "for (;;);", @@ -750,7 +725,7 @@ ruleTester.run( ], }, { - keywords: ["generators", "syntax"], + keyword: "generators", valid: [ { code: "function f() {}", @@ -841,7 +816,7 @@ ruleTester.run( ], }, { - keywords: ["modules", "syntax"], + keyword: "modules", valid: [ { code: "require('a')", @@ -904,7 +879,7 @@ ruleTester.run( ], }, { - keywords: ["new.target", "syntax"], + keyword: "new.target", valid: [ { code: "new target", @@ -943,7 +918,7 @@ ruleTester.run( ], }, { - keywords: ["objectSuperProperties", "syntax"], + keyword: "objectSuperProperties", valid: [ { code: "class A { foo() { super.foo } }", @@ -998,7 +973,7 @@ ruleTester.run( ], }, { - keywords: ["octalNumericLiterals", "syntax"], + keyword: "octalNumericLiterals", valid: [ { code: "0755", @@ -1063,7 +1038,7 @@ ruleTester.run( ], }, { - keywords: ["propertyShorthands", "syntax"], + keyword: "propertyShorthands", valid: [ { code: "({ a: 1 })", @@ -1180,7 +1155,7 @@ ruleTester.run( ], }, { - keywords: ["regexpU", "syntax"], + keyword: "regexpU", valid: [ { code: "/foo/", @@ -1213,7 +1188,7 @@ ruleTester.run( ], }, { - keywords: ["regexpY", "syntax"], + keyword: "regexpY", valid: [ { code: "/foo/", @@ -1246,7 +1221,7 @@ ruleTester.run( ], }, { - keywords: ["restParameters", "syntax"], + keyword: "restParameters", valid: [ { code: "var [...a] = b", @@ -1378,7 +1353,7 @@ ruleTester.run( ], }, { - keywords: ["spreadElements", "syntax"], + keyword: "spreadElements", valid: [ { code: "var [...a] = b", @@ -1474,7 +1449,7 @@ ruleTester.run( }, { /*eslint-disable no-template-curly-in-string */ - keywords: ["templateLiterals", "syntax"], + keyword: "templateLiterals", valid: [ { code: "'`foo`'", @@ -1542,7 +1517,7 @@ ruleTester.run( /*eslint-enable no-template-curly-in-string */ }, { - keywords: ["unicodeCodePointEscapes", "syntax"], + keyword: "unicodeCodePointEscapes", valid: [ { code: String.raw`var a = "\x61"`, @@ -1628,1868 +1603,216 @@ ruleTester.run( }, ], }, + + //---------------------------------------------------------------------- + // ES2016 + //---------------------------------------------------------------------- { - keywords: ["Array.from", "Array.*", "runtime"], + keyword: "exponentialOperators", valid: [ { - code: "Array.foo(a)", - options: [{ version: "3.9.9" }], + code: "a ** b", + options: [{ version: "7.0.0" }], }, { - code: "(function(Array) { Array.from(a) }(b))", - options: [{ version: "3.9.9" }], + code: "a **= b", + options: [{ version: "7.0.0" }], }, { - code: "Array.from(a)", - options: [{ version: "4.0.0" }], + code: "a * b", + options: [{ version: "6.9.9" }], + }, + { + code: "a *= b", + options: [{ version: "6.9.9" }], }, ], invalid: [ { - code: "Array.from(a)", - options: [{ version: "3.9.9" }], + code: "a ** b", + options: [{ version: "6.9.9" }], errors: [ { - messageId: "no-array-from", - data: { supported: "4.0.0", version: "3.9.9" }, + messageId: "no-exponential-operators", + data: { supported: "7.0.0", version: "6.9.9" }, + }, + ], + }, + { + code: "a **= b", + options: [{ version: "6.9.9" }], + errors: [ + { + messageId: "no-exponential-operators", + data: { supported: "7.0.0", version: "6.9.9" }, }, ], }, ], }, + + //---------------------------------------------------------------------- + // ES2017 + //---------------------------------------------------------------------- { - keywords: ["Array.of", "Array.*", "runtime"], + keyword: "asyncFunctions", valid: [ { - code: "Array.foo(a)", - options: [{ version: "3.9.9" }], + code: "async function f() {}", + options: [{ version: "7.6.0" }], }, { - code: "(function(Array) { Array.of(a) }(b))", - options: [{ version: "3.9.9" }], + code: "async function f() { await 1 }", + options: [{ version: "7.6.0" }], }, { - code: "Array.of(a)", - options: [{ version: "4.0.0" }], + code: "(async function() { await 1 })", + options: [{ version: "7.6.0" }], }, - ], - invalid: [ { - code: "Array.of(a)", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "no-array-of", - data: { supported: "4.0.0", version: "3.9.9" }, - }, - ], + code: "(async() => { await 1 })", + options: [{ version: "7.6.0" }], }, - ], - }, - { - keywords: ["Map", "runtime"], - valid: [ { - code: "map", - options: [{ version: "0.11.9" }], + code: "({ async method() { await 1 } })", + options: [{ version: "7.6.0" }], }, { - code: "(function(Map) { Map }(b))", - options: [{ version: "0.11.9" }], + code: "class A { async method() { await 1 } }", + options: [{ version: "7.6.0" }], }, { - code: "Map", - options: [{ version: "0.12.0" }], + code: "(class { async method() { await 1 } })", + options: [{ version: "7.6.0" }], }, ], invalid: [ { - code: "Map", - options: [{ version: "0.11.9" }], + code: "async function f() {}", + options: [{ version: "7.5.9" }], errors: [ { - messageId: "no-map", - data: { supported: "0.12.0", version: "0.11.9" }, + messageId: "no-async-functions", + data: { supported: "7.6.0", version: "7.5.9" }, }, ], }, { - code: "(function() { Map })()", - options: [{ version: "0.11.9" }], + code: "async function f() { await 1 }", + options: [{ version: "7.5.9" }], errors: [ { - messageId: "no-map", - data: { supported: "0.12.0", version: "0.11.9" }, + messageId: "no-async-functions", + data: { supported: "7.6.0", version: "7.5.9" }, }, ], }, - ], - }, - { - keywords: ["Math.acosh", "Math.*", "runtime"], - valid: [ - { - code: "Math.foo(a)", - options: [{ version: "0.11.9" }], - }, - { - code: "(function(Math) { Math.acosh(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { - code: "Math.acosh(a)", - options: [{ version: "0.12.0" }], - }, - ], - invalid: [ { - code: "Math.acosh(a)", - options: [{ version: "0.11.9" }], + code: "(async function() { await 1 })", + options: [{ version: "7.5.9" }], errors: [ { - messageId: "no-math-acosh", - data: { supported: "0.12.0", version: "0.11.9" }, + messageId: "no-async-functions", + data: { supported: "7.6.0", version: "7.5.9" }, }, ], }, - ], - }, - { - keywords: ["Math.asinh", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.asinh(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.asinh(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ { - code: "Math.asinh(a)", - options: [{ version: "0.11.9" }], + code: "(async() => { await 1 })", + options: [{ version: "7.5.9" }], errors: [ { - messageId: "no-math-asinh", - data: { supported: "0.12.0", version: "0.11.9" }, + messageId: "no-async-functions", + data: { supported: "7.6.0", version: "7.5.9" }, }, ], }, - ], - }, - { - keywords: ["Math.atanh", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.atanh(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.atanh(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ { - code: "Math.atanh(a)", - options: [{ version: "0.11.9" }], + code: "({ async method() { await 1 } })", + options: [{ version: "7.5.9" }], errors: [ { - messageId: "no-math-atanh", - data: { supported: "0.12.0", version: "0.11.9" }, + messageId: "no-async-functions", + data: { supported: "7.6.0", version: "7.5.9" }, }, ], }, - ], - }, - { - keywords: ["Math.cbrt", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.cbrt(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.cbrt(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ { - code: "Math.cbrt(a)", - options: [{ version: "0.11.9" }], + code: "class A { async method() { await 1 } }", + options: [{ version: "7.5.9" }], errors: [ { - messageId: "no-math-cbrt", - data: { supported: "0.12.0", version: "0.11.9" }, + messageId: "no-async-functions", + data: { supported: "7.6.0", version: "7.5.9" }, }, ], }, - ], - }, - { - keywords: ["Math.clz32", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.clz32(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.clz32(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ { - code: "Math.clz32(a)", - options: [{ version: "0.11.9" }], + code: "(class { async method() { await 1 } })", + options: [{ version: "7.5.9" }], errors: [ { - messageId: "no-math-clz32", - data: { supported: "0.12.0", version: "0.11.9" }, + messageId: "no-async-functions", + data: { supported: "7.6.0", version: "7.5.9" }, }, ], }, ], }, { - keywords: ["Math.cosh", "Math.*", "runtime"], + keyword: "trailingCommasInFunctions", valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, { - code: "(function(Math) { Math.cosh(a) }(b))", - options: [{ version: "0.11.9" }], + code: "function f(a,) {}", + options: [{ version: "8.0.0" }], }, - { code: "Math.cosh(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ { - code: "Math.cosh(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-cosh", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], + code: "(function(a,) {})", + options: [{ version: "8.0.0" }], }, - ], - }, - { - keywords: ["Math.expm1", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, { - code: "(function(Math) { Math.expm1(a) }(b))", - options: [{ version: "0.11.9" }], + code: "((a,) => {})", + options: [{ version: "8.0.0" }], }, - { code: "Math.expm1(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ { - code: "Math.expm1(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-expm1", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], + code: "({ method(a,) {} })", + options: [{ version: "8.0.0" }], }, - ], - }, - { - keywords: ["Math.fround", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, { - code: "(function(Math) { Math.fround(a) }(b))", - options: [{ version: "0.11.9" }], + code: "class A { method(a,) {} }", + options: [{ version: "8.0.0" }], + }, + { + code: "(class { method(a,) {} })", + options: [{ version: "8.0.0" }], + }, + { + code: "f(1,)", + options: [{ version: "8.0.0" }], + }, + { + code: "new A(1,)", + options: [{ version: "8.0.0" }], }, - { code: "Math.fround(a)", options: [{ version: "0.12.0" }] }, ], invalid: [ { - code: "Math.fround(a)", - options: [{ version: "0.11.9" }], + code: "function f(a,) {}", + options: [{ version: "7.9.9" }], errors: [ { - messageId: "no-math-fround", - data: { supported: "0.12.0", version: "0.11.9" }, + messageId: "no-trailing-function-commas", + data: { supported: "8.0.0", version: "7.9.9" }, }, ], }, - ], - }, - { - keywords: ["Math.hypot", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.hypot(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.hypot(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ { - code: "Math.hypot(a)", - options: [{ version: "0.11.9" }], + code: "(function(a,) {})", + options: [{ version: "7.9.9" }], errors: [ { - messageId: "no-math-hypot", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Math.imul", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.imul(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.imul(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Math.imul(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-imul", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Math.log10", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.log10(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.log10(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Math.log10(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-log10", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Math.log1p", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.log1p(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.log1p(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Math.log1p(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-log1p", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Math.log2", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.log2(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.log2(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Math.log2(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-log2", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Math.sign", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.sign(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.sign(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Math.sign(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-sign", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Math.sinh", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.sinh(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.sinh(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Math.sinh(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-sinh", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Math.tanh", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.tanh(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.tanh(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Math.tanh(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-tanh", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Math.trunc", "Math.*", "runtime"], - valid: [ - { code: "Math.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Math) { Math.trunc(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { code: "Math.trunc(a)", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Math.trunc(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-math-trunc", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Number.isFinite", "Number.*", "runtime"], - valid: [ - { code: "Number.foo(a)", options: [{ version: "0.9.9" }] }, - { - code: "(function(Number) { Number.isFinite(a) }(b))", - options: [{ version: "0.9.9" }], - }, - { - code: "Number.isFinite(a)", - options: [{ version: "0.10.0" }], - }, - ], - invalid: [ - { - code: "Number.isFinite(a)", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-number-isfinite", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Number.isInteger", "Number.*", "runtime"], - valid: [ - { code: "Number.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Number) { Number.isInteger(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { - code: "Number.isInteger(a)", - options: [{ version: "0.12.0" }], - }, - ], - invalid: [ - { - code: "Number.isInteger(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-number-isinteger", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Number.isNaN", "Number.*", "runtime"], - valid: [ - { code: "Number.foo(a)", options: [{ version: "0.9.9" }] }, - { - code: "(function(Number) { Number.isNaN(a) }(b))", - options: [{ version: "0.9.9" }], - }, - { code: "Number.isNaN(a)", options: [{ version: "0.10.0" }] }, - ], - invalid: [ - { - code: "Number.isNaN(a)", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-number-isnan", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Number.isSafeInteger", "Number.*", "runtime"], - valid: [ - { code: "Number.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Number) { Number.isSafeInteger(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { - code: "Number.isSafeInteger(a)", - options: [{ version: "0.12.0" }], - }, - ], - invalid: [ - { - code: "Number.isSafeInteger(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-number-issafeinteger", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Number.parseFloat", "Number.*", "runtime"], - valid: [ - { code: "Number.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Number) { Number.parseFloat(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { - code: "Number.parseFloat(a)", - options: [{ version: "0.12.0" }], - }, - ], - invalid: [ - { - code: "Number.parseFloat(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-number-parsefloat", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Number.parseInt", "Number.*", "runtime"], - valid: [ - { code: "Number.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Number) { Number.parseInt(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { - code: "Number.parseInt(a)", - options: [{ version: "0.12.0" }], - }, - ], - invalid: [ - { - code: "Number.parseInt(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-number-parseint", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Object.assign", "Object.*", "runtime"], - valid: [ - { code: "Object.foo(a)", options: [{ version: "3.9.9" }] }, - { - code: "(function(Object) { Object.assign(a) }(b))", - options: [{ version: "3.9.9" }], - }, - { code: "Object.assign(a)", options: [{ version: "4.0.0" }] }, - ], - invalid: [ - { - code: "Object.assign(a)", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "no-object-assign", - data: { supported: "4.0.0", version: "3.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Object.getOwnPropertySymbols", "Object.*", "runtime"], - valid: [ - { code: "Object.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: - "(function(Object) { Object.getOwnPropertySymbols(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { - code: "Object.getOwnPropertySymbols(a)", - options: [{ version: "0.12.0" }], - }, - ], - invalid: [ - { - code: "Object.getOwnPropertySymbols(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-object-getownpropertysymbols", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Object.is", "Object.*", "runtime"], - valid: [ - { code: "Object.foo(a)", options: [{ version: "0.9.9" }] }, - { - code: "(function(Object) { Object.is(a) }(b))", - options: [{ version: "0.9.9" }], - }, - { code: "Object.is(a)", options: [{ version: "0.10.0" }] }, - ], - invalid: [ - { - code: "Object.is(a)", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-object-is", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Object.setPrototypeOf", "Object.*", "runtime"], - valid: [ - { code: "Object.foo(a)", options: [{ version: "0.11.9" }] }, - { - code: "(function(Object) { Object.setPrototypeOf(a) }(b))", - options: [{ version: "0.11.9" }], - }, - { - code: "Object.setPrototypeOf(a)", - options: [{ version: "0.12.0" }], - }, - ], - invalid: [ - { - code: "Object.setPrototypeOf(a)", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-object-setprototypeof", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Promise", "runtime"], - valid: [ - { - code: "(function(Promise) { Promise }(a))", - options: [{ version: "0.11.9" }], - }, - { code: "Promise", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Promise", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-promise", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - { - code: "function wrap() { Promise }", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-promise", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Proxy", "runtime"], - valid: [ - { - code: "(function(Proxy) { Proxy }(a))", - options: [{ version: "5.9.9" }], - }, - { code: "Proxy", options: [{ version: "6.0.0" }] }, - ], - invalid: [ - { - code: "Proxy", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "no-proxy", - data: { supported: "6.0.0", version: "5.9.9" }, - }, - ], - }, - { - code: "function wrap() { Proxy }", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "no-proxy", - data: { supported: "6.0.0", version: "5.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Reflect", "runtime"], - valid: [ - { - code: "(function(Reflect) { Reflect }(a))", - options: [{ version: "5.9.9" }], - }, - { code: "Reflect", options: [{ version: "6.0.0" }] }, - ], - invalid: [ - { - code: "Reflect", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "no-reflect", - data: { supported: "6.0.0", version: "5.9.9" }, - }, - ], - }, - { - code: "function wrap() { Reflect }", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "no-reflect", - data: { supported: "6.0.0", version: "5.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Set", "runtime"], - valid: [ - { - code: "(function(Set) { Set }(a))", - options: [{ version: "0.11.9" }], - }, - { code: "Set", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Set", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-set", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - { - code: "function wrap() { Set }", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-set", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["String.fromCodePoint", "String.*", "runtime"], - valid: [ - { code: "String.foo(a)", options: [{ version: "3.9.9" }] }, - { - code: "(function(String) { String.fromCodePoint(a) }(b))", - options: [{ version: "3.9.9" }], - }, - { - code: "String.fromCodePoint(a)", - options: [{ version: "4.0.0" }], - }, - ], - invalid: [ - { - code: "String.fromCodePoint(a)", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "no-string-fromcodepoint", - data: { supported: "4.0.0", version: "3.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["String.raw", "String.*", "runtime"], - valid: [ - { code: "String.foo(a)", options: [{ version: "3.9.9" }] }, - { - code: "(function(String) { String.raw(a) }(b))", - options: [{ version: "3.9.9" }], - }, - { code: "String.raw(a)", options: [{ version: "4.0.0" }] }, - ], - invalid: [ - { - code: "String.raw(a)", - options: [{ version: "3.9.9" }], - errors: [ - { - messageId: "no-string-raw", - data: { supported: "4.0.0", version: "3.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["subclassingBuiltins", "runtime"], - valid: [ - { - code: "class A extends Array {}", - options: [{ version: "6.5.0" }], - }, - { - code: "(class extends Array {})", - options: [{ version: "6.5.0" }], - }, - { - code: "class A extends Function {}", - options: [{ version: "6.0.0", ignores: ["classes"] }], - }, - { - code: "(class extends Function {})", - options: [{ version: "6.0.0", ignores: ["classes"] }], - }, - { - code: "class A extends String {}", - options: [{ version: "6.0.0", ignores: ["classes"] }], - }, - { - code: "(class extends String {})", - options: [{ version: "6.0.0", ignores: ["classes"] }], - }, - { - code: "class A extends RegExp {}", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "(class extends RegExp {})", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "class A extends Promise {}", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "(class extends Promise {})", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "class A extends Boolean {}", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "(class extends Boolean {})", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "class A extends Number {}", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "(class extends Number {})", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "class A extends Error {}", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "(class extends Error {})", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "class A extends Map {}", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "(class extends Map {})", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "class A extends Set {}", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "(class extends Set {})", - options: [{ version: "4.0.0", ignores: ["classes"] }], - }, - { - code: "class A extends B {}", - options: [{ version: "3.9.9", ignores: ["classes"] }], - }, - ], - invalid: [ - { - code: "class A extends Array {}", - options: [{ version: "6.4.9" }], - errors: [ - { - messageId: "no-subclassing-builtins-array", - data: { - name: "Array", - supported: "6.5.0", - version: "6.4.9", - }, - }, - ], - }, - { - code: "(class extends Array {})", - options: [{ version: "6.4.9" }], - errors: [ - { - messageId: "no-subclassing-builtins-array", - data: { - name: "Array", - supported: "6.5.0", - version: "6.4.9", - }, - }, - ], - }, - { - code: "class A extends Function {}", - options: [{ version: "5.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: - "no-subclassing-builtins-function-string", - data: { - name: "Function", - supported: "6.0.0", - version: "5.9.9", - }, - }, - ], - }, - { - code: "(class extends Function {})", - options: [{ version: "5.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: - "no-subclassing-builtins-function-string", - data: { - name: "Function", - supported: "6.0.0", - version: "5.9.9", - }, - }, - ], - }, - { - code: "class A extends String {}", - options: [{ version: "5.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: - "no-subclassing-builtins-function-string", - data: { - name: "String", - supported: "6.0.0", - version: "5.9.9", - }, - }, - ], - }, - { - code: "(class extends String {})", - options: [{ version: "5.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: - "no-subclassing-builtins-function-string", - data: { - name: "String", - supported: "6.0.0", - version: "5.9.9", - }, - }, - ], - }, - { - code: "class A extends RegExp {}", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "RegExp", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "(class extends RegExp {})", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "RegExp", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "class A extends Promise {}", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Promise", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "(class extends Promise {})", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Promise", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "class A extends Boolean {}", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Boolean", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "(class extends Boolean {})", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Boolean", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "class A extends Number {}", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Number", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "(class extends Number {})", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Number", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "class A extends Error {}", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Error", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "(class extends Error {})", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Error", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "class A extends Map {}", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Map", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "(class extends Map {})", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Map", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "class A extends Set {}", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Set", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - { - code: "(class extends Set {})", - options: [{ version: "3.9.9", ignores: ["classes"] }], - errors: [ - { - messageId: "no-subclassing-builtins", - data: { - name: "Set", - supported: "4.0.0", - version: "3.9.9", - }, - }, - ], - }, - ], - }, - { - keywords: ["Symbol", "runtime"], - valid: [ - { - code: "(function(Symbol) { Symbol }(a))", - options: [{ version: "0.11.9" }], - }, - { code: "Symbol", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "Symbol", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-symbol", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - { - code: "function wrap() { Symbol }", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-symbol", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["TypedArrays", "runtime"], - valid: [ - { - code: "(function(Int8Array) { Int8Array }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "Int8Array", options: [{ version: "0.10.0" }] }, - { - code: "(function(Uint8Array) { Uint8Array }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "Uint8Array", options: [{ version: "0.10.0" }] }, - { - code: - "(function(Uint8ClampedArray) { Uint8ClampedArray }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "Uint8ClampedArray", options: [{ version: "0.10.0" }] }, - { - code: "(function(Int16Array) { Int16Array }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "Int16Array", options: [{ version: "0.10.0" }] }, - { - code: "(function(Uint16Array) { Uint16Array }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "Uint16Array", options: [{ version: "0.10.0" }] }, - { - code: "(function(Int32Array) { Int32Array }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "Int32Array", options: [{ version: "0.10.0" }] }, - { - code: "(function(Uint32Array) { Uint32Array }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "Uint32Array", options: [{ version: "0.10.0" }] }, - { - code: "(function(Float32Array) { Float32Array }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "Float32Array", options: [{ version: "0.10.0" }] }, - { - code: "(function(Float64Array) { Float64Array }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "Float64Array", options: [{ version: "0.10.0" }] }, - { - code: "(function(DataView) { DataView }(a))", - options: [{ version: "0.9.9" }], - }, - { code: "DataView", options: [{ version: "0.10.0" }] }, - ], - invalid: [ - { - code: "Int8Array", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { Int8Array }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "Uint8Array", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { Uint8Array }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "Uint8ClampedArray", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { Uint8ClampedArray }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "Int16Array", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { Int16Array }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "Uint16Array", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { Uint16Array }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "Int32Array", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { Int32Array }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "Uint32Array", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { Uint32Array }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "Float32Array", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { Float32Array }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "Float64Array", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { Float64Array }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "DataView", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - { - code: "function wrap() { DataView }", - options: [{ version: "0.9.9" }], - errors: [ - { - messageId: "no-typed-arrays", - data: { supported: "0.10.0", version: "0.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["WeakMap", "runtime"], - valid: [ - { - code: "(function(WeakMap) { WeakMap }(a))", - options: [{ version: "0.11.9" }], - }, - { code: "WeakMap", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "WeakMap", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-weak-map", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - { - code: "function wrap() { WeakMap }", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-weak-map", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - { - keywords: ["WeakSet", "runtime"], - valid: [ - { - code: "(function(WeakSet) { WeakSet }(a))", - options: [{ version: "0.11.9" }], - }, - { code: "WeakSet", options: [{ version: "0.12.0" }] }, - ], - invalid: [ - { - code: "WeakSet", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-weak-set", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - { - code: "function wrap() { WeakSet }", - options: [{ version: "0.11.9" }], - errors: [ - { - messageId: "no-weak-set", - data: { supported: "0.12.0", version: "0.11.9" }, - }, - ], - }, - ], - }, - - //---------------------------------------------------------------------- - // ES2016 - //---------------------------------------------------------------------- - { - keywords: ["exponentialOperators", "syntax"], - valid: [ - { - code: "a ** b", - options: [{ version: "7.0.0" }], - }, - { - code: "a **= b", - options: [{ version: "7.0.0" }], - }, - { - code: "a * b", - options: [{ version: "6.9.9" }], - }, - { - code: "a *= b", - options: [{ version: "6.9.9" }], - }, - ], - invalid: [ - { - code: "a ** b", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "no-exponential-operators", - data: { supported: "7.0.0", version: "6.9.9" }, - }, - ], - }, - { - code: "a **= b", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "no-exponential-operators", - data: { supported: "7.0.0", version: "6.9.9" }, - }, - ], - }, - ], - }, - - //---------------------------------------------------------------------- - // ES2017 - //---------------------------------------------------------------------- - { - keywords: ["asyncFunctions", "syntax"], - valid: [ - { - code: "async function f() {}", - options: [{ version: "7.6.0" }], - }, - { - code: "async function f() { await 1 }", - options: [{ version: "7.6.0" }], - }, - { - code: "(async function() { await 1 })", - options: [{ version: "7.6.0" }], - }, - { - code: "(async() => { await 1 })", - options: [{ version: "7.6.0" }], - }, - { - code: "({ async method() { await 1 } })", - options: [{ version: "7.6.0" }], - }, - { - code: "class A { async method() { await 1 } }", - options: [{ version: "7.6.0" }], - }, - { - code: "(class { async method() { await 1 } })", - options: [{ version: "7.6.0" }], - }, - ], - invalid: [ - { - code: "async function f() {}", - options: [{ version: "7.5.9" }], - errors: [ - { - messageId: "no-async-functions", - data: { supported: "7.6.0", version: "7.5.9" }, - }, - ], - }, - { - code: "async function f() { await 1 }", - options: [{ version: "7.5.9" }], - errors: [ - { - messageId: "no-async-functions", - data: { supported: "7.6.0", version: "7.5.9" }, - }, - ], - }, - { - code: "(async function() { await 1 })", - options: [{ version: "7.5.9" }], - errors: [ - { - messageId: "no-async-functions", - data: { supported: "7.6.0", version: "7.5.9" }, - }, - ], - }, - { - code: "(async() => { await 1 })", - options: [{ version: "7.5.9" }], - errors: [ - { - messageId: "no-async-functions", - data: { supported: "7.6.0", version: "7.5.9" }, - }, - ], - }, - { - code: "({ async method() { await 1 } })", - options: [{ version: "7.5.9" }], - errors: [ - { - messageId: "no-async-functions", - data: { supported: "7.6.0", version: "7.5.9" }, - }, - ], - }, - { - code: "class A { async method() { await 1 } }", - options: [{ version: "7.5.9" }], - errors: [ - { - messageId: "no-async-functions", - data: { supported: "7.6.0", version: "7.5.9" }, - }, - ], - }, - { - code: "(class { async method() { await 1 } })", - options: [{ version: "7.5.9" }], - errors: [ - { - messageId: "no-async-functions", - data: { supported: "7.6.0", version: "7.5.9" }, - }, - ], - }, - ], - }, - { - keywords: ["trailingCommasInFunctions", "syntax"], - valid: [ - { - code: "function f(a,) {}", - options: [{ version: "8.0.0" }], - }, - { - code: "(function(a,) {})", - options: [{ version: "8.0.0" }], - }, - { - code: "((a,) => {})", - options: [{ version: "8.0.0" }], - }, - { - code: "({ method(a,) {} })", - options: [{ version: "8.0.0" }], - }, - { - code: "class A { method(a,) {} }", - options: [{ version: "8.0.0" }], - }, - { - code: "(class { method(a,) {} })", - options: [{ version: "8.0.0" }], - }, - { - code: "f(1,)", - options: [{ version: "8.0.0" }], - }, - { - code: "new A(1,)", - options: [{ version: "8.0.0" }], - }, - ], - invalid: [ - { - code: "function f(a,) {}", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "no-trailing-function-commas", - data: { supported: "8.0.0", version: "7.9.9" }, - }, - ], - }, - { - code: "(function(a,) {})", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "no-trailing-function-commas", - data: { supported: "8.0.0", version: "7.9.9" }, + messageId: "no-trailing-function-commas", + data: { supported: "8.0.0", version: "7.9.9" }, }, ], }, @@ -3555,154 +1878,12 @@ ruleTester.run( }, ], }, - { - keywords: ["Atomics", "runtime"], - valid: [ - { - code: "(function(Atomics) { Atomics }(a))", - options: [{ version: "8.9.9" }], - }, - { code: "Atomics", options: [{ version: "8.10.0" }] }, - ], - invalid: [ - { - code: "Atomics", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "no-atomics", - data: { supported: "8.10.0", version: "8.9.9" }, - }, - ], - }, - { - code: "function wrap() { Atomics }", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "no-atomics", - data: { supported: "8.10.0", version: "8.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Object.values", "Object.*", "runtime"], - valid: [ - { code: "Object.foo(a)", options: [{ version: "6.9.9" }] }, - { - code: "(function(Object) { Object.values(a) }(b))", - options: [{ version: "6.9.9" }], - }, - { code: "Object.values(a)", options: [{ version: "7.0.0" }] }, - ], - invalid: [ - { - code: "Object.values(a)", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "no-object-values", - data: { supported: "7.0.0", version: "6.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["Object.entries", "Object.*", "runtime"], - valid: [ - { code: "Object.foo(a)", options: [{ version: "6.9.9" }] }, - { - code: "(function(Object) { Object.entries(a) }(b))", - options: [{ version: "6.9.9" }], - }, - { code: "Object.entries(a)", options: [{ version: "7.0.0" }] }, - ], - invalid: [ - { - code: "Object.entries(a)", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "no-object-entries", - data: { supported: "7.0.0", version: "6.9.9" }, - }, - ], - }, - ], - }, - { - keywords: [ - "Object.getOwnPropertyDescriptors", - "Object.*", - "runtime", - ], - valid: [ - { code: "Object.foo(a)", options: [{ version: "6.9.9" }] }, - { - code: - "(function(Object) { Object.getOwnPropertyDescriptors(a) }(b))", - options: [{ version: "6.9.9" }], - }, - { - code: "Object.getOwnPropertyDescriptors(a)", - options: [{ version: "7.0.0" }], - }, - ], - invalid: [ - { - code: "Object.getOwnPropertyDescriptors(a)", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "no-object-getownpropertydescriptors", - data: { supported: "7.0.0", version: "6.9.9" }, - }, - ], - }, - ], - }, - { - keywords: ["SharedArrayBuffer", "runtime"], - valid: [ - { - code: - "(function(SharedArrayBuffer) { SharedArrayBuffer }(a))", - options: [{ version: "8.9.9" }], - }, - { code: "SharedArrayBuffer", options: [{ version: "8.10.0" }] }, - ], - invalid: [ - { - code: "SharedArrayBuffer", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "no-shared-array-buffer", - data: { supported: "8.10.0", version: "8.9.9" }, - }, - ], - }, - { - code: "function wrap() { SharedArrayBuffer }", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "no-shared-array-buffer", - data: { supported: "8.10.0", version: "8.9.9" }, - }, - ], - }, - ], - }, //---------------------------------------------------------------------- // ES2018 //---------------------------------------------------------------------- { - keywords: ["asyncIteration", "syntax"], + keyword: "asyncIteration", valid: [ { code: "async function f() { for await (const x of xs) {} }", @@ -3805,7 +1986,7 @@ ruleTester.run( ], }, { - keywords: ["malformedTemplateLiterals", "syntax"], + keyword: "malformedTemplateLiterals", valid: [ { code: "tag`\\unicode`", @@ -3826,7 +2007,7 @@ ruleTester.run( ], }, { - keywords: ["regexpLookbehind", "syntax"], + keyword: "regexpLookbehind", valid: [ { code: "var a = /(?<=a)foo/", @@ -3887,7 +2068,7 @@ ruleTester.run( ], }, { - keywords: ["regexpNamedCaptureGroups", "syntax"], + keyword: "regexpNamedCaptureGroups", valid: [ { code: "var a = /(?a)foo/", @@ -3948,7 +2129,7 @@ ruleTester.run( ], }, { - keywords: ["regexpS", "syntax"], + keyword: "regexpS", valid: [ { code: "var a = /foo/s", @@ -3991,7 +2172,7 @@ ruleTester.run( ], }, { - keywords: ["regexpUnicodeProperties", "syntax"], + keyword: "regexpUnicodeProperties", valid: [ { code: "var a = /\\p{Letter}/u", @@ -4052,7 +2233,7 @@ ruleTester.run( ], }, { - keywords: ["restSpreadProperties", "syntax"], + keyword: "restSpreadProperties", valid: [ { code: "({ ...obj })", diff --git a/tests/lib/rules/no-unsupported-features/fs.js b/tests/lib/rules/no-unsupported-features/fs.js deleted file mode 100644 index d3665fd8..00000000 --- a/tests/lib/rules/no-unsupported-features/fs.js +++ /dev/null @@ -1,269 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/fs") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/fs", rule, { - valid: [ - { - code: "require('fs').promises", - options: [{ version: "10.1.0" }], - }, - { - code: "var fs = require('fs'); fs.promises", - options: [{ version: "10.1.0" }], - }, - { - code: "var { promises } = require('fs'); promises", - options: [{ version: "10.1.0" }], - }, - { - code: "import fs from 'fs'; fs.promises", - options: [{ version: "10.1.0" }], - }, - { - code: "import { promises } from 'fs'", - options: [{ version: "10.1.0" }], - }, - { - code: "require('fs').copyFile", - options: [{ version: "8.5.0" }], - }, - { - code: "require('fs').copyFileSync", - options: [{ version: "8.5.0" }], - }, - { - code: "require('fs').mkdtemp", - options: [{ version: "5.10.0" }], - }, - { - code: "require('fs').mkdtempSync", - options: [{ version: "5.10.0" }], - }, - { - code: "require('fs').realpath.native", - options: [{ version: "9.2.0" }], - }, - { - code: "require('fs').realpathSync.native", - options: [{ version: "9.2.0" }], - }, - - // Ignores - { - code: "require('fs').promises", - options: [{ version: "10.0.9", ignores: ["fs.promises"] }], - }, - { - code: "var fs = require('fs'); fs.promises", - options: [{ version: "10.0.9", ignores: ["fs.promises"] }], - }, - { - code: "var { promises } = require('fs'); promises", - options: [{ version: "10.0.9", ignores: ["fs.promises"] }], - }, - { - code: "import fs from 'fs'; fs.promises", - options: [{ version: "10.0.9", ignores: ["fs.promises"] }], - }, - { - code: "import { promises } from 'fs'", - options: [{ version: "10.0.9", ignores: ["fs.promises"] }], - }, - { - code: "require('fs').copyFile", - options: [{ version: "8.4.9", ignores: ["fs.copyFile"] }], - }, - { - code: "require('fs').copyFileSync", - options: [{ version: "8.4.9", ignores: ["fs.copyFileSync"] }], - }, - { - code: "require('fs').mkdtemp", - options: [{ version: "5.9.9", ignores: ["fs.mkdtemp"] }], - }, - { - code: "require('fs').mkdtempSync", - options: [{ version: "5.9.9", ignores: ["fs.mkdtempSync"] }], - }, - { - code: "require('fs').realpath.native", - options: [{ version: "9.1.9", ignores: ["fs.realpath.native"] }], - }, - { - code: "require('fs').realpathSync.native", - options: [ - { version: "9.1.9", ignores: ["fs.realpathSync.native"] }, - ], - }, - ], - invalid: [ - { - code: "require('fs').promises", - options: [{ version: "10.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.promises", - supported: "10.1.0", - version: "10.0.9", - }, - }, - ], - }, - { - code: "var fs = require('fs'); fs.promises", - options: [{ version: "10.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.promises", - supported: "10.1.0", - version: "10.0.9", - }, - }, - ], - }, - { - code: "var { promises } = require('fs'); promises", - options: [{ version: "10.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.promises", - supported: "10.1.0", - version: "10.0.9", - }, - }, - ], - }, - { - code: "import fs from 'fs'; fs.promises", - options: [{ version: "10.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.promises", - supported: "10.1.0", - version: "10.0.9", - }, - }, - ], - }, - { - code: "import { promises } from 'fs'", - options: [{ version: "10.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.promises", - supported: "10.1.0", - version: "10.0.9", - }, - }, - ], - }, - { - code: "require('fs').copyFile", - options: [{ version: "8.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.copyFile", - supported: "8.5.0", - version: "8.4.9", - }, - }, - ], - }, - { - code: "require('fs').copyFileSync", - options: [{ version: "8.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.copyFileSync", - supported: "8.5.0", - version: "8.4.9", - }, - }, - ], - }, - { - code: "require('fs').mkdtemp", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.mkdtemp", - supported: "5.10.0", - version: "5.9.9", - }, - }, - ], - }, - { - code: "require('fs').mkdtempSync", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.mkdtempSync", - supported: "5.10.0", - version: "5.9.9", - }, - }, - ], - }, - { - code: "require('fs').realpath.native", - options: [{ version: "9.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.realpath.native", - supported: "9.2.0", - version: "9.1.9", - }, - }, - ], - }, - { - code: "require('fs').realpathSync.native", - options: [{ version: "9.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "fs.realpathSync.native", - supported: "9.2.0", - version: "9.1.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/http2.js b/tests/lib/rules/no-unsupported-features/http2.js deleted file mode 100644 index 668b543b..00000000 --- a/tests/lib/rules/no-unsupported-features/http2.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/http2") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/http2", rule, { - valid: [ - { - code: "require('http2')", - options: [{ version: "8.4.0" }], - }, - { - code: "import http2 from 'http2'", - options: [{ version: "8.4.0" }], - }, - { - code: "require('http2')", - options: [{ version: "8.3.9", ignores: ["http2"] }], - }, - { - code: "import http2 from 'http2'", - options: [{ version: "8.3.9", ignores: ["http2"] }], - }, - ], - invalid: [ - { - code: "require('http2')", - options: [{ version: "8.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "http2", - supported: "8.4.0", - version: "8.3.9", - }, - }, - ], - }, - { - code: "import http2 from 'http2'", - options: [{ version: "8.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "http2", - supported: "8.4.0", - version: "8.3.9", - }, - }, - ], - }, - { - code: "import { createServer } from 'http2'", - options: [{ version: "8.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "http2", - supported: "8.4.0", - version: "8.3.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/inspector.js b/tests/lib/rules/no-unsupported-features/inspector.js deleted file mode 100644 index 5ce1eb44..00000000 --- a/tests/lib/rules/no-unsupported-features/inspector.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/inspector") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/inspector", rule, { - valid: [ - { - code: "require('inspector')", - options: [{ version: "8.0.0" }], - }, - { - code: "import inspector from 'inspector'", - options: [{ version: "8.0.0" }], - }, - { - code: "require('inspector')", - options: [{ version: "7.9.9", ignores: ["inspector"] }], - }, - { - code: "import inspector from 'inspector'", - options: [{ version: "7.9.9", ignores: ["inspector"] }], - }, - ], - invalid: [ - { - code: "require('inspector')", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "inspector", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "import inspector from 'inspector'", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "inspector", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "import { open } from 'inspector'", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "inspector", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/module.js b/tests/lib/rules/no-unsupported-features/module.js deleted file mode 100644 index 0a610902..00000000 --- a/tests/lib/rules/no-unsupported-features/module.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/module") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/module", rule, { - valid: [ - { - code: "require.resolve.paths()", - options: [{ version: "8.9.0" }], - }, - { - code: "require('module').builtinModules", - options: [{ version: "9.3.0" }], - }, - { - code: "require.resolve.paths()", - options: [{ version: "8.8.9", ignores: ["require.resolve.paths"] }], - }, - { - code: "require('module').builtinModules", - options: [{ version: "9.2.9", ignores: ["module.builtinModules"] }], - }, - ], - invalid: [ - { - code: "require.resolve.paths()", - options: [{ version: "8.8.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "require.resolve.paths", - supported: "8.9.0", - version: "8.8.9", - }, - }, - ], - }, - { - code: "require('module').builtinModules", - options: [{ version: "9.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "module.builtinModules", - supported: "9.3.0", - version: "9.2.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/node-builtins.js b/tests/lib/rules/no-unsupported-features/node-builtins.js new file mode 100644 index 00000000..e583052a --- /dev/null +++ b/tests/lib/rules/no-unsupported-features/node-builtins.js @@ -0,0 +1,4970 @@ +/** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */ +"use strict" + +const RuleTester = require("eslint").RuleTester +const rule = require("../../../../lib/rules/no-unsupported-features/node-builtins") + +/** + * Concatenate patterns. + * @param {Array<{valid:Array,invalid:Array}>} patterns The patterns to concat. + * @returns {{valid:Array,invalid:Array}} The concatenated patterns. + */ +function concat(patterns) { + const ret = { + valid: [], + invalid: [], + } + + for (const { valid, invalid } of patterns) { + ret.valid.push(...valid) + ret.invalid.push(...invalid) + } + + return ret +} + +new RuleTester({ + parserOptions: { + ecmaVersion: 2015, + sourceType: "module", + }, + globals: { + Buffer: false, + URL: false, + URLSearchParams: false, + console: false, + process: false, + require: false, + }, +}).run( + "no-unsupported-features/node-builtins", + rule, + concat([ + //---------------------------------------------------------------------- + // assert + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('assert').strictEqual()", + options: [{ version: "0.12.0" }], + }, + { + code: + "var assert = require('assert'); assert(); assert.strictEqual()", + options: [{ version: "0.12.0" }], + }, + { + code: "require('assert').deepStrictEqual()", + options: [{ version: "4.0.0" }], + }, + { + code: + "var assert = require('assert'); assert.deepStrictEqual()", + options: [{ version: "4.0.0" }], + }, + { + code: + "var { deepStrictEqual } = require('assert'); deepStrictEqual()", + options: [{ version: "4.0.0" }], + }, + { + code: + "import assert from 'assert'; assert.deepStrictEqual()", + options: [{ version: "4.0.0" }], + }, + { + code: + "import { deepStrictEqual } from 'assert'; deepStrictEqual()", + options: [{ version: "4.0.0" }], + }, + { + code: "require('assert').notDeepStrictEqual()", + options: [{ version: "4.0.0" }], + }, + { + code: "require('assert').rejects()", + options: [{ version: "10.0.0" }], + }, + { + code: "require('assert').doesNotReject()", + options: [{ version: "10.0.0" }], + }, + { + code: "require('assert').strict.rejects()", + options: [{ version: "10.0.0" }], + }, + { + code: "require('assert').strict.doesNotReject()", + options: [{ version: "10.0.0" }], + }, + { + code: "var assert = require('assert').strict", + options: [{ version: "9.9.0" }], + }, + { + code: + "var {strict: assert} = require('assert'); assert.rejects()", + options: [{ version: "10.0.0" }], + }, + { + code: "require('assert').deepStrictEqual()", + options: [ + { + version: "3.9.9", + ignores: ["assert.deepStrictEqual"], + }, + ], + }, + { + code: + "var assert = require('assert'); assert.deepStrictEqual()", + options: [ + { + version: "3.9.9", + ignores: ["assert.deepStrictEqual"], + }, + ], + }, + { + code: + "var { deepStrictEqual } = require('assert'); deepStrictEqual()", + options: [ + { + version: "3.9.9", + ignores: ["assert.deepStrictEqual"], + }, + ], + }, + { + code: + "import assert from 'assert'; assert.deepStrictEqual()", + options: [ + { + version: "3.9.9", + ignores: ["assert.deepStrictEqual"], + }, + ], + }, + { + code: + "import { deepStrictEqual } from 'assert'; deepStrictEqual()", + options: [ + { + version: "3.9.9", + ignores: ["assert.deepStrictEqual"], + }, + ], + }, + { + code: "require('assert').notDeepStrictEqual()", + options: [ + { + version: "3.9.9", + ignores: ["assert.notDeepStrictEqual"], + }, + ], + }, + { + code: "require('assert').rejects()", + options: [ + { version: "9.9.9", ignores: ["assert.rejects"] }, + ], + }, + { + code: "require('assert').doesNotReject()", + options: [ + { version: "9.9.9", ignores: ["assert.doesNotReject"] }, + ], + }, + { + code: "require('assert').strict.rejects()", + options: [ + { + version: "9.9.9", + ignores: ["assert.strict.rejects"], + }, + ], + }, + { + code: "require('assert').strict.doesNotReject()", + options: [ + { + version: "9.9.9", + ignores: ["assert.strict.doesNotReject"], + }, + ], + }, + { + code: "var assert = require('assert').strict", + options: [{ version: "9.8.9", ignores: ["assert.strict"] }], + }, + { + code: + "var {strict: assert} = require('assert'); assert.rejects()", + options: [ + { + version: "9.8.9", + ignores: ["assert.strict", "assert.strict.rejects"], + }, + ], + }, + ], + invalid: [ + { + code: "require('assert').deepStrictEqual()", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.deepStrictEqual", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + { + code: + "var assert = require('assert'); assert.deepStrictEqual()", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.deepStrictEqual", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + { + code: + "var { deepStrictEqual } = require('assert'); deepStrictEqual()", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.deepStrictEqual", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + { + code: + "import assert from 'assert'; assert.deepStrictEqual()", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.deepStrictEqual", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + { + code: + "import { deepStrictEqual } from 'assert'; deepStrictEqual()", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.deepStrictEqual", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + { + code: "require('assert').notDeepStrictEqual()", + options: [{ version: "3.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.notDeepStrictEqual", + supported: "4.0.0", + version: "3.9.9", + }, + }, + ], + }, + { + code: "require('assert').rejects()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.rejects", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "require('assert').doesNotReject()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.doesNotReject", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "require('assert').strict.rejects()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.strict.rejects", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "require('assert').strict.doesNotReject()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.strict.doesNotReject", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "var assert = require('assert').strict", + options: [{ version: "9.8.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.strict", + supported: "9.9.0", + version: "9.8.9", + }, + }, + ], + }, + { + code: + "var {strict: assert} = require('assert'); assert.rejects()", + options: [{ version: "9.8.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "assert.strict", + supported: "9.9.0", + version: "9.8.9", + }, + }, + { + messageId: "unsupported", + data: { + name: "assert.strict.rejects", + supported: "10.0.0", + version: "9.8.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // async_hooks + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('async_hooks')", + options: [{ version: "8.0.0" }], + }, + { + code: "import hooks from 'async_hooks'", + options: [{ version: "8.0.0" }], + }, + { + code: "require('async_hooks').createHook()", + options: [{ version: "8.1.0" }], + }, + { + code: + "var hooks = require('async_hooks'); hooks.createHook()", + options: [{ version: "8.1.0" }], + }, + { + code: + "var { createHook } = require('async_hooks'); createHook()", + options: [{ version: "8.1.0" }], + }, + { + code: "import hooks from 'async_hooks'; hooks.createHook()", + options: [{ version: "8.1.0" }], + }, + { + code: + "import { createHook } from 'async_hooks'; createHook()", + options: [{ version: "8.1.0" }], + }, + + // Ignores + { + code: "require('async_hooks')", + options: [{ version: "7.9.9", ignores: ["async_hooks"] }], + }, + { + code: "import hooks from 'async_hooks'", + options: [{ version: "7.9.9", ignores: ["async_hooks"] }], + }, + { + code: "import { createHook } from 'async_hooks'", + options: [ + { + version: "7.9.9", + ignores: ["async_hooks", "async_hooks.createHook"], + }, + ], + }, + { + code: "require('async_hooks').createHook()", + options: [ + { + version: "8.0.9", + ignores: ["async_hooks.createHook"], + }, + ], + }, + { + code: + "var hooks = require('async_hooks'); hooks.createHook()", + options: [ + { + version: "8.0.9", + ignores: ["async_hooks.createHook"], + }, + ], + }, + { + code: + "var { createHook } = require('async_hooks'); createHook()", + options: [ + { + version: "8.0.9", + ignores: ["async_hooks.createHook"], + }, + ], + }, + { + code: + "import async_hooks from 'async_hooks'; async_hooks.createHook()", + options: [ + { + version: "8.0.9", + ignores: ["async_hooks.createHook"], + }, + ], + }, + { + code: + "import { createHook } from 'async_hooks'; createHook()", + options: [ + { + version: "8.0.9", + ignores: ["async_hooks.createHook"], + }, + ], + }, + ], + invalid: [ + { + code: "require('async_hooks')", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "async_hooks", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "import hooks from 'async_hooks'", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "async_hooks", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "import { createHook } from 'async_hooks'", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "async_hooks", + supported: "8.0.0", + version: "7.9.9", + }, + }, + { + messageId: "unsupported", + data: { + name: "async_hooks.createHook", + supported: "8.1.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('async_hooks').createHook()", + options: [{ version: "8.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "async_hooks.createHook", + supported: "8.1.0", + version: "8.0.9", + }, + }, + ], + }, + { + code: + "var hooks = require('async_hooks'); hooks.createHook()", + options: [{ version: "8.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "async_hooks.createHook", + supported: "8.1.0", + version: "8.0.9", + }, + }, + ], + }, + { + code: + "var { createHook } = require('async_hooks'); createHook()", + options: [{ version: "8.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "async_hooks.createHook", + supported: "8.1.0", + version: "8.0.9", + }, + }, + ], + }, + { + code: + "import async_hooks from 'async_hooks'; async_hooks.createHook()", + options: [{ version: "8.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "async_hooks.createHook", + supported: "8.1.0", + version: "8.0.9", + }, + }, + ], + }, + { + code: + "import { createHook } from 'async_hooks'; createHook()", + options: [{ version: "8.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "async_hooks.createHook", + supported: "8.1.0", + version: "8.0.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // buffer + //---------------------------------------------------------------------- + { + valid: [ + { + code: "Buffer.alloc", + options: [{ version: "4.5.0" }], + }, + { + code: "Buffer.allocUnsafe", + options: [{ version: "4.5.0" }], + }, + { + code: "Buffer.allocUnsafeSlow", + options: [{ version: "4.5.0" }], + }, + { + code: "Buffer.from", + options: [{ version: "4.5.0" }], + }, + { + code: "require('buffer').constants", + options: [{ version: "8.2.0" }], + }, + { + code: "var cp = require('buffer'); cp.constants", + options: [{ version: "8.2.0" }], + }, + { + code: "var { constants } = require('buffer');", + options: [{ version: "8.2.0" }], + }, + { + code: "import cp from 'buffer'; cp.constants", + options: [{ version: "8.2.0" }], + }, + { + code: "import { constants } from 'buffer'", + options: [{ version: "8.2.0" }], + }, + { + code: "var {Buffer: b} = require('buffer'); b.alloc", + options: [{ version: "4.5.0" }], + }, + { + code: "var {Buffer: b} = require('buffer'); b.allocUnsafe", + options: [{ version: "4.5.0" }], + }, + { + code: + "var {Buffer: b} = require('buffer'); b.allocUnsafeSlow", + options: [{ version: "4.5.0" }], + }, + { + code: "var {Buffer: b} = require('buffer'); b.from", + options: [{ version: "4.5.0" }], + }, + { + code: "require('buffer').kMaxLength", + options: [{ version: "3.0.0" }], + }, + { + code: "require('buffer').transcode", + options: [{ version: "7.1.0" }], + }, + + // Ignores + { + code: "Buffer.alloc", + options: [{ version: "4.4.9", ignores: ["Buffer.alloc"] }], + }, + { + code: "Buffer.allocUnsafe", + options: [ + { version: "4.4.9", ignores: ["Buffer.allocUnsafe"] }, + ], + }, + { + code: "Buffer.allocUnsafeSlow", + options: [ + { + version: "4.4.9", + ignores: ["Buffer.allocUnsafeSlow"], + }, + ], + }, + { + code: "Buffer.from", + options: [{ version: "4.4.9", ignores: ["Buffer.from"] }], + }, + { + code: "require('buffer').constants", + options: [ + { version: "8.1.9", ignores: ["buffer.constants"] }, + ], + }, + { + code: "var cp = require('buffer'); cp.constants", + options: [ + { version: "8.1.9", ignores: ["buffer.constants"] }, + ], + }, + { + code: "var { constants } = require('buffer');", + options: [ + { version: "8.1.9", ignores: ["buffer.constants"] }, + ], + }, + { + code: "import cp from 'buffer'; cp.constants", + options: [ + { version: "8.1.9", ignores: ["buffer.constants"] }, + ], + }, + { + code: "import { constants } from 'buffer'", + options: [ + { version: "8.1.9", ignores: ["buffer.constants"] }, + ], + }, + { + code: "var {Buffer: b} = require('buffer'); b.alloc", + options: [ + { version: "4.4.9", ignores: ["buffer.Buffer.alloc"] }, + ], + }, + { + code: "var {Buffer: b} = require('buffer'); b.allocUnsafe", + options: [ + { + version: "4.4.9", + ignores: ["buffer.Buffer.allocUnsafe"], + }, + ], + }, + { + code: + "var {Buffer: b} = require('buffer'); b.allocUnsafeSlow", + options: [ + { + version: "4.4.9", + ignores: ["buffer.Buffer.allocUnsafeSlow"], + }, + ], + }, + { + code: "var {Buffer: b} = require('buffer'); b.from", + options: [ + { version: "4.4.9", ignores: ["buffer.Buffer.from"] }, + ], + }, + { + code: "require('buffer').kMaxLength", + options: [ + { version: "2.9.9", ignores: ["buffer.kMaxLength"] }, + ], + }, + { + code: "require('buffer').transcode", + options: [ + { version: "7.0.9", ignores: ["buffer.transcode"] }, + ], + }, + ], + invalid: [ + { + code: "Buffer.alloc", + options: [{ version: "4.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Buffer.alloc", + supported: "4.5.0", + version: "4.4.9", + }, + }, + ], + }, + { + code: "Buffer.allocUnsafe", + options: [{ version: "4.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Buffer.allocUnsafe", + supported: "4.5.0", + version: "4.4.9", + }, + }, + ], + }, + { + code: "Buffer.allocUnsafeSlow", + options: [{ version: "4.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Buffer.allocUnsafeSlow", + supported: "4.5.0", + version: "4.4.9", + }, + }, + ], + }, + { + code: "Buffer.from", + options: [{ version: "4.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "Buffer.from", + supported: "4.5.0", + version: "4.4.9", + }, + }, + ], + }, + { + code: "require('buffer').constants", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.constants", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "var cp = require('buffer'); cp.constants", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.constants", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "var { constants } = require('buffer');", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.constants", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "import cp from 'buffer'; cp.constants", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.constants", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "import { constants } from 'buffer'", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.constants", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "var {Buffer: b} = require('buffer'); b.alloc", + options: [{ version: "4.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.Buffer.alloc", + supported: "4.5.0", + version: "4.4.9", + }, + }, + ], + }, + { + code: "var {Buffer: b} = require('buffer'); b.allocUnsafe", + options: [{ version: "4.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.Buffer.allocUnsafe", + supported: "4.5.0", + version: "4.4.9", + }, + }, + ], + }, + { + code: + "var {Buffer: b} = require('buffer'); b.allocUnsafeSlow", + options: [{ version: "4.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.Buffer.allocUnsafeSlow", + supported: "4.5.0", + version: "4.4.9", + }, + }, + ], + }, + { + code: "var {Buffer: b} = require('buffer'); b.from", + options: [{ version: "4.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.Buffer.from", + supported: "4.5.0", + version: "4.4.9", + }, + }, + ], + }, + { + code: "require('buffer').kMaxLength", + options: [{ version: "2.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.kMaxLength", + supported: "3.0.0", + version: "2.9.9", + }, + }, + ], + }, + { + code: "require('buffer').transcode", + options: [{ version: "7.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "buffer.transcode", + supported: "7.1.0", + version: "7.0.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // child_process + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('child_process').ChildProcess", + options: [{ version: "2.2.0" }], + }, + { + code: "var cp = require('child_process'); cp.ChildProcess", + options: [{ version: "2.2.0" }], + }, + { + code: + "var { ChildProcess } = require('child_process'); ChildProcess", + options: [{ version: "2.2.0" }], + }, + { + code: "import cp from 'child_process'; cp.ChildProcess", + options: [{ version: "2.2.0" }], + }, + { + code: "import { ChildProcess } from 'child_process'", + options: [{ version: "2.2.0" }], + }, + + // Ignores. + { + code: "require('child_process').ChildProcess", + options: [ + { + version: "2.1.9", + ignores: ["child_process.ChildProcess"], + }, + ], + }, + { + code: "var cp = require('child_process'); cp.ChildProcess", + options: [ + { + version: "2.1.9", + ignores: ["child_process.ChildProcess"], + }, + ], + }, + { + code: + "var { ChildProcess } = require('child_process'); ChildProcess", + options: [ + { + version: "2.1.9", + ignores: ["child_process.ChildProcess"], + }, + ], + }, + { + code: "import cp from 'child_process'; cp.ChildProcess", + options: [ + { + version: "2.1.9", + ignores: ["child_process.ChildProcess"], + }, + ], + }, + { + code: "import { ChildProcess } from 'child_process'", + options: [ + { + version: "2.1.9", + ignores: ["child_process.ChildProcess"], + }, + ], + }, + ], + invalid: [ + { + code: "require('child_process').ChildProcess", + options: [{ version: "2.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "child_process.ChildProcess", + supported: "2.2.0", + version: "2.1.9", + }, + }, + ], + }, + { + code: "var cp = require('child_process'); cp.ChildProcess", + options: [{ version: "2.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "child_process.ChildProcess", + supported: "2.2.0", + version: "2.1.9", + }, + }, + ], + }, + { + code: + "var { ChildProcess } = require('child_process'); ChildProcess", + options: [{ version: "2.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "child_process.ChildProcess", + supported: "2.2.0", + version: "2.1.9", + }, + }, + ], + }, + { + code: "import cp from 'child_process'; cp.ChildProcess", + options: [{ version: "2.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "child_process.ChildProcess", + supported: "2.2.0", + version: "2.1.9", + }, + }, + ], + }, + { + code: "import { ChildProcess } from 'child_process'", + options: [{ version: "2.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "child_process.ChildProcess", + supported: "2.2.0", + version: "2.1.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // console + //---------------------------------------------------------------------- + { + valid: [ + { + code: "console.clear()", + options: [{ version: "8.3.0" }], + }, + { + code: "require('console').clear()", + options: [{ version: "8.3.0" }], + }, + { + code: "var c = require('console'); c.clear()", + options: [{ version: "8.3.0" }], + }, + { + code: "var { clear } = require('console'); clear()", + options: [{ version: "8.3.0" }], + }, + { + code: "import c from 'console'; c.clear()", + options: [{ version: "8.3.0" }], + }, + { + code: "console.count()", + options: [{ version: "8.3.0" }], + }, + { + code: "console.countReset()", + options: [{ version: "8.3.0" }], + }, + { + code: "console.debug()", + options: [{ version: "8.0.0" }], + }, + { + code: "console.dirxml()", + options: [{ version: "8.0.0" }], + }, + { + code: "console.group()", + options: [{ version: "8.5.0" }], + }, + { + code: "console.groupCollapsed()", + options: [{ version: "8.5.0" }], + }, + { + code: "console.groupEnd()", + options: [{ version: "8.5.0" }], + }, + { + code: "console.table()", + options: [{ version: "10.0.0" }], + }, + { + code: "console.markTimeline()", + options: [{ version: "8.0.0" }], + }, + { + code: "console.profile()", + options: [{ version: "8.0.0" }], + }, + { + code: "console.profileEnd()", + options: [{ version: "8.0.0" }], + }, + { + code: "console.timeStamp()", + options: [{ version: "8.0.0" }], + }, + { + code: "console.timeline()", + options: [{ version: "8.0.0" }], + }, + { + code: "console.timelineEnd()", + options: [{ version: "8.0.0" }], + }, + + // Ignores. + { + code: "console.clear()", + options: [{ version: "8.2.9", ignores: ["console.clear"] }], + }, + { + code: "require('console').clear()", + options: [{ version: "8.2.9", ignores: ["console.clear"] }], + }, + { + code: "var c = require('console'); c.clear()", + options: [{ version: "8.2.9", ignores: ["console.clear"] }], + }, + { + code: "var { clear } = require('console'); clear()", + options: [{ version: "8.2.9", ignores: ["console.clear"] }], + }, + { + code: "import c from 'console'; c.clear()", + options: [{ version: "8.2.9", ignores: ["console.clear"] }], + }, + { + code: "console.count()", + options: [{ version: "8.2.9", ignores: ["console.count"] }], + }, + { + code: "console.countReset()", + options: [ + { version: "8.2.9", ignores: ["console.countReset"] }, + ], + }, + { + code: "console.debug()", + options: [{ version: "7.9.9", ignores: ["console.debug"] }], + }, + { + code: "console.dirxml()", + options: [ + { version: "7.9.9", ignores: ["console.dirxml"] }, + ], + }, + { + code: "console.group()", + options: [{ version: "8.4.9", ignores: ["console.group"] }], + }, + { + code: "console.groupCollapsed()", + options: [ + { + version: "8.4.9", + ignores: ["console.groupCollapsed"], + }, + ], + }, + { + code: "console.groupEnd()", + options: [ + { version: "8.4.9", ignores: ["console.groupEnd"] }, + ], + }, + { + code: "console.table()", + options: [{ version: "9.9.9", ignores: ["console.table"] }], + }, + { + code: "console.markTimeline()", + options: [ + { version: "7.9.9", ignores: ["console.markTimeline"] }, + ], + }, + { + code: "console.profile()", + options: [ + { version: "7.9.9", ignores: ["console.profile"] }, + ], + }, + { + code: "console.profileEnd()", + options: [ + { version: "7.9.9", ignores: ["console.profileEnd"] }, + ], + }, + { + code: "console.timeStamp()", + options: [ + { version: "7.9.9", ignores: ["console.timeStamp"] }, + ], + }, + { + code: "console.timeline()", + options: [ + { version: "7.9.9", ignores: ["console.timeline"] }, + ], + }, + { + code: "console.timelineEnd()", + options: [ + { version: "7.9.9", ignores: ["console.timelineEnd"] }, + ], + }, + ], + invalid: [ + { + code: "console.clear()", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.clear", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "require('console').clear()", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.clear", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "var c = require('console'); c.clear()", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.clear", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "var { clear } = require('console'); clear()", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.clear", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "import c from 'console'; c.clear()", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.clear", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "console.count()", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.count", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "console.countReset()", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.countReset", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "console.debug()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.debug", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "console.dirxml()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.dirxml", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "console.group()", + options: [{ version: "8.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.group", + supported: "8.5.0", + version: "8.4.9", + }, + }, + ], + }, + { + code: "console.groupCollapsed()", + options: [{ version: "8.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.groupCollapsed", + supported: "8.5.0", + version: "8.4.9", + }, + }, + ], + }, + { + code: "console.groupEnd()", + options: [{ version: "8.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.groupEnd", + supported: "8.5.0", + version: "8.4.9", + }, + }, + ], + }, + { + code: "console.table()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.table", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "console.markTimeline()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.markTimeline", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "console.profile()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.profile", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "console.profileEnd()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.profileEnd", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "console.timeStamp()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.timeStamp", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "console.timeline()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.timeline", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "console.timelineEnd()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "console.timelineEnd", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // crypto + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('crypto').constants", + options: [{ version: "6.3.0" }], + }, + { + code: "var hooks = require('crypto'); hooks.constants", + options: [{ version: "6.3.0" }], + }, + { + code: "var { constants } = require('crypto'); constants", + options: [{ version: "6.3.0" }], + }, + { + code: "import crypto from 'crypto'; crypto.constants", + options: [{ version: "6.3.0" }], + }, + { + code: "import { constants } from 'crypto'; constants", + options: [{ version: "6.3.0" }], + }, + { + code: "require('crypto').Certificate.exportChallenge()", + options: [{ version: "9.0.0" }], + }, + { + code: + "var { Certificate: c } = require('crypto'); c.exportChallenge()", + options: [{ version: "9.0.0" }], + }, + { + code: + "var { Certificate: c } = require('crypto'); c.exportPublicKey()", + options: [{ version: "9.0.0" }], + }, + { + code: + "var { Certificate: c } = require('crypto'); c.verifySpkac()", + options: [{ version: "9.0.0" }], + }, + { + code: "require('crypto').fips", + options: [{ version: "6.0.0" }], + }, + { + code: "require('crypto').getCurves", + options: [{ version: "2.3.0" }], + }, + { + code: "require('crypto').getFips", + options: [{ version: "10.0.0" }], + }, + { + code: "require('crypto').privateEncrypt", + options: [{ version: "1.1.0" }], + }, + { + code: "require('crypto').publicDecrypt", + options: [{ version: "1.1.0" }], + }, + { + code: "require('crypto').randomFillSync", + options: [{ version: "7.10.0" }], + }, + { + code: "require('crypto').randomFill", + options: [{ version: "7.10.0" }], + }, + { + code: "require('crypto').scrypt", + options: [{ version: "10.5.0" }], + }, + { + code: "require('crypto').scryptSync", + options: [{ version: "10.5.0" }], + }, + { + code: "require('crypto').setFips", + options: [{ version: "10.0.0" }], + }, + { + code: "require('crypto').timingSafeEqual", + options: [{ version: "6.6.0" }], + }, + + // Ignores. + { + code: "require('crypto').constants", + options: [ + { version: "6.2.9", ignores: ["crypto.constants"] }, + ], + }, + { + code: "var hooks = require('crypto'); hooks.constants", + options: [ + { version: "6.2.9", ignores: ["crypto.constants"] }, + ], + }, + { + code: "var { constants } = require('crypto'); constants", + options: [ + { version: "6.2.9", ignores: ["crypto.constants"] }, + ], + }, + { + code: "import crypto from 'crypto'; crypto.constants", + options: [ + { version: "6.2.9", ignores: ["crypto.constants"] }, + ], + }, + { + code: "import { constants } from 'crypto'; constants", + options: [ + { version: "6.2.9", ignores: ["crypto.constants"] }, + ], + }, + { + code: "require('crypto').Certificate.exportChallenge()", + options: [ + { + version: "8.9.9", + ignores: ["crypto.Certificate.exportChallenge"], + }, + ], + }, + { + code: + "var { Certificate: c } = require('crypto'); c.exportChallenge()", + options: [ + { + version: "8.9.9", + ignores: ["crypto.Certificate.exportChallenge"], + }, + ], + }, + { + code: + "var { Certificate: c } = require('crypto'); c.exportPublicKey()", + options: [ + { + version: "8.9.9", + ignores: ["crypto.Certificate.exportPublicKey"], + }, + ], + }, + { + code: + "var { Certificate: c } = require('crypto'); c.verifySpkac()", + options: [ + { + version: "8.9.9", + ignores: ["crypto.Certificate.verifySpkac"], + }, + ], + }, + { + code: "require('crypto').fips", + options: [{ version: "5.9.9", ignores: ["crypto.fips"] }], + }, + { + code: "require('crypto').getCurves", + options: [ + { version: "2.2.9", ignores: ["crypto.getCurves"] }, + ], + }, + { + code: "require('crypto').getFips", + options: [ + { version: "9.9.9", ignores: ["crypto.getFips"] }, + ], + }, + { + code: "require('crypto').privateEncrypt", + options: [ + { + version: "1.0.9", + ignores: ["crypto.privateEncrypt"], + }, + ], + }, + { + code: "require('crypto').publicDecrypt", + options: [ + { version: "1.0.9", ignores: ["crypto.publicDecrypt"] }, + ], + }, + { + code: "require('crypto').randomFillSync", + options: [ + { + version: "7.9.9", + ignores: ["crypto.randomFillSync"], + }, + ], + }, + { + code: "require('crypto').randomFill", + options: [ + { version: "7.9.9", ignores: ["crypto.randomFill"] }, + ], + }, + { + code: "require('crypto').scrypt", + options: [ + { version: "10.4.9", ignores: ["crypto.scrypt"] }, + ], + }, + { + code: "require('crypto').scryptSync", + options: [ + { version: "10.4.9", ignores: ["crypto.scryptSync"] }, + ], + }, + { + code: "require('crypto').setFips", + options: [ + { version: "9.9.9", ignores: ["crypto.setFips"] }, + ], + }, + { + code: "require('crypto').timingSafeEqual", + options: [ + { + version: "6.5.9", + ignores: ["crypto.timingSafeEqual"], + }, + ], + }, + ], + invalid: [ + { + code: "require('crypto').constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "var hooks = require('crypto'); hooks.constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "var { constants } = require('crypto'); constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "import crypto from 'crypto'; crypto.constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "import { constants } from 'crypto'; constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "require('crypto').Certificate.exportChallenge()", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.Certificate.exportChallenge", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: + "var { Certificate: c } = require('crypto'); c.exportChallenge()", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.Certificate.exportChallenge", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: + "var { Certificate: c } = require('crypto'); c.exportPublicKey()", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.Certificate.exportPublicKey", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: + "var { Certificate: c } = require('crypto'); c.verifySpkac()", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.Certificate.verifySpkac", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: "require('crypto').fips", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.fips", + supported: "6.0.0", + version: "5.9.9", + }, + }, + ], + }, + { + code: "require('crypto').getCurves", + options: [{ version: "2.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.getCurves", + supported: "2.3.0", + version: "2.2.9", + }, + }, + ], + }, + { + code: "require('crypto').getFips", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.getFips", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "require('crypto').privateEncrypt", + options: [{ version: "1.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.privateEncrypt", + supported: "1.1.0", + version: "1.0.9", + }, + }, + ], + }, + { + code: "require('crypto').publicDecrypt", + options: [{ version: "1.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.publicDecrypt", + supported: "1.1.0", + version: "1.0.9", + }, + }, + ], + }, + { + code: "require('crypto').randomFillSync", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.randomFillSync", + supported: "7.10.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('crypto').randomFill", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.randomFill", + supported: "7.10.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('crypto').scrypt", + options: [{ version: "10.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.scrypt", + supported: "10.5.0", + version: "10.4.9", + }, + }, + ], + }, + { + code: "require('crypto').scryptSync", + options: [{ version: "10.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.scryptSync", + supported: "10.5.0", + version: "10.4.9", + }, + }, + ], + }, + { + code: "require('crypto').setFips", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.setFips", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "require('crypto').timingSafeEqual", + options: [{ version: "6.5.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "crypto.timingSafeEqual", + supported: "6.6.0", + version: "6.5.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // dns + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('dns').Resolver", + options: [{ version: "8.3.0" }], + }, + { + code: "var hooks = require('dns'); hooks.Resolver", + options: [{ version: "8.3.0" }], + }, + { + code: "var { Resolver } = require('dns'); Resolver", + options: [{ version: "8.3.0" }], + }, + { + code: "import dns from 'dns'; dns.Resolver", + options: [{ version: "8.3.0" }], + }, + { + code: "import { Resolver } from 'dns'; Resolver", + options: [{ version: "8.3.0" }], + }, + { + code: "require('dns').resolvePtr", + options: [{ version: "6.0.0" }], + }, + { + code: "require('dns').promises", + options: [{ version: "10.6.0" }], + }, + + // Ignores + { + code: "require('dns').Resolver", + options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], + }, + { + code: "var hooks = require('dns'); hooks.Resolver", + options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], + }, + { + code: "var { Resolver } = require('dns'); Resolver", + options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], + }, + { + code: "import dns from 'dns'; dns.Resolver", + options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], + }, + { + code: "import { Resolver } from 'dns'; Resolver", + options: [{ version: "8.2.9", ignores: ["dns.Resolver"] }], + }, + { + code: "require('dns').resolvePtr", + options: [ + { version: "5.9.9", ignores: ["dns.resolvePtr"] }, + ], + }, + { + code: "require('dns').promises", + options: [{ version: "10.5.9", ignores: ["dns.promises"] }], + }, + ], + invalid: [ + { + code: "require('dns').Resolver", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "dns.Resolver", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "var hooks = require('dns'); hooks.Resolver", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "dns.Resolver", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "var { Resolver } = require('dns'); Resolver", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "dns.Resolver", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "import dns from 'dns'; dns.Resolver", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "dns.Resolver", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "import { Resolver } from 'dns'; Resolver", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "dns.Resolver", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "require('dns').resolvePtr", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "dns.resolvePtr", + supported: "6.0.0", + version: "5.9.9", + }, + }, + ], + }, + { + code: "require('dns').promises", + options: [{ version: "10.5.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "dns.promises", + supported: "10.6.0", + version: "10.5.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // fs + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('fs').promises", + options: [{ version: "10.1.0" }], + }, + { + code: "var fs = require('fs'); fs.promises", + options: [{ version: "10.1.0" }], + }, + { + code: "var { promises } = require('fs'); promises", + options: [{ version: "10.1.0" }], + }, + { + code: "import fs from 'fs'; fs.promises", + options: [{ version: "10.1.0" }], + }, + { + code: "import { promises } from 'fs'", + options: [{ version: "10.1.0" }], + }, + { + code: "require('fs').copyFile", + options: [{ version: "8.5.0" }], + }, + { + code: "require('fs').copyFileSync", + options: [{ version: "8.5.0" }], + }, + { + code: "require('fs').mkdtemp", + options: [{ version: "5.10.0" }], + }, + { + code: "require('fs').mkdtempSync", + options: [{ version: "5.10.0" }], + }, + { + code: "require('fs').realpath.native", + options: [{ version: "9.2.0" }], + }, + { + code: "require('fs').realpathSync.native", + options: [{ version: "9.2.0" }], + }, + + // Ignores + { + code: "require('fs').promises", + options: [{ version: "10.0.9", ignores: ["fs.promises"] }], + }, + { + code: "var fs = require('fs'); fs.promises", + options: [{ version: "10.0.9", ignores: ["fs.promises"] }], + }, + { + code: "var { promises } = require('fs'); promises", + options: [{ version: "10.0.9", ignores: ["fs.promises"] }], + }, + { + code: "import fs from 'fs'; fs.promises", + options: [{ version: "10.0.9", ignores: ["fs.promises"] }], + }, + { + code: "import { promises } from 'fs'", + options: [{ version: "10.0.9", ignores: ["fs.promises"] }], + }, + { + code: "require('fs').copyFile", + options: [{ version: "8.4.9", ignores: ["fs.copyFile"] }], + }, + { + code: "require('fs').copyFileSync", + options: [ + { version: "8.4.9", ignores: ["fs.copyFileSync"] }, + ], + }, + { + code: "require('fs').mkdtemp", + options: [{ version: "5.9.9", ignores: ["fs.mkdtemp"] }], + }, + { + code: "require('fs').mkdtempSync", + options: [ + { version: "5.9.9", ignores: ["fs.mkdtempSync"] }, + ], + }, + { + code: "require('fs').realpath.native", + options: [ + { version: "9.1.9", ignores: ["fs.realpath.native"] }, + ], + }, + { + code: "require('fs').realpathSync.native", + options: [ + { + version: "9.1.9", + ignores: ["fs.realpathSync.native"], + }, + ], + }, + ], + invalid: [ + { + code: "require('fs').promises", + options: [{ version: "10.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.promises", + supported: "10.1.0", + version: "10.0.9", + }, + }, + ], + }, + { + code: "var fs = require('fs'); fs.promises", + options: [{ version: "10.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.promises", + supported: "10.1.0", + version: "10.0.9", + }, + }, + ], + }, + { + code: "var { promises } = require('fs'); promises", + options: [{ version: "10.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.promises", + supported: "10.1.0", + version: "10.0.9", + }, + }, + ], + }, + { + code: "import fs from 'fs'; fs.promises", + options: [{ version: "10.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.promises", + supported: "10.1.0", + version: "10.0.9", + }, + }, + ], + }, + { + code: "import { promises } from 'fs'", + options: [{ version: "10.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.promises", + supported: "10.1.0", + version: "10.0.9", + }, + }, + ], + }, + { + code: "require('fs').copyFile", + options: [{ version: "8.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.copyFile", + supported: "8.5.0", + version: "8.4.9", + }, + }, + ], + }, + { + code: "require('fs').copyFileSync", + options: [{ version: "8.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.copyFileSync", + supported: "8.5.0", + version: "8.4.9", + }, + }, + ], + }, + { + code: "require('fs').mkdtemp", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.mkdtemp", + supported: "5.10.0", + version: "5.9.9", + }, + }, + ], + }, + { + code: "require('fs').mkdtempSync", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.mkdtempSync", + supported: "5.10.0", + version: "5.9.9", + }, + }, + ], + }, + { + code: "require('fs').realpath.native", + options: [{ version: "9.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.realpath.native", + supported: "9.2.0", + version: "9.1.9", + }, + }, + ], + }, + { + code: "require('fs').realpathSync.native", + options: [{ version: "9.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "fs.realpathSync.native", + supported: "9.2.0", + version: "9.1.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // http2 + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('http2')", + options: [{ version: "8.4.0" }], + }, + { + code: "import http2 from 'http2'", + options: [{ version: "8.4.0" }], + }, + { + code: "require('http2')", + options: [{ version: "8.3.9", ignores: ["http2"] }], + }, + { + code: "import http2 from 'http2'", + options: [{ version: "8.3.9", ignores: ["http2"] }], + }, + ], + invalid: [ + { + code: "require('http2')", + options: [{ version: "8.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "http2", + supported: "8.4.0", + version: "8.3.9", + }, + }, + ], + }, + { + code: "import http2 from 'http2'", + options: [{ version: "8.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "http2", + supported: "8.4.0", + version: "8.3.9", + }, + }, + ], + }, + { + code: "import { createServer } from 'http2'", + options: [{ version: "8.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "http2", + supported: "8.4.0", + version: "8.3.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // inspector + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('inspector')", + options: [{ version: "8.0.0" }], + }, + { + code: "import inspector from 'inspector'", + options: [{ version: "8.0.0" }], + }, + { + code: "require('inspector')", + options: [{ version: "7.9.9", ignores: ["inspector"] }], + }, + { + code: "import inspector from 'inspector'", + options: [{ version: "7.9.9", ignores: ["inspector"] }], + }, + ], + invalid: [ + { + code: "require('inspector')", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "inspector", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "import inspector from 'inspector'", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "inspector", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "import { open } from 'inspector'", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "inspector", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // module + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require.resolve.paths()", + options: [{ version: "8.9.0" }], + }, + { + code: "require('module').builtinModules", + options: [{ version: "9.3.0" }], + }, + { + code: "require.resolve.paths()", + options: [ + { + version: "8.8.9", + ignores: ["require.resolve.paths"], + }, + ], + }, + { + code: "require('module').builtinModules", + options: [ + { + version: "9.2.9", + ignores: ["module.builtinModules"], + }, + ], + }, + ], + invalid: [ + { + code: "require.resolve.paths()", + options: [{ version: "8.8.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "require.resolve.paths", + supported: "8.9.0", + version: "8.8.9", + }, + }, + ], + }, + { + code: "require('module').builtinModules", + options: [{ version: "9.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "module.builtinModules", + supported: "9.3.0", + version: "9.2.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // os + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('os').constants", + options: [{ version: "6.3.0" }], + }, + { + code: "var hooks = require('os'); hooks.constants", + options: [{ version: "6.3.0" }], + }, + { + code: "var { constants } = require('os'); constants", + options: [{ version: "6.3.0" }], + }, + { + code: "import os from 'os'; os.constants", + options: [{ version: "6.3.0" }], + }, + { + code: "import { constants } from 'os'; constants", + options: [{ version: "6.3.0" }], + }, + { + code: "require('os').homedir", + options: [{ version: "2.3.0" }], + }, + { + code: "require('os').userInfo", + options: [{ version: "6.0.0" }], + }, + + // Ignores + { + code: "require('os').constants", + options: [{ version: "6.2.9", ignores: ["os.constants"] }], + }, + { + code: "var hooks = require('os'); hooks.constants", + options: [{ version: "6.2.9", ignores: ["os.constants"] }], + }, + { + code: "var { constants } = require('os'); constants", + options: [{ version: "6.2.9", ignores: ["os.constants"] }], + }, + { + code: "import os from 'os'; os.constants", + options: [{ version: "6.2.9", ignores: ["os.constants"] }], + }, + { + code: "import { constants } from 'os'; constants", + options: [{ version: "6.2.9", ignores: ["os.constants"] }], + }, + { + code: "require('os').homedir", + options: [{ version: "2.2.9", ignores: ["os.homedir"] }], + }, + { + code: "require('os').userInfo", + options: [{ version: "5.9.9", ignores: ["os.userInfo"] }], + }, + ], + invalid: [ + { + code: "require('os').constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "os.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "var hooks = require('os'); hooks.constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "os.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "var { constants } = require('os'); constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "os.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "import os from 'os'; os.constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "os.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "import { constants } from 'os'; constants", + options: [{ version: "6.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "os.constants", + supported: "6.3.0", + version: "6.2.9", + }, + }, + ], + }, + { + code: "require('os').homedir", + options: [{ version: "2.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "os.homedir", + supported: "2.3.0", + version: "2.2.9", + }, + }, + ], + }, + { + code: "require('os').userInfo", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "os.userInfo", + supported: "6.0.0", + version: "5.9.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // path + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('path').toNamespacedPath()", + options: [{ version: "9.0.0" }], + }, + { + code: "var path = require('path'); path.toNamespacedPath()", + options: [{ version: "9.0.0" }], + }, + { + code: + "var { toNamespacedPath } = require('path'); toNamespacedPath()", + options: [{ version: "9.0.0" }], + }, + { + code: "import path from 'path'; path.toNamespacedPath()", + options: [{ version: "9.0.0" }], + }, + { + code: + "import { toNamespacedPath } from 'path'; toNamespacedPath()", + options: [{ version: "9.0.0" }], + }, + + // Ignores + { + code: "require('path').toNamespacedPath()", + options: [ + { + version: "8.9.9", + ignores: ["path.toNamespacedPath"], + }, + ], + }, + { + code: "var path = require('path'); path.toNamespacedPath()", + options: [ + { + version: "8.9.9", + ignores: ["path.toNamespacedPath"], + }, + ], + }, + { + code: + "var { toNamespacedPath } = require('path'); toNamespacedPath()", + options: [ + { + version: "8.9.9", + ignores: ["path.toNamespacedPath"], + }, + ], + }, + { + code: "import path from 'path'; path.toNamespacedPath()", + options: [ + { + version: "8.9.9", + ignores: ["path.toNamespacedPath"], + }, + ], + }, + { + code: + "import { toNamespacedPath } from 'path'; toNamespacedPath()", + options: [ + { + version: "8.9.9", + ignores: ["path.toNamespacedPath"], + }, + ], + }, + ], + invalid: [ + { + code: "require('path').toNamespacedPath()", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "path.toNamespacedPath", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: "var path = require('path'); path.toNamespacedPath()", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "path.toNamespacedPath", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: + "var { toNamespacedPath } = require('path'); toNamespacedPath()", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "path.toNamespacedPath", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: "import path from 'path'; path.toNamespacedPath()", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "path.toNamespacedPath", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: + "import { toNamespacedPath } from 'path'; toNamespacedPath()", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "path.toNamespacedPath", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // perf_hooks + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('perf_hooks')", + options: [{ version: "8.5.0" }], + }, + { + code: "import perf_hooks from 'perf_hooks'", + options: [{ version: "8.5.0" }], + }, + { + code: "require('perf_hooks')", + options: [{ version: "8.4.9", ignores: ["perf_hooks"] }], + }, + { + code: "import perf_hooks from 'perf_hooks'", + options: [{ version: "8.4.9", ignores: ["perf_hooks"] }], + }, + ], + invalid: [ + { + code: "require('perf_hooks')", + options: [{ version: "8.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "perf_hooks", + supported: "8.5.0", + version: "8.4.9", + }, + }, + ], + }, + { + code: "import perf_hooks from 'perf_hooks'", + options: [{ version: "8.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "perf_hooks", + supported: "8.5.0", + version: "8.4.9", + }, + }, + ], + }, + { + code: "import { open } from 'perf_hooks'", + options: [{ version: "8.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "perf_hooks", + supported: "8.5.0", + version: "8.4.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // process + //---------------------------------------------------------------------- + { + valid: [ + { + code: "process.argv0", + options: [{ version: "6.4.0" }], + }, + { + code: "require('process').argv0", + options: [{ version: "6.4.0" }], + }, + { + code: "var c = require('process'); c.argv0", + options: [{ version: "6.4.0" }], + }, + { + code: "var { argv0 } = require('process'); argv0", + options: [{ version: "6.4.0" }], + }, + { + code: "import c from 'process'; c.argv0", + options: [{ version: "6.4.0" }], + }, + { + code: "process.channel", + options: [{ version: "7.1.0" }], + }, + { + code: "process.cpuUsage", + options: [{ version: "6.1.0" }], + }, + { + code: "process.emitWarning", + options: [{ version: "8.0.0" }], + }, + { + code: "process.getegid", + options: [{ version: "2.0.0" }], + }, + { + code: "process.geteuid", + options: [{ version: "2.0.0" }], + }, + { + code: "process.hasUncaughtExceptionCaptureCallback", + options: [{ version: "9.3.0" }], + }, + { + code: "process.ppid", + options: [{ version: "9.2.0" }], + }, + { + code: "process.release", + options: [{ version: "3.0.0" }], + }, + { + code: "process.setegid", + options: [{ version: "2.0.0" }], + }, + { + code: "process.seteuid", + options: [{ version: "2.0.0" }], + }, + { + code: "process.setUncaughtExceptionCaptureCallback", + options: [{ version: "9.3.0" }], + }, + + // Ignores + { + code: "process.argv0", + options: [{ version: "6.3.9", ignores: ["process.argv0"] }], + }, + { + code: "require('process').argv0", + options: [{ version: "6.3.9", ignores: ["process.argv0"] }], + }, + { + code: "var c = require('process'); c.argv0", + options: [{ version: "6.3.9", ignores: ["process.argv0"] }], + }, + { + code: "var { argv0 } = require('process'); argv0", + options: [{ version: "6.3.9", ignores: ["process.argv0"] }], + }, + { + code: "import c from 'process'; c.argv0", + options: [{ version: "6.3.9", ignores: ["process.argv0"] }], + }, + { + code: "process.channel", + options: [ + { version: "7.0.9", ignores: ["process.channel"] }, + ], + }, + { + code: "process.cpuUsage", + options: [ + { version: "6.0.9", ignores: ["process.cpuUsage"] }, + ], + }, + { + code: "process.emitWarning", + options: [ + { version: "7.9.9", ignores: ["process.emitWarning"] }, + ], + }, + { + code: "process.getegid", + options: [ + { version: "1.9.9", ignores: ["process.getegid"] }, + ], + }, + { + code: "process.geteuid", + options: [ + { version: "1.9.9", ignores: ["process.geteuid"] }, + ], + }, + { + code: "process.hasUncaughtExceptionCaptureCallback", + options: [ + { + version: "9.2.9", + ignores: [ + "process.hasUncaughtExceptionCaptureCallback", + ], + }, + ], + }, + { + code: "process.ppid", + options: [{ version: "9.1.9", ignores: ["process.ppid"] }], + }, + { + code: "process.release", + options: [ + { version: "2.9.9", ignores: ["process.release"] }, + ], + }, + { + code: "process.setegid", + options: [ + { version: "1.9.9", ignores: ["process.setegid"] }, + ], + }, + { + code: "process.seteuid", + options: [ + { version: "1.9.9", ignores: ["process.seteuid"] }, + ], + }, + { + code: "process.setUncaughtExceptionCaptureCallback", + options: [ + { + version: "9.2.9", + ignores: [ + "process.setUncaughtExceptionCaptureCallback", + ], + }, + ], + }, + ], + invalid: [ + { + code: "process.argv0", + options: [{ version: "6.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.argv0", + supported: "6.4.0", + version: "6.3.9", + }, + }, + ], + }, + { + code: "require('process').argv0", + options: [{ version: "6.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.argv0", + supported: "6.4.0", + version: "6.3.9", + }, + }, + ], + }, + { + code: "var c = require('process'); c.argv0", + options: [{ version: "6.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.argv0", + supported: "6.4.0", + version: "6.3.9", + }, + }, + ], + }, + { + code: "var { argv0 } = require('process'); argv0", + options: [{ version: "6.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.argv0", + supported: "6.4.0", + version: "6.3.9", + }, + }, + ], + }, + { + code: "import c from 'process'; c.argv0", + options: [{ version: "6.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.argv0", + supported: "6.4.0", + version: "6.3.9", + }, + }, + ], + }, + { + code: "process.channel", + options: [{ version: "7.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.channel", + supported: "7.1.0", + version: "7.0.9", + }, + }, + ], + }, + { + code: "process.cpuUsage", + options: [{ version: "6.0.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.cpuUsage", + supported: "6.1.0", + version: "6.0.9", + }, + }, + ], + }, + { + code: "process.emitWarning", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.emitWarning", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "process.getegid", + options: [{ version: "1.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.getegid", + supported: "2.0.0", + version: "1.9.9", + }, + }, + ], + }, + { + code: "process.geteuid", + options: [{ version: "1.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.geteuid", + supported: "2.0.0", + version: "1.9.9", + }, + }, + ], + }, + { + code: "process.hasUncaughtExceptionCaptureCallback", + options: [{ version: "9.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: + "process.hasUncaughtExceptionCaptureCallback", + supported: "9.3.0", + version: "9.2.9", + }, + }, + ], + }, + { + code: "process.ppid", + options: [{ version: "9.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.ppid", + supported: "9.2.0", + version: "9.1.9", + }, + }, + ], + }, + { + code: "process.release", + options: [{ version: "2.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.release", + supported: "3.0.0", + version: "2.9.9", + }, + }, + ], + }, + { + code: "process.setegid", + options: [{ version: "1.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.setegid", + supported: "2.0.0", + version: "1.9.9", + }, + }, + ], + }, + { + code: "process.seteuid", + options: [{ version: "1.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "process.seteuid", + supported: "2.0.0", + version: "1.9.9", + }, + }, + ], + }, + { + code: "process.setUncaughtExceptionCaptureCallback", + options: [{ version: "9.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: + "process.setUncaughtExceptionCaptureCallback", + supported: "9.3.0", + version: "9.2.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // stream + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('stream').finished()", + options: [{ version: "10.0.0" }], + }, + { + code: "var hooks = require('stream'); hooks.finished()", + options: [{ version: "10.0.0" }], + }, + { + code: "var { finished } = require('stream'); finished()", + options: [{ version: "10.0.0" }], + }, + { + code: "import stream from 'stream'; stream.finished()", + options: [{ version: "10.0.0" }], + }, + { + code: "import { finished } from 'stream'; finished()", + options: [{ version: "10.0.0" }], + }, + { + code: "require('stream').pipeline()", + options: [{ version: "10.0.0" }], + }, + + // Ignores + { + code: "require('stream').finished()", + options: [ + { version: "9.9.9", ignores: ["stream.finished"] }, + ], + }, + { + code: "var hooks = require('stream'); hooks.finished()", + options: [ + { version: "9.9.9", ignores: ["stream.finished"] }, + ], + }, + { + code: "var { finished } = require('stream'); finished()", + options: [ + { version: "9.9.9", ignores: ["stream.finished"] }, + ], + }, + { + code: "import stream from 'stream'; stream.finished()", + options: [ + { version: "9.9.9", ignores: ["stream.finished"] }, + ], + }, + { + code: "import { finished } from 'stream'; finished()", + options: [ + { version: "9.9.9", ignores: ["stream.finished"] }, + ], + }, + { + code: "require('stream').pipeline()", + options: [ + { version: "9.9.9", ignores: ["stream.pipeline"] }, + ], + }, + ], + invalid: [ + { + code: "require('stream').finished()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "stream.finished", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "var hooks = require('stream'); hooks.finished()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "stream.finished", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "var { finished } = require('stream'); finished()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "stream.finished", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "import stream from 'stream'; stream.finished()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "stream.finished", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "import { finished } from 'stream'; finished()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "stream.finished", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "require('stream').pipeline()", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "stream.pipeline", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // trace_events + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('trace_events')", + options: [{ version: "10.0.0" }], + }, + { + code: "import trace_events from 'trace_events'", + options: [{ version: "10.0.0" }], + }, + { + code: "require('trace_events')", + options: [{ version: "9.9.9", ignores: ["trace_events"] }], + }, + { + code: "import trace_events from 'trace_events'", + options: [{ version: "9.9.9", ignores: ["trace_events"] }], + }, + ], + invalid: [ + { + code: "require('trace_events')", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "trace_events", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "import trace_events from 'trace_events'", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "trace_events", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "import { createTracing } from 'trace_events'", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "trace_events", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // url + //---------------------------------------------------------------------- + { + valid: [ + { + code: "URL", + options: [{ version: "10.0.0" }], + }, + { + code: "URLSearchParams", + options: [{ version: "10.0.0" }], + }, + { + code: "require('url').URL", + options: [{ version: "7.0.0" }], + }, + { + code: "var cp = require('url'); cp.URL", + options: [{ version: "7.0.0" }], + }, + { + code: "var { URL } = require('url');", + options: [{ version: "7.0.0" }], + }, + { + code: "import cp from 'url'; cp.URL", + options: [{ version: "7.0.0" }], + }, + { + code: "import { URL } from 'url'", + options: [{ version: "7.0.0" }], + }, + { + code: "require('url').URLSearchParams", + options: [{ version: "7.5.0" }], + }, + { + code: "require('url').domainToASCII", + options: [{ version: "7.4.0" }], + }, + { + code: "require('url').domainToUnicode", + options: [{ version: "7.4.0" }], + }, + + // Ignores + { + code: "URL", + options: [{ version: "9.9.9", ignores: ["URL"] }], + }, + { + code: "URLSearchParams", + options: [ + { version: "9.9.9", ignores: ["URLSearchParams"] }, + ], + }, + { + code: "require('url').URL", + options: [{ version: "6.9.9", ignores: ["url.URL"] }], + }, + { + code: "var cp = require('url'); cp.URL", + options: [{ version: "6.9.9", ignores: ["url.URL"] }], + }, + { + code: "var { URL } = require('url');", + options: [{ version: "6.9.9", ignores: ["url.URL"] }], + }, + { + code: "import cp from 'url'; cp.URL", + options: [{ version: "6.9.9", ignores: ["url.URL"] }], + }, + { + code: "import { URL } from 'url'", + options: [{ version: "6.9.9", ignores: ["url.URL"] }], + }, + { + code: "require('url').URLSearchParams", + options: [ + { version: "7.4.9", ignores: ["url.URLSearchParams"] }, + ], + }, + { + code: "require('url').domainToASCII", + options: [ + { version: "7.3.9", ignores: ["url.domainToASCII"] }, + ], + }, + { + code: "require('url').domainToUnicode", + options: [ + { version: "7.3.9", ignores: ["url.domainToUnicode"] }, + ], + }, + ], + invalid: [ + { + code: "URL", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "URL", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "URLSearchParams", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "URLSearchParams", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "require('url').URL", + options: [{ version: "6.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "url.URL", + supported: "7.0.0", + version: "6.9.9", + }, + }, + ], + }, + { + code: "var cp = require('url'); cp.URL", + options: [{ version: "6.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "url.URL", + supported: "7.0.0", + version: "6.9.9", + }, + }, + ], + }, + { + code: "var { URL } = require('url');", + options: [{ version: "6.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "url.URL", + supported: "7.0.0", + version: "6.9.9", + }, + }, + ], + }, + { + code: "import cp from 'url'; cp.URL", + options: [{ version: "6.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "url.URL", + supported: "7.0.0", + version: "6.9.9", + }, + }, + ], + }, + { + code: "import { URL } from 'url'", + options: [{ version: "6.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "url.URL", + supported: "7.0.0", + version: "6.9.9", + }, + }, + ], + }, + { + code: "require('url').URLSearchParams", + options: [{ version: "7.4.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "url.URLSearchParams", + supported: "7.5.0", + version: "7.4.9", + }, + }, + ], + }, + { + code: "require('url').domainToASCII", + options: [{ version: "7.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "url.domainToASCII", + supported: "7.4.0", + version: "7.3.9", + }, + }, + ], + }, + { + code: "require('url').domainToUnicode", + options: [{ version: "7.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "url.domainToUnicode", + supported: "7.4.0", + version: "7.3.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // util + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('util').callbackify", + options: [{ version: "8.2.0" }], + }, + { + code: "var hooks = require('util'); hooks.callbackify", + options: [{ version: "8.2.0" }], + }, + { + code: "var { callbackify } = require('util'); callbackify", + options: [{ version: "8.2.0" }], + }, + { + code: "import util from 'util'; util.callbackify", + options: [{ version: "8.2.0" }], + }, + { + code: "import { callbackify } from 'util'; callbackify", + options: [{ version: "8.2.0" }], + }, + { + code: "require('util').formatWithOptions", + options: [{ version: "10.0.0" }], + }, + { + code: "require('util').getSystemErrorName", + options: [{ version: "9.7.0" }], + }, + { + code: "require('util').inspect.custom", + options: [{ version: "6.6.0" }], + }, + { + code: "require('util').inspect.defaultOptions", + options: [{ version: "6.4.0" }], + }, + { + code: "require('util').isDeepStrictEqual", + options: [{ version: "9.0.0" }], + }, + { + code: "require('util').promisify", + options: [{ version: "8.0.0" }], + }, + { + code: "require('util').TextDecoder", + options: [{ version: "8.3.0" }], + }, + { + code: "require('util').TextEncoder", + options: [{ version: "8.3.0" }], + }, + { + code: "require('util').types", + options: [{ version: "10.0.0" }], + }, + + // Ignores + { + code: "require('util').callbackify", + options: [ + { version: "8.1.9", ignores: ["util.callbackify"] }, + ], + }, + { + code: "var hooks = require('util'); hooks.callbackify", + options: [ + { version: "8.1.9", ignores: ["util.callbackify"] }, + ], + }, + { + code: "var { callbackify } = require('util'); callbackify", + options: [ + { version: "8.1.9", ignores: ["util.callbackify"] }, + ], + }, + { + code: "import util from 'util'; util.callbackify", + options: [ + { version: "8.1.9", ignores: ["util.callbackify"] }, + ], + }, + { + code: "import { callbackify } from 'util'; callbackify", + options: [ + { version: "8.1.9", ignores: ["util.callbackify"] }, + ], + }, + { + code: "require('util').formatWithOptions", + options: [ + { + version: "9.9.9", + ignores: ["util.formatWithOptions"], + }, + ], + }, + { + code: "require('util').getSystemErrorName", + options: [ + { + version: "9.6.9", + ignores: ["util.getSystemErrorName"], + }, + ], + }, + { + code: "require('util').inspect.custom", + options: [ + { version: "6.5.9", ignores: ["util.inspect.custom"] }, + ], + }, + { + code: "require('util').inspect.defaultOptions", + options: [ + { + version: "6.3.9", + ignores: ["util.inspect.defaultOptions"], + }, + ], + }, + { + code: "require('util').isDeepStrictEqual", + options: [ + { + version: "8.9.9", + ignores: ["util.isDeepStrictEqual"], + }, + ], + }, + { + code: "require('util').promisify", + options: [ + { version: "7.9.9", ignores: ["util.promisify"] }, + ], + }, + { + code: "require('util').TextDecoder", + options: [ + { version: "8.2.9", ignores: ["util.TextDecoder"] }, + ], + }, + { + code: "require('util').TextEncoder", + options: [ + { version: "8.2.9", ignores: ["util.TextEncoder"] }, + ], + }, + { + code: "require('util').types", + options: [{ version: "9.9.9", ignores: ["util.types"] }], + }, + ], + invalid: [ + { + code: "require('util').callbackify", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.callbackify", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "var hooks = require('util'); hooks.callbackify", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.callbackify", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "var { callbackify } = require('util'); callbackify", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.callbackify", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "import util from 'util'; util.callbackify", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.callbackify", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "import { callbackify } from 'util'; callbackify", + options: [{ version: "8.1.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.callbackify", + supported: "8.2.0", + version: "8.1.9", + }, + }, + ], + }, + { + code: "require('util').formatWithOptions", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.formatWithOptions", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + { + code: "require('util').getSystemErrorName", + options: [{ version: "9.6.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.getSystemErrorName", + supported: "9.7.0", + version: "9.6.9", + }, + }, + ], + }, + { + code: "require('util').inspect.custom", + options: [{ version: "6.5.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.inspect.custom", + supported: "6.6.0", + version: "6.5.9", + }, + }, + ], + }, + { + code: "require('util').inspect.defaultOptions", + options: [{ version: "6.3.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.inspect.defaultOptions", + supported: "6.4.0", + version: "6.3.9", + }, + }, + ], + }, + { + code: "require('util').isDeepStrictEqual", + options: [{ version: "8.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.isDeepStrictEqual", + supported: "9.0.0", + version: "8.9.9", + }, + }, + ], + }, + { + code: "require('util').promisify", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.promisify", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('util').TextDecoder", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.TextDecoder", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "require('util').TextEncoder", + options: [{ version: "8.2.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.TextEncoder", + supported: "8.3.0", + version: "8.2.9", + }, + }, + ], + }, + { + code: "require('util').types", + options: [{ version: "9.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "util.types", + supported: "10.0.0", + version: "9.9.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // v8 + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('v8')", + options: [{ version: "1.0.0" }], + }, + { + code: "import hooks from 'v8'", + options: [{ version: "1.0.0" }], + }, + { + code: "require('v8').cachedDataVersionTag()", + options: [{ version: "8.0.0" }], + }, + { + code: + "var hooks = require('v8'); hooks.cachedDataVersionTag()", + options: [{ version: "8.0.0" }], + }, + { + code: + "var { cachedDataVersionTag } = require('v8'); cachedDataVersionTag()", + options: [{ version: "8.0.0" }], + }, + { + code: "import v8 from 'v8'; v8.cachedDataVersionTag()", + options: [{ version: "8.0.0" }], + }, + { + code: + "import { cachedDataVersionTag } from 'v8'; cachedDataVersionTag()", + options: [{ version: "8.0.0" }], + }, + { + code: "require('v8').getHeapSpaceStatistics()", + options: [{ version: "6.0.0" }], + }, + { + code: "require('v8').serialize()", + options: [{ version: "8.0.0" }], + }, + { + code: "require('v8').deserialize()", + options: [{ version: "8.0.0" }], + }, + { + code: "require('v8').Serializer", + options: [{ version: "8.0.0" }], + }, + { + code: "require('v8').Deserializer", + options: [{ version: "8.0.0" }], + }, + { + code: "require('v8').DefaultSerializer", + options: [{ version: "8.0.0" }], + }, + { + code: "require('v8').DefaultDeserializer", + options: [{ version: "8.0.0" }], + }, + + // Ignores. + { + code: "require('v8')", + options: [{ version: "0.12.99", ignores: ["v8"] }], + }, + { + code: "import hooks from 'v8'", + options: [{ version: "0.12.99", ignores: ["v8"] }], + }, + { + code: "import { cachedDataVersionTag } from 'v8'", + options: [ + { + version: "0.12.99", + ignores: ["v8", "v8.cachedDataVersionTag"], + }, + ], + }, + { + code: "require('v8').cachedDataVersionTag()", + options: [ + { + version: "7.9.9", + ignores: ["v8.cachedDataVersionTag"], + }, + ], + }, + { + code: + "var hooks = require('v8'); hooks.cachedDataVersionTag()", + options: [ + { + version: "7.9.9", + ignores: ["v8.cachedDataVersionTag"], + }, + ], + }, + { + code: + "var { cachedDataVersionTag } = require('v8'); cachedDataVersionTag()", + options: [ + { + version: "7.9.9", + ignores: ["v8.cachedDataVersionTag"], + }, + ], + }, + { + code: "import v8 from 'v8'; v8.cachedDataVersionTag()", + options: [ + { + version: "7.9.9", + ignores: ["v8.cachedDataVersionTag"], + }, + ], + }, + { + code: + "import { cachedDataVersionTag } from 'v8'; cachedDataVersionTag()", + options: [ + { + version: "7.9.9", + ignores: ["v8.cachedDataVersionTag"], + }, + ], + }, + { + code: "require('v8').getHeapSpaceStatistics()", + options: [ + { + version: "5.9.9", + ignores: ["v8.getHeapSpaceStatistics"], + }, + ], + }, + { + code: "require('v8').serialize()", + options: [{ version: "7.9.9", ignores: ["v8.serialize"] }], + }, + { + code: "require('v8').deserialize()", + options: [ + { version: "7.9.9", ignores: ["v8.deserialize"] }, + ], + }, + { + code: "require('v8').Serializer", + options: [{ version: "7.9.9", ignores: ["v8.Serializer"] }], + }, + { + code: "require('v8').Deserializer", + options: [ + { version: "7.9.9", ignores: ["v8.Deserializer"] }, + ], + }, + { + code: "require('v8').DefaultSerializer", + options: [ + { version: "7.9.9", ignores: ["v8.DefaultSerializer"] }, + ], + }, + { + code: "require('v8').DefaultDeserializer", + options: [ + { + version: "7.9.9", + ignores: ["v8.DefaultDeserializer"], + }, + ], + }, + ], + invalid: [ + { + code: "require('v8')", + options: [{ version: "0.12.99" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8", + supported: "1.0.0", + version: "0.12.99", + }, + }, + ], + }, + { + code: "import hooks from 'v8'", + options: [{ version: "0.12.99" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8", + supported: "1.0.0", + version: "0.12.99", + }, + }, + ], + }, + { + code: "import { cachedDataVersionTag } from 'v8'", + options: [{ version: "0.12.99" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8", + supported: "1.0.0", + version: "0.12.99", + }, + }, + { + messageId: "unsupported", + data: { + name: "v8.cachedDataVersionTag", + supported: "8.0.0", + version: "0.12.99", + }, + }, + ], + }, + { + code: "require('v8').cachedDataVersionTag()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.cachedDataVersionTag", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: + "var hooks = require('v8'); hooks.cachedDataVersionTag()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.cachedDataVersionTag", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: + "var { cachedDataVersionTag } = require('v8'); cachedDataVersionTag()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.cachedDataVersionTag", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "import v8 from 'v8'; v8.cachedDataVersionTag()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.cachedDataVersionTag", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: + "import { cachedDataVersionTag } from 'v8'; cachedDataVersionTag()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.cachedDataVersionTag", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('v8').getHeapSpaceStatistics()", + options: [{ version: "5.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.getHeapSpaceStatistics", + supported: "6.0.0", + version: "5.9.9", + }, + }, + ], + }, + { + code: "require('v8').serialize()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.serialize", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('v8').deserialize()", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.deserialize", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('v8').Serializer", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.Serializer", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('v8').Deserializer", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.Deserializer", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('v8').DefaultSerializer", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.DefaultSerializer", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + { + code: "require('v8').DefaultDeserializer", + options: [{ version: "7.9.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "v8.DefaultDeserializer", + supported: "8.0.0", + version: "7.9.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // vm + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('vm').Module", + options: [{ version: "9.6.0" }], + }, + { + code: "var vm = require('vm'); vm.Module", + options: [{ version: "9.6.0" }], + }, + { + code: "var { Module } = require('vm'); Module", + options: [{ version: "9.6.0" }], + }, + { + code: "import vm from 'vm'; vm.Module", + options: [{ version: "9.6.0" }], + }, + { + code: "import { Module } from 'vm'; Module", + options: [{ version: "9.6.0" }], + }, + + // Ignores + { + code: "require('vm').Module", + options: [{ version: "9.5.9", ignores: ["vm.Module"] }], + }, + { + code: "var vm = require('vm'); vm.Module", + options: [{ version: "9.5.9", ignores: ["vm.Module"] }], + }, + { + code: "var { Module } = require('vm'); Module", + options: [{ version: "9.5.9", ignores: ["vm.Module"] }], + }, + { + code: "import vm from 'vm'; vm.Module", + options: [{ version: "9.5.9", ignores: ["vm.Module"] }], + }, + { + code: "import { Module } from 'vm'; Module", + options: [{ version: "9.5.9", ignores: ["vm.Module"] }], + }, + ], + invalid: [ + { + code: "require('vm').Module", + options: [{ version: "9.5.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "vm.Module", + supported: "9.6.0", + version: "9.5.9", + }, + }, + ], + }, + { + code: "var vm = require('vm'); vm.Module", + options: [{ version: "9.5.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "vm.Module", + supported: "9.6.0", + version: "9.5.9", + }, + }, + ], + }, + { + code: "var { Module } = require('vm'); Module", + options: [{ version: "9.5.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "vm.Module", + supported: "9.6.0", + version: "9.5.9", + }, + }, + ], + }, + { + code: "import vm from 'vm'; vm.Module", + options: [{ version: "9.5.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "vm.Module", + supported: "9.6.0", + version: "9.5.9", + }, + }, + ], + }, + { + code: "import { Module } from 'vm'; Module", + options: [{ version: "9.5.9" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "vm.Module", + supported: "9.6.0", + version: "9.5.9", + }, + }, + ], + }, + ], + }, + + //---------------------------------------------------------------------- + // worker_threads + //---------------------------------------------------------------------- + { + valid: [ + { + code: "require('worker_threads')", + options: [{ version: "10.5.0" }], + }, + { + code: "import worker_threads from 'worker_threads'", + options: [{ version: "10.5.0" }], + }, + { + code: "require('worker_threads')", + options: [ + { version: "10.4.99", ignores: ["worker_threads"] }, + ], + }, + { + code: "import worker_threads from 'worker_threads'", + options: [ + { version: "10.4.99", ignores: ["worker_threads"] }, + ], + }, + ], + invalid: [ + { + code: "require('worker_threads')", + options: [{ version: "10.4.99" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "worker_threads", + supported: "10.5.0", + version: "10.4.99", + }, + }, + ], + }, + { + code: "import worker_threads from 'worker_threads'", + options: [{ version: "10.4.99" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "worker_threads", + supported: "10.5.0", + version: "10.4.99", + }, + }, + ], + }, + { + code: "import { Worker } from 'worker_threads'", + options: [{ version: "10.4.99" }], + errors: [ + { + messageId: "unsupported", + data: { + name: "worker_threads", + supported: "10.5.0", + version: "10.4.99", + }, + }, + ], + }, + ], + }, + ]) +) diff --git a/tests/lib/rules/no-unsupported-features/os.js b/tests/lib/rules/no-unsupported-features/os.js deleted file mode 100644 index 4025b184..00000000 --- a/tests/lib/rules/no-unsupported-features/os.js +++ /dev/null @@ -1,179 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/os") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/os", rule, { - valid: [ - { - code: "require('os').constants", - options: [{ version: "6.3.0" }], - }, - { - code: "var hooks = require('os'); hooks.constants", - options: [{ version: "6.3.0" }], - }, - { - code: "var { constants } = require('os'); constants", - options: [{ version: "6.3.0" }], - }, - { - code: "import os from 'os'; os.constants", - options: [{ version: "6.3.0" }], - }, - { - code: "import { constants } from 'os'; constants", - options: [{ version: "6.3.0" }], - }, - { - code: "require('os').homedir", - options: [{ version: "2.3.0" }], - }, - { - code: "require('os').userInfo", - options: [{ version: "6.0.0" }], - }, - - // Ignores - { - code: "require('os').constants", - options: [{ version: "6.2.9", ignores: ["os.constants"] }], - }, - { - code: "var hooks = require('os'); hooks.constants", - options: [{ version: "6.2.9", ignores: ["os.constants"] }], - }, - { - code: "var { constants } = require('os'); constants", - options: [{ version: "6.2.9", ignores: ["os.constants"] }], - }, - { - code: "import os from 'os'; os.constants", - options: [{ version: "6.2.9", ignores: ["os.constants"] }], - }, - { - code: "import { constants } from 'os'; constants", - options: [{ version: "6.2.9", ignores: ["os.constants"] }], - }, - { - code: "require('os').homedir", - options: [{ version: "2.2.9", ignores: ["os.homedir"] }], - }, - { - code: "require('os').userInfo", - options: [{ version: "5.9.9", ignores: ["os.userInfo"] }], - }, - ], - invalid: [ - { - code: "require('os').constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "os.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "var hooks = require('os'); hooks.constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "os.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "var { constants } = require('os'); constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "os.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "import os from 'os'; os.constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "os.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "import { constants } from 'os'; constants", - options: [{ version: "6.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "os.constants", - supported: "6.3.0", - version: "6.2.9", - }, - }, - ], - }, - { - code: "require('os').homedir", - options: [{ version: "2.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "os.homedir", - supported: "2.3.0", - version: "2.2.9", - }, - }, - ], - }, - { - code: "require('os').userInfo", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "os.userInfo", - supported: "6.0.0", - version: "5.9.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/path.js b/tests/lib/rules/no-unsupported-features/path.js deleted file mode 100644 index 45d7fc15..00000000 --- a/tests/lib/rules/no-unsupported-features/path.js +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/path") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/path", rule, { - valid: [ - { - code: "require('path').toNamespacedPath()", - options: [{ version: "9.0.0" }], - }, - { - code: "var path = require('path'); path.toNamespacedPath()", - options: [{ version: "9.0.0" }], - }, - { - code: - "var { toNamespacedPath } = require('path'); toNamespacedPath()", - options: [{ version: "9.0.0" }], - }, - { - code: "import path from 'path'; path.toNamespacedPath()", - options: [{ version: "9.0.0" }], - }, - { - code: "import { toNamespacedPath } from 'path'; toNamespacedPath()", - options: [{ version: "9.0.0" }], - }, - - // Ignores - { - code: "require('path').toNamespacedPath()", - options: [{ version: "8.9.9", ignores: ["path.toNamespacedPath"] }], - }, - { - code: "var path = require('path'); path.toNamespacedPath()", - options: [{ version: "8.9.9", ignores: ["path.toNamespacedPath"] }], - }, - { - code: - "var { toNamespacedPath } = require('path'); toNamespacedPath()", - options: [{ version: "8.9.9", ignores: ["path.toNamespacedPath"] }], - }, - { - code: "import path from 'path'; path.toNamespacedPath()", - options: [{ version: "8.9.9", ignores: ["path.toNamespacedPath"] }], - }, - { - code: "import { toNamespacedPath } from 'path'; toNamespacedPath()", - options: [{ version: "8.9.9", ignores: ["path.toNamespacedPath"] }], - }, - ], - invalid: [ - { - code: "require('path').toNamespacedPath()", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "path.toNamespacedPath", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - { - code: "var path = require('path'); path.toNamespacedPath()", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "path.toNamespacedPath", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - { - code: - "var { toNamespacedPath } = require('path'); toNamespacedPath()", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "path.toNamespacedPath", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - { - code: "import path from 'path'; path.toNamespacedPath()", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "path.toNamespacedPath", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - { - code: "import { toNamespacedPath } from 'path'; toNamespacedPath()", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "path.toNamespacedPath", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/perf_hooks.js b/tests/lib/rules/no-unsupported-features/perf_hooks.js deleted file mode 100644 index b4d975a5..00000000 --- a/tests/lib/rules/no-unsupported-features/perf_hooks.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/perf_hooks") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/perf_hooks", rule, { - valid: [ - { - code: "require('perf_hooks')", - options: [{ version: "8.5.0" }], - }, - { - code: "import perf_hooks from 'perf_hooks'", - options: [{ version: "8.5.0" }], - }, - { - code: "require('perf_hooks')", - options: [{ version: "8.4.9", ignores: ["perf_hooks"] }], - }, - { - code: "import perf_hooks from 'perf_hooks'", - options: [{ version: "8.4.9", ignores: ["perf_hooks"] }], - }, - ], - invalid: [ - { - code: "require('perf_hooks')", - options: [{ version: "8.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "perf_hooks", - supported: "8.5.0", - version: "8.4.9", - }, - }, - ], - }, - { - code: "import perf_hooks from 'perf_hooks'", - options: [{ version: "8.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "perf_hooks", - supported: "8.5.0", - version: "8.4.9", - }, - }, - ], - }, - { - code: "import { open } from 'perf_hooks'", - options: [{ version: "8.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "perf_hooks", - supported: "8.5.0", - version: "8.4.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/process.js b/tests/lib/rules/no-unsupported-features/process.js deleted file mode 100644 index aba42b0f..00000000 --- a/tests/lib/rules/no-unsupported-features/process.js +++ /dev/null @@ -1,388 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/process") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - process: false, - require: false, - }, -}).run("no-unsupported-features/process", rule, { - valid: [ - { - code: "process.argv0", - options: [{ version: "6.4.0" }], - }, - { - code: "require('process').argv0", - options: [{ version: "6.4.0" }], - }, - { - code: "var c = require('process'); c.argv0", - options: [{ version: "6.4.0" }], - }, - { - code: "var { argv0 } = require('process'); argv0", - options: [{ version: "6.4.0" }], - }, - { - code: "import c from 'process'; c.argv0", - options: [{ version: "6.4.0" }], - }, - { - code: "process.channel", - options: [{ version: "7.1.0" }], - }, - { - code: "process.cpuUsage", - options: [{ version: "6.1.0" }], - }, - { - code: "process.emitWarning", - options: [{ version: "8.0.0" }], - }, - { - code: "process.getegid", - options: [{ version: "2.0.0" }], - }, - { - code: "process.geteuid", - options: [{ version: "2.0.0" }], - }, - { - code: "process.hasUncaughtExceptionCaptureCallback", - options: [{ version: "9.3.0" }], - }, - { - code: "process.ppid", - options: [{ version: "9.2.0" }], - }, - { - code: "process.release", - options: [{ version: "3.0.0" }], - }, - { - code: "process.setegid", - options: [{ version: "2.0.0" }], - }, - { - code: "process.seteuid", - options: [{ version: "2.0.0" }], - }, - { - code: "process.setUncaughtExceptionCaptureCallback", - options: [{ version: "9.3.0" }], - }, - - // Ignores - { - code: "process.argv0", - options: [{ version: "6.3.9", ignores: ["process.argv0"] }], - }, - { - code: "require('process').argv0", - options: [{ version: "6.3.9", ignores: ["process.argv0"] }], - }, - { - code: "var c = require('process'); c.argv0", - options: [{ version: "6.3.9", ignores: ["process.argv0"] }], - }, - { - code: "var { argv0 } = require('process'); argv0", - options: [{ version: "6.3.9", ignores: ["process.argv0"] }], - }, - { - code: "import c from 'process'; c.argv0", - options: [{ version: "6.3.9", ignores: ["process.argv0"] }], - }, - { - code: "process.channel", - options: [{ version: "7.0.9", ignores: ["process.channel"] }], - }, - { - code: "process.cpuUsage", - options: [{ version: "6.0.9", ignores: ["process.cpuUsage"] }], - }, - { - code: "process.emitWarning", - options: [{ version: "7.9.9", ignores: ["process.emitWarning"] }], - }, - { - code: "process.getegid", - options: [{ version: "1.9.9", ignores: ["process.getegid"] }], - }, - { - code: "process.geteuid", - options: [{ version: "1.9.9", ignores: ["process.geteuid"] }], - }, - { - code: "process.hasUncaughtExceptionCaptureCallback", - options: [ - { - version: "9.2.9", - ignores: ["process.hasUncaughtExceptionCaptureCallback"], - }, - ], - }, - { - code: "process.ppid", - options: [{ version: "9.1.9", ignores: ["process.ppid"] }], - }, - { - code: "process.release", - options: [{ version: "2.9.9", ignores: ["process.release"] }], - }, - { - code: "process.setegid", - options: [{ version: "1.9.9", ignores: ["process.setegid"] }], - }, - { - code: "process.seteuid", - options: [{ version: "1.9.9", ignores: ["process.seteuid"] }], - }, - { - code: "process.setUncaughtExceptionCaptureCallback", - options: [ - { - version: "9.2.9", - ignores: ["process.setUncaughtExceptionCaptureCallback"], - }, - ], - }, - ], - invalid: [ - { - code: "process.argv0", - options: [{ version: "6.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.argv0", - supported: "6.4.0", - version: "6.3.9", - }, - }, - ], - }, - { - code: "require('process').argv0", - options: [{ version: "6.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.argv0", - supported: "6.4.0", - version: "6.3.9", - }, - }, - ], - }, - { - code: "var c = require('process'); c.argv0", - options: [{ version: "6.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.argv0", - supported: "6.4.0", - version: "6.3.9", - }, - }, - ], - }, - { - code: "var { argv0 } = require('process'); argv0", - options: [{ version: "6.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.argv0", - supported: "6.4.0", - version: "6.3.9", - }, - }, - ], - }, - { - code: "import c from 'process'; c.argv0", - options: [{ version: "6.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.argv0", - supported: "6.4.0", - version: "6.3.9", - }, - }, - ], - }, - { - code: "process.channel", - options: [{ version: "7.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.channel", - supported: "7.1.0", - version: "7.0.9", - }, - }, - ], - }, - { - code: "process.cpuUsage", - options: [{ version: "6.0.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.cpuUsage", - supported: "6.1.0", - version: "6.0.9", - }, - }, - ], - }, - { - code: "process.emitWarning", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.emitWarning", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "process.getegid", - options: [{ version: "1.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.getegid", - supported: "2.0.0", - version: "1.9.9", - }, - }, - ], - }, - { - code: "process.geteuid", - options: [{ version: "1.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.geteuid", - supported: "2.0.0", - version: "1.9.9", - }, - }, - ], - }, - { - code: "process.hasUncaughtExceptionCaptureCallback", - options: [{ version: "9.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.hasUncaughtExceptionCaptureCallback", - supported: "9.3.0", - version: "9.2.9", - }, - }, - ], - }, - { - code: "process.ppid", - options: [{ version: "9.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.ppid", - supported: "9.2.0", - version: "9.1.9", - }, - }, - ], - }, - { - code: "process.release", - options: [{ version: "2.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.release", - supported: "3.0.0", - version: "2.9.9", - }, - }, - ], - }, - { - code: "process.setegid", - options: [{ version: "1.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.setegid", - supported: "2.0.0", - version: "1.9.9", - }, - }, - ], - }, - { - code: "process.seteuid", - options: [{ version: "1.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.seteuid", - supported: "2.0.0", - version: "1.9.9", - }, - }, - ], - }, - { - code: "process.setUncaughtExceptionCaptureCallback", - options: [{ version: "9.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "process.setUncaughtExceptionCaptureCallback", - supported: "9.3.0", - version: "9.2.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/stream.js b/tests/lib/rules/no-unsupported-features/stream.js deleted file mode 100644 index 62ae3ec8..00000000 --- a/tests/lib/rules/no-unsupported-features/stream.js +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/stream") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/stream", rule, { - valid: [ - { - code: "require('stream').finished()", - options: [{ version: "10.0.0" }], - }, - { - code: "var hooks = require('stream'); hooks.finished()", - options: [{ version: "10.0.0" }], - }, - { - code: "var { finished } = require('stream'); finished()", - options: [{ version: "10.0.0" }], - }, - { - code: "import stream from 'stream'; stream.finished()", - options: [{ version: "10.0.0" }], - }, - { - code: "import { finished } from 'stream'; finished()", - options: [{ version: "10.0.0" }], - }, - { - code: "require('stream').pipeline()", - options: [{ version: "10.0.0" }], - }, - - // Ignores - { - code: "require('stream').finished()", - options: [{ version: "9.9.9", ignores: ["stream.finished"] }], - }, - { - code: "var hooks = require('stream'); hooks.finished()", - options: [{ version: "9.9.9", ignores: ["stream.finished"] }], - }, - { - code: "var { finished } = require('stream'); finished()", - options: [{ version: "9.9.9", ignores: ["stream.finished"] }], - }, - { - code: "import stream from 'stream'; stream.finished()", - options: [{ version: "9.9.9", ignores: ["stream.finished"] }], - }, - { - code: "import { finished } from 'stream'; finished()", - options: [{ version: "9.9.9", ignores: ["stream.finished"] }], - }, - { - code: "require('stream').pipeline()", - options: [{ version: "9.9.9", ignores: ["stream.pipeline"] }], - }, - ], - invalid: [ - { - code: "require('stream').finished()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "stream.finished", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "var hooks = require('stream'); hooks.finished()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "stream.finished", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "var { finished } = require('stream'); finished()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "stream.finished", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "import stream from 'stream'; stream.finished()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "stream.finished", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "import { finished } from 'stream'; finished()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "stream.finished", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "require('stream').pipeline()", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "stream.pipeline", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/trace_events.js b/tests/lib/rules/no-unsupported-features/trace_events.js deleted file mode 100644 index e71a2f0c..00000000 --- a/tests/lib/rules/no-unsupported-features/trace_events.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/trace_events") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/trace_events", rule, { - valid: [ - { - code: "require('trace_events')", - options: [{ version: "10.0.0" }], - }, - { - code: "import trace_events from 'trace_events'", - options: [{ version: "10.0.0" }], - }, - { - code: "require('trace_events')", - options: [{ version: "9.9.9", ignores: ["trace_events"] }], - }, - { - code: "import trace_events from 'trace_events'", - options: [{ version: "9.9.9", ignores: ["trace_events"] }], - }, - ], - invalid: [ - { - code: "require('trace_events')", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "trace_events", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "import trace_events from 'trace_events'", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "trace_events", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "import { createTracing } from 'trace_events'", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "trace_events", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/url.js b/tests/lib/rules/no-unsupported-features/url.js deleted file mode 100644 index 41cf5774..00000000 --- a/tests/lib/rules/no-unsupported-features/url.js +++ /dev/null @@ -1,247 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/url") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - URL: false, - URLSearchParams: false, - require: false, - }, -}).run("no-unsupported-features/url", rule, { - valid: [ - { - code: "URL", - options: [{ version: "10.0.0" }], - }, - { - code: "URLSearchParams", - options: [{ version: "10.0.0" }], - }, - { - code: "require('url').URL", - options: [{ version: "7.0.0" }], - }, - { - code: "var cp = require('url'); cp.URL", - options: [{ version: "7.0.0" }], - }, - { - code: "var { URL } = require('url');", - options: [{ version: "7.0.0" }], - }, - { - code: "import cp from 'url'; cp.URL", - options: [{ version: "7.0.0" }], - }, - { - code: "import { URL } from 'url'", - options: [{ version: "7.0.0" }], - }, - { - code: "require('url').URLSearchParams", - options: [{ version: "7.5.0" }], - }, - { - code: "require('url').domainToASCII", - options: [{ version: "7.4.0" }], - }, - { - code: "require('url').domainToUnicode", - options: [{ version: "7.4.0" }], - }, - - // Ignores - { - code: "URL", - options: [{ version: "9.9.9", ignores: ["URL"] }], - }, - { - code: "URLSearchParams", - options: [{ version: "9.9.9", ignores: ["URLSearchParams"] }], - }, - { - code: "require('url').URL", - options: [{ version: "6.9.9", ignores: ["url.URL"] }], - }, - { - code: "var cp = require('url'); cp.URL", - options: [{ version: "6.9.9", ignores: ["url.URL"] }], - }, - { - code: "var { URL } = require('url');", - options: [{ version: "6.9.9", ignores: ["url.URL"] }], - }, - { - code: "import cp from 'url'; cp.URL", - options: [{ version: "6.9.9", ignores: ["url.URL"] }], - }, - { - code: "import { URL } from 'url'", - options: [{ version: "6.9.9", ignores: ["url.URL"] }], - }, - { - code: "require('url').URLSearchParams", - options: [{ version: "7.4.9", ignores: ["url.URLSearchParams"] }], - }, - { - code: "require('url').domainToASCII", - options: [{ version: "7.3.9", ignores: ["url.domainToASCII"] }], - }, - { - code: "require('url').domainToUnicode", - options: [{ version: "7.3.9", ignores: ["url.domainToUnicode"] }], - }, - ], - invalid: [ - { - code: "URL", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "URL", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "URLSearchParams", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "URLSearchParams", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "require('url').URL", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "url.URL", - supported: "7.0.0", - version: "6.9.9", - }, - }, - ], - }, - { - code: "var cp = require('url'); cp.URL", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "url.URL", - supported: "7.0.0", - version: "6.9.9", - }, - }, - ], - }, - { - code: "var { URL } = require('url');", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "url.URL", - supported: "7.0.0", - version: "6.9.9", - }, - }, - ], - }, - { - code: "import cp from 'url'; cp.URL", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "url.URL", - supported: "7.0.0", - version: "6.9.9", - }, - }, - ], - }, - { - code: "import { URL } from 'url'", - options: [{ version: "6.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "url.URL", - supported: "7.0.0", - version: "6.9.9", - }, - }, - ], - }, - { - code: "require('url').URLSearchParams", - options: [{ version: "7.4.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "url.URLSearchParams", - supported: "7.5.0", - version: "7.4.9", - }, - }, - ], - }, - { - code: "require('url').domainToASCII", - options: [{ version: "7.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "url.domainToASCII", - supported: "7.4.0", - version: "7.3.9", - }, - }, - ], - }, - { - code: "require('url').domainToUnicode", - options: [{ version: "7.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "url.domainToUnicode", - supported: "7.4.0", - version: "7.3.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/util.js b/tests/lib/rules/no-unsupported-features/util.js deleted file mode 100644 index 7537c6d7..00000000 --- a/tests/lib/rules/no-unsupported-features/util.js +++ /dev/null @@ -1,341 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/util") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/util", rule, { - valid: [ - { - code: "require('util').callbackify", - options: [{ version: "8.2.0" }], - }, - { - code: "var hooks = require('util'); hooks.callbackify", - options: [{ version: "8.2.0" }], - }, - { - code: "var { callbackify } = require('util'); callbackify", - options: [{ version: "8.2.0" }], - }, - { - code: "import util from 'util'; util.callbackify", - options: [{ version: "8.2.0" }], - }, - { - code: "import { callbackify } from 'util'; callbackify", - options: [{ version: "8.2.0" }], - }, - { - code: "require('util').formatWithOptions", - options: [{ version: "10.0.0" }], - }, - { - code: "require('util').getSystemErrorName", - options: [{ version: "9.7.0" }], - }, - { - code: "require('util').inspect.custom", - options: [{ version: "6.6.0" }], - }, - { - code: "require('util').inspect.defaultOptions", - options: [{ version: "6.4.0" }], - }, - { - code: "require('util').isDeepStrictEqual", - options: [{ version: "9.0.0" }], - }, - { - code: "require('util').promisify", - options: [{ version: "8.0.0" }], - }, - { - code: "require('util').TextDecoder", - options: [{ version: "8.3.0" }], - }, - { - code: "require('util').TextEncoder", - options: [{ version: "8.3.0" }], - }, - { - code: "require('util').types", - options: [{ version: "10.0.0" }], - }, - - // Ignores - { - code: "require('util').callbackify", - options: [{ version: "8.1.9", ignores: ["util.callbackify"] }], - }, - { - code: "var hooks = require('util'); hooks.callbackify", - options: [{ version: "8.1.9", ignores: ["util.callbackify"] }], - }, - { - code: "var { callbackify } = require('util'); callbackify", - options: [{ version: "8.1.9", ignores: ["util.callbackify"] }], - }, - { - code: "import util from 'util'; util.callbackify", - options: [{ version: "8.1.9", ignores: ["util.callbackify"] }], - }, - { - code: "import { callbackify } from 'util'; callbackify", - options: [{ version: "8.1.9", ignores: ["util.callbackify"] }], - }, - { - code: "require('util').formatWithOptions", - options: [ - { version: "9.9.9", ignores: ["util.formatWithOptions"] }, - ], - }, - { - code: "require('util').getSystemErrorName", - options: [ - { version: "9.6.9", ignores: ["util.getSystemErrorName"] }, - ], - }, - { - code: "require('util').inspect.custom", - options: [{ version: "6.5.9", ignores: ["util.inspect.custom"] }], - }, - { - code: "require('util').inspect.defaultOptions", - options: [ - { version: "6.3.9", ignores: ["util.inspect.defaultOptions"] }, - ], - }, - { - code: "require('util').isDeepStrictEqual", - options: [ - { version: "8.9.9", ignores: ["util.isDeepStrictEqual"] }, - ], - }, - { - code: "require('util').promisify", - options: [{ version: "7.9.9", ignores: ["util.promisify"] }], - }, - { - code: "require('util').TextDecoder", - options: [{ version: "8.2.9", ignores: ["util.TextDecoder"] }], - }, - { - code: "require('util').TextEncoder", - options: [{ version: "8.2.9", ignores: ["util.TextEncoder"] }], - }, - { - code: "require('util').types", - options: [{ version: "9.9.9", ignores: ["util.types"] }], - }, - ], - invalid: [ - { - code: "require('util').callbackify", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.callbackify", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "var hooks = require('util'); hooks.callbackify", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.callbackify", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "var { callbackify } = require('util'); callbackify", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.callbackify", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "import util from 'util'; util.callbackify", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.callbackify", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "import { callbackify } from 'util'; callbackify", - options: [{ version: "8.1.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.callbackify", - supported: "8.2.0", - version: "8.1.9", - }, - }, - ], - }, - { - code: "require('util').formatWithOptions", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.formatWithOptions", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - { - code: "require('util').getSystemErrorName", - options: [{ version: "9.6.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.getSystemErrorName", - supported: "9.7.0", - version: "9.6.9", - }, - }, - ], - }, - { - code: "require('util').inspect.custom", - options: [{ version: "6.5.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.inspect.custom", - supported: "6.6.0", - version: "6.5.9", - }, - }, - ], - }, - { - code: "require('util').inspect.defaultOptions", - options: [{ version: "6.3.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.inspect.defaultOptions", - supported: "6.4.0", - version: "6.3.9", - }, - }, - ], - }, - { - code: "require('util').isDeepStrictEqual", - options: [{ version: "8.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.isDeepStrictEqual", - supported: "9.0.0", - version: "8.9.9", - }, - }, - ], - }, - { - code: "require('util').promisify", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.promisify", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('util').TextDecoder", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.TextDecoder", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "require('util').TextEncoder", - options: [{ version: "8.2.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.TextEncoder", - supported: "8.3.0", - version: "8.2.9", - }, - }, - ], - }, - { - code: "require('util').types", - options: [{ version: "9.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "util.types", - supported: "10.0.0", - version: "9.9.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/v8.js b/tests/lib/rules/no-unsupported-features/v8.js deleted file mode 100644 index 851d576c..00000000 --- a/tests/lib/rules/no-unsupported-features/v8.js +++ /dev/null @@ -1,384 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/v8") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/v8", rule, { - valid: [ - { - code: "require('v8')", - options: [{ version: "1.0.0" }], - }, - { - code: "import hooks from 'v8'", - options: [{ version: "1.0.0" }], - }, - { - code: "require('v8').cachedDataVersionTag()", - options: [{ version: "8.0.0" }], - }, - { - code: "var hooks = require('v8'); hooks.cachedDataVersionTag()", - options: [{ version: "8.0.0" }], - }, - { - code: - "var { cachedDataVersionTag } = require('v8'); cachedDataVersionTag()", - options: [{ version: "8.0.0" }], - }, - { - code: "import v8 from 'v8'; v8.cachedDataVersionTag()", - options: [{ version: "8.0.0" }], - }, - { - code: - "import { cachedDataVersionTag } from 'v8'; cachedDataVersionTag()", - options: [{ version: "8.0.0" }], - }, - { - code: "require('v8').getHeapSpaceStatistics()", - options: [{ version: "6.0.0" }], - }, - { - code: "require('v8').serialize()", - options: [{ version: "8.0.0" }], - }, - { - code: "require('v8').deserialize()", - options: [{ version: "8.0.0" }], - }, - { - code: "require('v8').Serializer", - options: [{ version: "8.0.0" }], - }, - { - code: "require('v8').Deserializer", - options: [{ version: "8.0.0" }], - }, - { - code: "require('v8').DefaultSerializer", - options: [{ version: "8.0.0" }], - }, - { - code: "require('v8').DefaultDeserializer", - options: [{ version: "8.0.0" }], - }, - - // Ignores. - { - code: "require('v8')", - options: [{ version: "0.12.99", ignores: ["v8"] }], - }, - { - code: "import hooks from 'v8'", - options: [{ version: "0.12.99", ignores: ["v8"] }], - }, - { - code: "import { cachedDataVersionTag } from 'v8'", - options: [ - { - version: "0.12.99", - ignores: ["v8", "v8.cachedDataVersionTag"], - }, - ], - }, - { - code: "require('v8').cachedDataVersionTag()", - options: [ - { version: "7.9.9", ignores: ["v8.cachedDataVersionTag"] }, - ], - }, - { - code: "var hooks = require('v8'); hooks.cachedDataVersionTag()", - options: [ - { version: "7.9.9", ignores: ["v8.cachedDataVersionTag"] }, - ], - }, - { - code: - "var { cachedDataVersionTag } = require('v8'); cachedDataVersionTag()", - options: [ - { version: "7.9.9", ignores: ["v8.cachedDataVersionTag"] }, - ], - }, - { - code: "import v8 from 'v8'; v8.cachedDataVersionTag()", - options: [ - { version: "7.9.9", ignores: ["v8.cachedDataVersionTag"] }, - ], - }, - { - code: - "import { cachedDataVersionTag } from 'v8'; cachedDataVersionTag()", - options: [ - { version: "7.9.9", ignores: ["v8.cachedDataVersionTag"] }, - ], - }, - { - code: "require('v8').getHeapSpaceStatistics()", - options: [ - { version: "5.9.9", ignores: ["v8.getHeapSpaceStatistics"] }, - ], - }, - { - code: "require('v8').serialize()", - options: [{ version: "7.9.9", ignores: ["v8.serialize"] }], - }, - { - code: "require('v8').deserialize()", - options: [{ version: "7.9.9", ignores: ["v8.deserialize"] }], - }, - { - code: "require('v8').Serializer", - options: [{ version: "7.9.9", ignores: ["v8.Serializer"] }], - }, - { - code: "require('v8').Deserializer", - options: [{ version: "7.9.9", ignores: ["v8.Deserializer"] }], - }, - { - code: "require('v8').DefaultSerializer", - options: [{ version: "7.9.9", ignores: ["v8.DefaultSerializer"] }], - }, - { - code: "require('v8').DefaultDeserializer", - options: [ - { version: "7.9.9", ignores: ["v8.DefaultDeserializer"] }, - ], - }, - ], - invalid: [ - { - code: "require('v8')", - options: [{ version: "0.12.99" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8", - supported: "1.0.0", - version: "0.12.99", - }, - }, - ], - }, - { - code: "import hooks from 'v8'", - options: [{ version: "0.12.99" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8", - supported: "1.0.0", - version: "0.12.99", - }, - }, - ], - }, - { - code: "import { cachedDataVersionTag } from 'v8'", - options: [{ version: "0.12.99" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8", - supported: "1.0.0", - version: "0.12.99", - }, - }, - { - messageId: "unsupported", - data: { - name: "v8.cachedDataVersionTag", - supported: "8.0.0", - version: "0.12.99", - }, - }, - ], - }, - { - code: "require('v8').cachedDataVersionTag()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.cachedDataVersionTag", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "var hooks = require('v8'); hooks.cachedDataVersionTag()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.cachedDataVersionTag", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: - "var { cachedDataVersionTag } = require('v8'); cachedDataVersionTag()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.cachedDataVersionTag", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "import v8 from 'v8'; v8.cachedDataVersionTag()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.cachedDataVersionTag", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: - "import { cachedDataVersionTag } from 'v8'; cachedDataVersionTag()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.cachedDataVersionTag", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('v8').getHeapSpaceStatistics()", - options: [{ version: "5.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.getHeapSpaceStatistics", - supported: "6.0.0", - version: "5.9.9", - }, - }, - ], - }, - { - code: "require('v8').serialize()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.serialize", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('v8').deserialize()", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.deserialize", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('v8').Serializer", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.Serializer", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('v8').Deserializer", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.Deserializer", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('v8').DefaultSerializer", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.DefaultSerializer", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - { - code: "require('v8').DefaultDeserializer", - options: [{ version: "7.9.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "v8.DefaultDeserializer", - supported: "8.0.0", - version: "7.9.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/vm.js b/tests/lib/rules/no-unsupported-features/vm.js deleted file mode 100644 index 8548282e..00000000 --- a/tests/lib/rules/no-unsupported-features/vm.js +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/vm") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/vm", rule, { - valid: [ - { - code: "require('vm').Module", - options: [{ version: "9.6.0" }], - }, - { - code: "var vm = require('vm'); vm.Module", - options: [{ version: "9.6.0" }], - }, - { - code: "var { Module } = require('vm'); Module", - options: [{ version: "9.6.0" }], - }, - { - code: "import vm from 'vm'; vm.Module", - options: [{ version: "9.6.0" }], - }, - { - code: "import { Module } from 'vm'; Module", - options: [{ version: "9.6.0" }], - }, - - // Ignores - { - code: "require('vm').Module", - options: [{ version: "9.5.9", ignores: ["vm.Module"] }], - }, - { - code: "var vm = require('vm'); vm.Module", - options: [{ version: "9.5.9", ignores: ["vm.Module"] }], - }, - { - code: "var { Module } = require('vm'); Module", - options: [{ version: "9.5.9", ignores: ["vm.Module"] }], - }, - { - code: "import vm from 'vm'; vm.Module", - options: [{ version: "9.5.9", ignores: ["vm.Module"] }], - }, - { - code: "import { Module } from 'vm'; Module", - options: [{ version: "9.5.9", ignores: ["vm.Module"] }], - }, - ], - invalid: [ - { - code: "require('vm').Module", - options: [{ version: "9.5.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "vm.Module", - supported: "9.6.0", - version: "9.5.9", - }, - }, - ], - }, - { - code: "var vm = require('vm'); vm.Module", - options: [{ version: "9.5.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "vm.Module", - supported: "9.6.0", - version: "9.5.9", - }, - }, - ], - }, - { - code: "var { Module } = require('vm'); Module", - options: [{ version: "9.5.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "vm.Module", - supported: "9.6.0", - version: "9.5.9", - }, - }, - ], - }, - { - code: "import vm from 'vm'; vm.Module", - options: [{ version: "9.5.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "vm.Module", - supported: "9.6.0", - version: "9.5.9", - }, - }, - ], - }, - { - code: "import { Module } from 'vm'; Module", - options: [{ version: "9.5.9" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "vm.Module", - supported: "9.6.0", - version: "9.5.9", - }, - }, - ], - }, - ], -}) diff --git a/tests/lib/rules/no-unsupported-features/worker_threads.js b/tests/lib/rules/no-unsupported-features/worker_threads.js deleted file mode 100644 index c324ab5c..00000000 --- a/tests/lib/rules/no-unsupported-features/worker_threads.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict" - -const RuleTester = require("eslint").RuleTester -const rule = require("../../../../lib/rules/no-unsupported-features/worker_threads") - -new RuleTester({ - parserOptions: { - ecmaVersion: 2015, - sourceType: "module", - }, - globals: { - require: false, - }, -}).run("no-unsupported-features/worker_threads", rule, { - valid: [ - { - code: "require('worker_threads')", - options: [{ version: "10.5.0" }], - }, - { - code: "import worker_threads from 'worker_threads'", - options: [{ version: "10.5.0" }], - }, - { - code: "require('worker_threads')", - options: [{ version: "10.4.99", ignores: ["worker_threads"] }], - }, - { - code: "import worker_threads from 'worker_threads'", - options: [{ version: "10.4.99", ignores: ["worker_threads"] }], - }, - ], - invalid: [ - { - code: "require('worker_threads')", - options: [{ version: "10.4.99" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "worker_threads", - supported: "10.5.0", - version: "10.4.99", - }, - }, - ], - }, - { - code: "import worker_threads from 'worker_threads'", - options: [{ version: "10.4.99" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "worker_threads", - supported: "10.5.0", - version: "10.4.99", - }, - }, - ], - }, - { - code: "import { Worker } from 'worker_threads'", - options: [{ version: "10.4.99" }], - errors: [ - { - messageId: "unsupported", - data: { - name: "worker_threads", - supported: "10.5.0", - version: "10.4.99", - }, - }, - ], - }, - ], -})