Skip to content

Commit 04051ed

Browse files
committedDec 26, 2019
💥 update node/no-unsupported-features/es-builtins to recognize globalThis
1 parent 4295f6a commit 04051ed

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed
 

‎docs/rules/no-unsupported-features/es-builtins.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ The `"ignores"` option accepts an array of the following strings.
6767
- `"BigInt64Array"`
6868
- `"BigUint64Array"`
6969
- `"Promise.allSettled"`
70+
- `"globalThis"`
7071

7172
**ES2019:**
7273

‎lib/rules/no-unsupported-features/es-builtins.js

+3
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ const trackMap = {
128128
SharedArrayBuffer: {
129129
[READ]: { supported: "8.10.0" },
130130
},
131+
globalThis: {
132+
[READ]: { supported: "12.0.0" },
133+
},
131134
},
132135
}
133136

‎tests/lib/rules/no-unsupported-features/es-builtins.js

+43
Original file line numberDiff line numberDiff line change
@@ -2228,5 +2228,48 @@ ruleTester.run(
22282228
},
22292229
],
22302230
},
2231+
{
2232+
keyword: "globalThis",
2233+
valid: [
2234+
{
2235+
code: "(function(globalThis) { globalThis }(a))",
2236+
options: [{ version: "12.0.0" }],
2237+
},
2238+
{
2239+
code: "globalThis",
2240+
options: [{ version: "12.0.0" }],
2241+
},
2242+
],
2243+
invalid: [
2244+
{
2245+
code: "globalThis",
2246+
options: [{ version: "11.9.9" }],
2247+
errors: [
2248+
{
2249+
messageId: "unsupported",
2250+
data: {
2251+
name: "globalThis",
2252+
supported: "12.0.0",
2253+
version: "11.9.9",
2254+
},
2255+
},
2256+
],
2257+
},
2258+
{
2259+
code: "function wrap() { globalThis }",
2260+
options: [{ version: "11.9.9" }],
2261+
errors: [
2262+
{
2263+
messageId: "unsupported",
2264+
data: {
2265+
name: "globalThis",
2266+
supported: "12.0.0",
2267+
version: "11.9.9",
2268+
},
2269+
},
2270+
],
2271+
},
2272+
],
2273+
},
22312274
])
22322275
)

0 commit comments

Comments
 (0)
Please sign in to comment.