8000 [[FIX]] Recognize ES2020 globals · jshint/jshint@b1426f1 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit b1426f1

Browse files
jugglinmikerwaldron
authored andcommitted
[[FIX]] Recognize ES2020 globals
Include `globalThis` in the set of global bindings available in ES2020-compliant runtimes. Add the instructions necessary to apply this set. Extend the document of the `esversion` option to mention these features.
1 parent be94b1d commit b1426f1

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/jshint.js

+4
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ var JSHINT = (function() {
242242
combine(predefined, vars.ecmaIdentifiers[8]);
243243
}
244244

245+
if (state.inES11()) {
246+
combine(predefined, vars.ecmaIdentifiers[11]);
247+
}
248+
245249
/**
246250
* Use `in` to check for the presence of any explicitly-specified value for
247251
* `globalstrict` because both `true` and `false` should trigger an error.

src/options.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,8 @@ exports.val = {
10531053
* Notable additions: optional catch bindings.
10541054
* - `11` - To enable language features introduced by ECMAScript 11. Notable
10551055
* additions: "export * as ns from 'module'", `import.meta`, the nullish
1056-
* coalescing operator, and optional chaining, and dynamic import.
1056+
* coalescing operator, the BigInt type, the `globalThis` binding,
1057+
* optional chaining, and dynamic import.
10571058
*/
10581059
esversion: 5
10591060
};

src/vars.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ exports.ecmaIdentifiers = {
6868
SharedArrayBuffer : false
6969
},
7070
11: {
71-
BigInt : false
71+
BigInt : false,
72+
globalThis : false
7273
}
7374
};
7475

tests/unit/core.js

+23
Original file line numberDiff line numberDiff line change
@@ -2582,3 +2582,26 @@ exports.constWithoutInit = function(test) {
25822582

25832583
test.done();
25842584
};
2585+
2586+
// regression test for gh-3595
2587+
exports.bigIntCtor = function(test) {
2588+
var code = [
2589+
"void BigInt;",
2590+
"void globalThis;"
2591+
];
2592+
2593+
TestRun(test)
2594+
.addError(1, 6, "'BigInt' is not defined.")
2595+
.addError(2, 6, "'globalThis' is not defined.")
2596+
.test(code, { undef: true });
2597+
2598+
TestRun(test)
2599+
.addError(1, 6, "'BigInt' is not defined.")
2600+
.addError(2, 6, "'globalThis' is not defined.")
2601+
.test(code, { undef: true, esversion: 10 });
2602+
2603+
TestRun(test)
2604+
.test(code, { undef: true, esversion: 11 });
2605+
2606+
test.done();
2607+
};

0 commit comments

Comments
 (0)
0