diff --git a/package.json b/package.json index 262410eda0..e8fb506021 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "scripts": { "browser-test-server": "node tests/helpers/browser/server", "build": "node bin/build", - "coverage": "istanbul -- cover ./node_modules/nodeunit/bin/nodeunit tests/unit tests/unit/unstable", + "coverage": "istanbul -- cover ./node_modules/nodeunit/bin/nodeunit tests/unit", "coverage-report": "npm run coverage && istanbul report html", "data": "node scripts/generate-identifier-data", "fetch-test262": "git submodule init && git submodule update", @@ -34,7 +34,7 @@ "test-cli": "nodeunit tests/cli.js", "test-node": "npm run test-unit && npm run test-cli && npm run test-regression", "test-regression": "nodeunit tests/regression", - "test-unit": "nodeunit tests/unit tests/unit/unstable", + "test-unit": "nodeunit tests/unit", "test-website": "node tests/website.js", "test": "npm run test-node && npm run test-browser" }, diff --git a/src/jshint.js b/src/jshint.js index 1705cc71e0..24a7abd184 100644 --- a/src/jshint.js +++ b/src/jshint.js @@ -1472,8 +1472,8 @@ var JSHINT = (function() { if (right.type === "(identifier)" && right.value === "typeof" && left.type === "(string)") { if (left.value === "bigint") { - if (!state.option.unstable.bigint) { - warning("W144", left, "BigInt", "bigint"); + if (!state.inES11()) { + warning("W119", left, "BigInt", "11"); } return false; diff --git a/src/lex.js b/src/lex.js index 05ba48f475..e21d479167 100644 --- a/src/lex.js +++ b/src/lex.js @@ -874,19 +874,17 @@ Lexer.prototype = { if (isAllowedDigit !== isDecimalDigit || isBigInt) { if (isBigInt) { - if (!state.option.unstable.bigint) { - this.triggerAsync( - "warning", - { - code: "W144", - line: this.line, - character: this.char, - data: [ "BigInt", "bigint" ] - }, - checks, - function() { return true; } - ); - } + this.triggerAsync( + "warning", + { + code: "W119", + line: this.line, + character: this.char, + data: [ "BigInt", "11" ] + }, + checks, + function() { return !state.inES11(); } + ); if (isLegacy || isNonOctal) { this.triggerAsync( diff --git a/src/options.js b/src/options.js index e43edbd8f4..ab9c26a34f 100644 --- a/src/options.js +++ b/src/options.js @@ -1063,17 +1063,6 @@ exports.val = { * right to remove or modify them between major version releases. */ exports.unstable = { - /** - * [The BigInt proposal](https://github.com/tc39/proposal-bigint) extends the - * language's grammer for numeric literals to support integer values of - * arbitrary precision. It also introduces a new value of the `typeof` - * operator, "bigint". - * - * Mathematical operations which use both BigInt and traditional ECMAScript - * Number values may not have the intended effect. Due to the weakly-typed - * nature of the language, JSHint is unable to identify such cases. - */ - bigint: true }; // These are JSHint boolean options which are shared with JSLint diff --git a/tests/test262/test.js b/tests/test262/test.js index 003a017752..d18dc7bda7 100644 --- a/tests/test262/test.js +++ b/tests/test262/test.js @@ -53,10 +53,7 @@ module.exports = function(test) { JSHint(test.contents, { esversion: 11, maxerr: Infinity, - module: isModule, - unstable: { - bigint: true - } + module: isModule }); } catch (e) { return false; diff --git a/tests/unit/unstable/bigint.js b/tests/unit/bigint.js similarity index 73% rename from tests/unit/unstable/bigint.js rename to tests/unit/bigint.js index 3db2720ad6..26c6fae59b 100644 --- a/tests/unit/unstable/bigint.js +++ b/tests/unit/bigint.js @@ -1,22 +1,22 @@ "use strict"; -var TestRun = require("../../helpers/testhelper").setup.testRun; +var TestRun = require("../helpers/testhelper").setup.testRun; exports.enabling = function (test) { TestRun(test, "Not enabled") - .addError(1, 6, "'BigInt' is a non-standard language feature. Enable it using the 'bigint' unstable option.") - .test("void 1n;", {esversion: 9}); + .addError(1, 6, "'BigInt' is only available in ES11 (use 'esversion: 11').") + .test("void 1n;", {esversion: 10}); TestRun(test, "Enabled via inline directive") .test([ - "// jshint.unstable bigint: true", + "// jshint esversion: 11", "void 1n;" - ], {esversion: 9}); + ], {esversion: 10}); TestRun(test, "Enabled via configuration object") .test([ "void 1n;" - ], {esversion: 9, unstable: {bigint: true}}); + ], {esversion: 11}); test.done(); }; @@ -34,7 +34,7 @@ exports.validUsage = function(test) { "void 0b1n;", "void 0b01n;", "void 0b10n;", - ], {esversion: 6, unstable: {bigint: true}}); + ], {esversion: 11}); TestRun(test, 'No warnings for values that would otherwise coerce to Infinity') .test([ @@ -44,7 +44,7 @@ exports.validUsage = function(test) { "0000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000n;" - ], {esversion: 9, unstable: {bigint: true}}); + ], {esversion: 11}); test.done(); }; @@ -54,51 +54,51 @@ exports.invalid = function (test) { .addError(1, 10, "A leading decimal point can be confused with a dot: '.1'.") .addError(1, 8, "Missing semicolon.") .addError(1, 8, "Expected an assignment or function call and instead saw an expression.") - .test("void 1n.1;", {esversion: 6, unstable: {bigint: true}}); + .test("void 1n.1;", {esversion: 11}); TestRun(test, "following decimal point") .addError(1, 6, "Unexpected '1'.") .addError(1, 1, "Unexpected early end of program.") .addError(1, 6, "Unrecoverable syntax error. (100% scanned).") - .test("void 1.1n;", {esversion: 6, unstable: {bigint: true}}); + .test("void 1.1n;", {esversion: 11}); TestRun(test, "preceding exponent") .addError(1, 6, "Unexpected '1'.") .addError(1, 1, "Unexpected early end of program.") .addError(1, 6, "Unrecoverable syntax error. (100% scanned).") - .test("void 1ne3;", {esversion: 6, unstable: {bigint: true}}); + .test("void 1ne3;", {esversion: 11}); TestRun(test, "following exponent") .addError(1, 6, "Unexpected '1'.") .addError(1, 1, "Unexpected early end of program.") .addError(1, 6, "Unrecoverable syntax error. (100% scanned).") - .test("void 1e3n;", {esversion: 6, unstable: {bigint: true}}); + .test("void 1e3n;", {esversion: 11}); TestRun(test, "invalid legacy octal") .addError(1, 6, "Malformed numeric literal: '01n'.") - .test("void 01n;", {esversion: 6, unstable: {bigint: true}}); + .test("void 01n;", {esversion: 11}); TestRun(test, "invalid leading 0") .addError(1, 6, "Malformed numeric literal: '08n'.") - .test("void 08n;", {esversion: 6, unstable: {bigint: true}}); + .test("void 08n;", {esversion: 11}); TestRun(test, "invalid hex digit") .addError(1, 8, "Malformed numeric literal: '0x'.") .addError(1, 8, "Missing semicolon.") .addError(1, 8, "Expected an assignment or function call and instead saw an expression.") - .test("void 0xgn;", {esversion: 6, unstable: {bigint: true}}); + .test("void 0xgn;", {esversion: 11}); TestRun(test, "invalid binary digit") .addError(1, 8, "Malformed numeric literal: '0b'.") .addError(1, 8, "Missing semicolon.") .addError(1, 8, "Expected an assignment or function call and instead saw an expression.") - .test("void 0b2n;", {esversion: 6, unstable: {bigint: true}}); + .test("void 0b2n;", {esversion: 11}); TestRun(test, "invalid octal digit") .addError(1, 8, "Malformed numeric literal: '0o'.") .addError(1, 8, "Missing semicolon.") .addError(1, 8, "Expected an assignment or function call and instead saw an expression.") - .test("void 0o8n;", {esversion: 6, unstable: {bigint: true}}); + .test("void 0o8n;", {esversion: 11}); test.done(); }; diff --git a/tests/unit/options.js b/tests/unit/options.js index bb05b4faf9..b2fc831b1e 100644 --- a/tests/unit/options.js +++ b/tests/unit/options.js @@ -311,7 +311,7 @@ exports.notypeof = function (test) { .addError(3, 17, "Invalid typeof value 'bool'") .addError(4, 11, "Invalid typeof value 'obj'") .addError(13, 17, "Invalid typeof value 'symbol'") - .addError(14, 21, "'BigInt' is a non-standard language feature. Enable it using the 'bigint' unstable option.") + .addError(14, 21, "'BigInt' is only available in ES11 (use 'esversion: 11').") .test(src); TestRun(test) @@ -319,7 +319,7 @@ exports.notypeof = function (test) { .addError(2, 14, "Invalid typeof value 'double'") .addError(3, 17, "Invalid typeof value 'bool'") .addError(4, 11, "Invalid typeof value 'obj'") - .addError(14, 21, "'BigInt' is a non-standard language feature. Enable it using the 'bigint' unstable option.") + .addError(14, 21, "'BigInt' is only available in ES11 (use 'esversion: 11').") .test(src, { esnext: true }); TestRun(test) @@ -327,7 +327,7 @@ exports.notypeof = function (test) { .addError(2, 14, "Invalid typeof value 'double'") .addError(3, 17, "Invalid typeof value 'bool'") .addError(4, 11, "Invalid typeof value 'obj'") - .test(src, { esnext: true, unstable: { bigint: true } }); + .test(src, { esversion: 11 }); TestRun(test) .test(src, { notypeof: true });