Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
💥 update node/no-unsupported-features/es-builtins to recognize global…
…This
  • Loading branch information
mysticatea committed Dec 26, 2019
1 parent 4295f6a commit 04051ed
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/rules/no-unsupported-features/es-builtins.md
Expand Up @@ -67,6 +67,7 @@ The `"ignores"` option accepts an array of the following strings.
- `"BigInt64Array"`
- `"BigUint64Array"`
- `"Promise.allSettled"`
- `"globalThis"`

**ES2019:**

Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-unsupported-features/es-builtins.js
Expand Up @@ -128,6 +128,9 @@ const trackMap = {
SharedArrayBuffer: {
[READ]: { supported: "8.10.0" },
},
globalThis: {
[READ]: { supported: "12.0.0" },
},
},
}

Expand Down
43 changes: 43 additions & 0 deletions tests/lib/rules/no-unsupported-features/es-builtins.js
Expand Up @@ -2228,5 +2228,48 @@ ruleTester.run(
},
],
},
{
keyword: "globalThis",
valid: [
{
code: "(function(globalThis) { globalThis }(a))",
options: [{ version: "12.0.0" }],
},
{
code: "globalThis",
options: [{ version: "12.0.0" }],
},
],
invalid: [
{
code: "globalThis",
options: [{ version: "11.9.9" }],
errors: [
{
messageId: "unsupported",
data: {
name: "globalThis",
supported: "12.0.0",
version: "11.9.9",
},
},
],
},
{
code: "function wrap() { globalThis }",
options: [{ version: "11.9.9" }],
errors: [
{
messageId: "unsupported",
data: {
name: "globalThis",
supported: "12.0.0",
version: "11.9.9",
},
},
],
},
],
},
])
)

0 comments on commit 04051ed

Please sign in to comment.