Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb1426f1

Browse files
jugglinmikerwaldron
authored andcommitted
[[FIX]] Recognize ES2020 globals
Include `globalThis` in the set of global bindings available inES2020-compliant runtimes. Add the instructions necessary to apply thisset. Extend the document of the `esversion` option to mention thesefeatures.
1 parentbe94b1d commitb1426f1

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

‎src/jshint.js‎

Lines changed: 4 additions & 0 deletions
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‎

Lines changed: 2 additions & 1 deletion
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‎

Lines changed: 2 additions & 1 deletion
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‎

Lines changed: 23 additions & 0 deletions
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+
varcode=[
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)

[8]ページ先頭

©2009-2025 Movatter.jp