Skip to content

Commit

Permalink
[[CHORE]] Refactor to support esversion: 2017
Browse files Browse the repository at this point in the history
This change simply enables the configuration settings `esversion: 8` and
`esversion: 2017` without introducing any new parsing/linting
functionality.
  • Loading branch information
jugglinmike committed Jan 14, 2019
1 parent 4a5a4a5 commit dc29e78
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,11 +674,13 @@ var JSHINT = (function() {
case "5":
case "6":
case "7":
case "8":
state.option.moz = false;
state.option.esversion = +val;
break;
case "2015":
case "2016":
case "2017":
state.option.moz = false;
// Translate specification publication year to version number.
state.option.esversion = +val - 2009;
Expand Down
2 changes: 1 addition & 1 deletion tests/test262/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = function(test) {
var isModule = !!test.attrs.flags.module;

try {
JSHint(test.contents, { esversion: 7, maxerr: Infinity, module: isModule });
JSHint(test.contents, { esversion: 8, maxerr: Infinity, module: isModule });
} catch (e) {
return false;
}
Expand Down
12 changes: 11 additions & 1 deletion tests/unit/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -4036,7 +4036,9 @@ exports.esversion = function(test) {
"// jshint esversion: 6",
"// jshint esversion: 2015",
"// jshint esversion: 7",
"// jshint esversion: 2016"
"// jshint esversion: 2016",
"// jshint esversion: 8",
"// jshint esversion: 2017"
];

TestRun(test, "Value")
Expand Down Expand Up @@ -4086,6 +4088,9 @@ exports.esversion = function(test) {
TestRun(test, "ES6 syntax as ES7")
.test(es6code, { esversion: 7 });

TestRun(test, "ES6 syntax as ES8")
.test(es6code, { esversion: 8 });


// Array comprehensions aren't defined in ECMAScript 6,
// but they can be enabled using the `esnext` option
Expand All @@ -4104,6 +4109,11 @@ exports.esversion = function(test) {
"(use moz option).")
.test(arrayComprehension, { esversion: 7 });

TestRun(test, "array comprehensions - esversion: 8")
.addError(2, 9, "'array comprehension' is only available in Mozilla JavaScript extensions " +
"(use moz option).")
.test(arrayComprehension, { esversion: 8 });

TestRun(test, "array comprehensions - esnext: true")
.test(arrayComprehension, { esnext: true });

Expand Down
8 changes: 8 additions & 0 deletions tests/unit/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5888,6 +5888,7 @@ exports["fat arrows support"] = function (test) {

run.test(code, { undef: true, esnext: true });
run.test(code, { undef: true, esversion: 2016 });
run.test(code, { undef: true, esversion: 2017 });

run = TestRun(test)
.addError(1, 14, "'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').")
Expand Down Expand Up @@ -8524,6 +8525,7 @@ exports["new.target"] = function (test) {

TestRun(test, "only in ES6").test(code, { esnext: true });
TestRun(test, "ES7").test(code, { esversion: 7 });
TestRun(test, "ES8").test(code, { esversion: 8 });

var code2 = [
"var a = new.target;",
Expand Down Expand Up @@ -8561,6 +8563,12 @@ exports["new.target"] = function (test) {
.addError(6, 13, "'new.target' must be in function scope.")
.test(code2, { esversion: 2016 });

TestRun(test, "must be in function scope")
.addError(1, 12, "'new.target' must be in function scope.")
.addError(4, 15, "'new.target' must be in function scope.")
.addError(6, 13, "'new.target' must be in function scope.")
.test(code2, { esversion: 2017 });

var code3 = [
"var x = new.meta;"
];
Expand Down

0 comments on commit dc29e78

Please sign in to comment.