Skip to content

Commit

Permalink
💥 update no-unsupported-features/node-builtins rule based on Node 13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Nov 24, 2019
1 parent 0b0c2aa commit b6cb9a0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 23 deletions.
14 changes: 13 additions & 1 deletion docs/rules/no-unsupported-features/node-builtins.md
Expand Up @@ -10,7 +10,7 @@ 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 v12.0.0 Documentation](https://nodejs.org/docs/v12.0.0/api/).
This rule reports APIs of Node.js built-in APIs on the basis of [Node.js v13.2.0 Documentation](https://nodejs.org/docs/v13.2.0/api/).

### Configured Node.js version range

Expand Down Expand Up @@ -201,6 +201,8 @@ The `"ignores"` option accepts an array of the following strings.
- `"fs.realpath.native"`
- `"fs.realpathSync.native"`
- `"fs.promises"`
- `"fs.writev"`
- `"fs.writevSync"`

**`http2` module:**

Expand All @@ -212,7 +214,14 @@ The `"ignores"` option accepts an array of the following strings.

**`module` module:**

- `"module.Module.builtinModules"`
- `"module.Module.createRequireFromPath"`
- `"module.Module.createRequire"`
- `"module.Module.syncBuiltinESMExports"`
- `"module.builtinModules"`
- `"module.createRequireFromPath"`
- `"module.createRequire"`
- `"module.syncBuiltinESMExports"`

**`os` module:**

Expand Down Expand Up @@ -246,6 +255,7 @@ The `"ignores"` option accepts an array of the following strings.
- `"process.ppid"`
- `"process.release"`
- `"process.report"`
- `"process.resourceUsage"`
- `"process.setegid"`
- `"process.seteuid"`
- `"process.setUncaughtExceptionCaptureCallback"`
Expand All @@ -256,6 +266,7 @@ The `"ignores"` option accepts an array of the following strings.

**`stream` module:**

- `"stream.Readable.from"`
- `"stream.finished"`
- `"stream.pipeline"`

Expand Down Expand Up @@ -294,6 +305,7 @@ The `"ignores"` option accepts an array of the following strings.
- `"v8.Serializer"`
- `"v8.cachedDataVersionTag"`
- `"v8.deserialize"`
- `"v8.getHeapCodeStatistics"`
- `"v8.getHeapSnapshot"`
- `"v8.getHeapSpaceStatistics"`
- `"v8.serialize"`
Expand Down
22 changes: 19 additions & 3 deletions lib/rules/no-unsupported-features/node-builtins.js
Expand Up @@ -123,15 +123,26 @@ const trackMap = {
promises: {
[READ]: { supported: "11.14.0", experimental: "10.1.0" },
},
writev: { [READ]: { supported: "12.9.0" } },
writevSync: { [READ]: { supported: "12.9.0" } },
},
http2: {
[READ]: { supported: "8.4.0" },
[READ]: { supported: "10.10.0", experimental: "8.4.0" },
},
inspector: {
[READ]: { supported: "8.0.0" },
[READ]: { supported: null, experimental: "8.0.0" },
},
module: {
Module: {
builtinModules: { [READ]: { supported: "9.3.0" } },
createRequireFromPath: { [READ]: { supported: "10.12.0" } },
createRequire: { [READ]: { supported: "12.2.0" } },
syncBuiltinESMExports: { [READ]: { supported: "12.12.0" } },
},
builtinModules: { [READ]: { supported: "9.3.0" } },
createRequireFromPath: { [READ]: { supported: "10.12.0" } },
createRequire: { [READ]: { supported: "12.2.0" } },
syncBuiltinESMExports: { [READ]: { supported: "12.12.0" } },
},
os: {
constants: {
Expand Down Expand Up @@ -167,6 +178,7 @@ const trackMap = {
ppid: { [READ]: { supported: "9.2.0" } },
release: { [READ]: { supported: "3.0.0" } },
report: { [READ]: { supported: null, experimental: "11.8.0" } },
resourceUsage: { [READ]: { supported: "12.6.0" } },
setegid: { [READ]: { supported: "2.0.0" } },
seteuid: { [READ]: { supported: "2.0.0" } },
setUncaughtExceptionCaptureCallback: {
Expand All @@ -182,6 +194,9 @@ const trackMap = {
},
},
stream: {
Readable: {
from: { [READ]: { supported: "12.3.0" } },
},
finished: { [READ]: { supported: "10.0.0" } },
pipeline: { [READ]: { supported: "10.0.0" } },
},
Expand Down Expand Up @@ -220,6 +235,7 @@ const trackMap = {
Serializer: { [READ]: { supported: "8.0.0" } },
cachedDataVersionTag: { [READ]: { supported: "8.0.0" } },
deserialize: { [READ]: { supported: "8.0.0" } },
getHeapCodeStatistics: { [READ]: { supported: "12.8.0" } },
getHeapSnapshot: { [READ]: { supported: "11.13.0" } },
getHeapSpaceStatistics: { [READ]: { supported: "6.0.0" } },
serialize: { [READ]: { supported: "8.0.0" } },
Expand All @@ -230,7 +246,7 @@ const trackMap = {
compileFunction: { [READ]: { supported: "10.10.0" } },
},
worker_threads: {
[READ]: { supported: null, experimental: "10.5.0" },
[READ]: { supported: "12.11.0", experimental: "10.5.0" },
},
},
}
Expand Down
38 changes: 19 additions & 19 deletions tests/lib/rules/no-unsupported-features/node-builtins.js
Expand Up @@ -2576,11 +2576,11 @@ new RuleTester({
valid: [
{
code: "require('http2')",
options: [{ version: "8.4.0" }],
options: [{ version: "10.10.0" }],
},
{
code: "import http2 from 'http2'",
options: [{ version: "8.4.0" }],
options: [{ version: "10.10.0" }],
},
{
code: "require('http2')",
Expand All @@ -2600,7 +2600,7 @@ new RuleTester({
messageId: "unsupported",
data: {
name: "http2",
supported: "8.4.0",
supported: "10.10.0",
version: "8.3.9",
},
},
Expand All @@ -2614,7 +2614,7 @@ new RuleTester({
messageId: "unsupported",
data: {
name: "http2",
supported: "8.4.0",
supported: "10.10.0",
version: "8.3.9",
},
},
Expand All @@ -2628,7 +2628,7 @@ new RuleTester({
messageId: "unsupported",
data: {
name: "http2",
supported: "8.4.0",
supported: "10.10.0",
version: "8.3.9",
},
},
Expand All @@ -2642,14 +2642,6 @@ new RuleTester({
//----------------------------------------------------------------------
{
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"] }],
Expand All @@ -2668,7 +2660,7 @@ new RuleTester({
messageId: "unsupported",
data: {
name: "inspector",
supported: "8.0.0",
supported: "???",
version: "7.9.9",
},
},
Expand All @@ -2682,7 +2674,7 @@ new RuleTester({
messageId: "unsupported",
data: {
name: "inspector",
supported: "8.0.0",
supported: "???",
version: "7.9.9",
},
},
Expand All @@ -2696,7 +2688,7 @@ new RuleTester({
messageId: "unsupported",
data: {
name: "inspector",
supported: "8.0.0",
supported: "???",
version: "7.9.9",
},
},
Expand Down Expand Up @@ -4914,6 +4906,14 @@ new RuleTester({
{ version: "10.4.99", ignores: ["worker_threads"] },
],
},
{
code: "require('worker_threads')",
options: [{ version: "12.11.0" }],
},
{
code: "import worker_threads from 'worker_threads'",
options: [{ version: "12.11.0" }],
},
],
invalid: [
{
Expand All @@ -4924,7 +4924,7 @@ new RuleTester({
messageId: "unsupported",
data: {
name: "worker_threads",
supported: "???",
supported: "12.11.0",
version: "10.5.0",
},
},
Expand All @@ -4938,7 +4938,7 @@ new RuleTester({
messageId: "unsupported",
data: {
name: "worker_threads",
supported: "???",
supported: "12.11.0",
version: "10.5.0",
},
},
Expand All @@ -4952,7 +4952,7 @@ new RuleTester({
messageId: "unsupported",
data: {
name: "worker_threads",
supported: "???",
supported: "12.11.0",
version: "10.5.0",
},
},
Expand Down

0 comments on commit b6cb9a0

Please sign in to comment.