diff --git a/.eslintignore b/.eslintignore index 09a8422e..d7bd5160 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,4 @@ !.eslintrc.js +/node_modules +/tests/fixtures +/tools diff --git a/.travis.yml b/.travis.yml index 8afb8e61..b3ea3d47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: node_js -sudo: false node_js: - 6 - 7 @@ -8,5 +7,10 @@ node_js: - 10 - 11 - 12 + +script: + - if [ $TRAVIS_NODE_VERSION -ge 8 ]; then node Makefile.js lint; fi + - node Makefile.js test + after_success: - npm run coveralls diff --git a/espree.js b/espree.js index 7c16b696..ce277c18 100644 --- a/espree.js +++ b/espree.js @@ -154,7 +154,7 @@ exports.Syntax = (function() { } for (name in astNodeTypes) { - if (astNodeTypes.hasOwnProperty(name)) { + if (Object.hasOwnProperty.call(astNodeTypes, name)) { types[name] = astNodeTypes[name]; } } diff --git a/lib/espree.js b/lib/espree.js index 6c57a87c..0d65018b 100644 --- a/lib/espree.js +++ b/lib/espree.js @@ -35,6 +35,7 @@ function normalizeEcmaVersion(ecmaVersion = DEFAULT_ECMA_VERSION) { case 8: case 9: case 10: + case 11: return version; // no default diff --git a/package.json b/package.json index 3835c012..03d91482 100644 --- a/package.json +++ b/package.json @@ -18,14 +18,14 @@ }, "license": "BSD-2-Clause", "dependencies": { - "acorn": "^6.0.7", + "acorn": "^7.0.0", "acorn-jsx": "^5.0.0", - "eslint-visitor-keys": "^1.0.0" + "eslint-visitor-keys": "^1.1.0" }, "devDependencies": { "browserify": "^7.0.0", "chai": "^1.10.0", - "eslint": "^5.7.0", + "eslint": "^6.0.1", "eslint-config-eslint": "^5.0.1", "eslint-plugin-node": "^8.0.0", "eslint-release": "^1.0.0", diff --git a/tests/fixtures/ecma-version/11/bigint/binary.result.js b/tests/fixtures/ecma-version/11/bigint/binary.result.js new file mode 100644 index 00000000..280dd585 --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/binary.result.js @@ -0,0 +1,77 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 0, + 7 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 0, + 7 + ], + "expression": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 0, + 7 + ], + "value": null, + "raw": "0b0101n", + "bigint": "0b0101" + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Numeric", + "value": "0b0101n", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 0, + 7 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/bigint/binary.src.js b/tests/fixtures/ecma-version/11/bigint/binary.src.js new file mode 100644 index 00000000..d9b0686a --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/binary.src.js @@ -0,0 +1 @@ +0b0101n diff --git a/tests/fixtures/ecma-version/11/bigint/decimal.result.js b/tests/fixtures/ecma-version/11/bigint/decimal.result.js new file mode 100644 index 00000000..e5fb5ae0 --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/decimal.result.js @@ -0,0 +1,77 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 0, + 2 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 0, + 2 + ], + "expression": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 0, + 2 + ], + "value": null, + "raw": "1n", + "bigint": "1" + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Numeric", + "value": "1n", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 0, + 2 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/bigint/decimal.src.js b/tests/fixtures/ecma-version/11/bigint/decimal.src.js new file mode 100644 index 00000000..7a5a058e --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/decimal.src.js @@ -0,0 +1 @@ +1n diff --git a/tests/fixtures/ecma-version/11/bigint/hex.result.js b/tests/fixtures/ecma-version/11/bigint/hex.result.js new file mode 100644 index 00000000..c9b46b0d --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/hex.result.js @@ -0,0 +1,77 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], + "expression": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], + "value": null, + "raw": "0x80n", + "bigint": "0x80" + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Numeric", + "value": "0x80n", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/bigint/hex.src.js b/tests/fixtures/ecma-version/11/bigint/hex.src.js new file mode 100644 index 00000000..334bd267 --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/hex.src.js @@ -0,0 +1 @@ +0x80n diff --git a/tests/fixtures/ecma-version/11/bigint/invalid-float.result.js b/tests/fixtures/ecma-version/11/bigint/invalid-float.result.js new file mode 100644 index 00000000..17158f6e --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/invalid-float.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 3, + "lineNumber": 1, + "column": 4, + "message": "Identifier directly after number" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/bigint/invalid-float.src.js b/tests/fixtures/ecma-version/11/bigint/invalid-float.src.js new file mode 100644 index 00000000..d87b390c --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/invalid-float.src.js @@ -0,0 +1 @@ +1.0n diff --git a/tests/fixtures/ecma-version/11/bigint/octal.result.js b/tests/fixtures/ecma-version/11/bigint/octal.result.js new file mode 100644 index 00000000..949109de --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/octal.result.js @@ -0,0 +1,77 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], + "expression": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], + "value": null, + "raw": "0o755n", + "bigint": "0o755" + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Numeric", + "value": "0o755n", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/bigint/octal.src.js b/tests/fixtures/ecma-version/11/bigint/octal.src.js new file mode 100644 index 00000000..184b15fe --- /dev/null +++ b/tests/fixtures/ecma-version/11/bigint/octal.src.js @@ -0,0 +1 @@ +0o755n diff --git a/tests/fixtures/ecma-version/11/dynamic-import/basic.result.js b/tests/fixtures/ecma-version/11/dynamic-import/basic.result.js new file mode 100644 index 00000000..5509d7b9 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/basic.result.js @@ -0,0 +1,457 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 62 + ], + "body": [ + { + "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 62 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 15, + 19 + ], + "name": "main" + }, + "expression": false, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 22, + 62 + ], + "body": [ + { + "type": "VariableDeclaration", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "range": [ + 28, + 60 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "range": [ + 34, + 60 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 34, + 37 + ], + "name": "foo" + }, + "init": { + "type": "AwaitExpression", + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "range": [ + 40, + 60 + ], + "argument": { + "type": "ImportExpression", + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "range": [ + 46, + 60 + ], + "source": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "range": [ + 53, + 59 + ], + "name": "source" + } + } + } + } + ], + "kind": "const" + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 6, + 14 + ] + }, + { + "type": "Identifier", + "value": "main", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 15, + 19 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 20, + 21 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 22, + 23 + ] + }, + { + "type": "Keyword", + "value": "const", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 28, + 33 + ] + }, + { + "type": "Identifier", + "value": "foo", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 34, + 37 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 38, + 39 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 40, + 45 + ] + }, + { + "type": "Keyword", + "value": "import", + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "range": [ + 46, + 52 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "range": [ + 52, + 53 + ] + }, + { + "type": "Identifier", + "value": "source", + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "range": [ + 53, + 59 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "range": [ + 59, + 60 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 61, + 62 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/basic.src.js b/tests/fixtures/ecma-version/11/dynamic-import/basic.src.js new file mode 100644 index 00000000..722788ec --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/basic.src.js @@ -0,0 +1,3 @@ +async function main() { + const foo = await import(source) +} diff --git a/tests/fixtures/ecma-version/11/dynamic-import/first-of-statement.result.js b/tests/fixtures/ecma-version/11/dynamic-import/first-of-statement.result.js new file mode 100644 index 00000000..484ff897 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/first-of-statement.result.js @@ -0,0 +1,146 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "expression": { + "type": "ImportExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "source": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 7, + 13 + ], + "name": "source" + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "import", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Identifier", + "value": "source", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 7, + 13 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/first-of-statement.src.js b/tests/fixtures/ecma-version/11/dynamic-import/first-of-statement.src.js new file mode 100644 index 00000000..fadb0d9d --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/first-of-statement.src.js @@ -0,0 +1 @@ +import(source) diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-import-prop.result.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-import-prop.result.js new file mode 100644 index 00000000..9771c256 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-import-prop.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 16, + "lineNumber": 1, + "column": 17, + "message": "Unexpected token ." +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-import-prop.src.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-import-prop.src.js new file mode 100644 index 00000000..b1073af3 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-import-prop.src.js @@ -0,0 +1 @@ +const i = import.property diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-multi-sources.result.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-multi-sources.result.js new file mode 100644 index 00000000..54c957f1 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-multi-sources.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 14, + "lineNumber": 1, + "column": 15, + "message": "Unexpected token ," +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-multi-sources.src.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-multi-sources.src.js new file mode 100644 index 00000000..6a11dd57 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-multi-sources.src.js @@ -0,0 +1 @@ +import(source1, source2) diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-new-import.result.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-new-import.result.js new file mode 100644 index 00000000..ef8f8527 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-new-import.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 4, + "lineNumber": 1, + "column": 5, + "message": "Cannot use new with import()" +}; diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-new-import.src.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-new-import.src.js new file mode 100644 index 00000000..5fe8698a --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-new-import.src.js @@ -0,0 +1 @@ +new import(source) diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-no-source.result.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-no-source.result.js new file mode 100644 index 00000000..c2746067 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-no-source.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 7, + "lineNumber": 1, + "column": 8, + "message": "Unexpected token )" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-no-source.src.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-no-source.src.js new file mode 100644 index 00000000..4de180fc --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-no-source.src.js @@ -0,0 +1 @@ +import() diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-only-import.result.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-only-import.result.js new file mode 100644 index 00000000..d997dfa0 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-only-import.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 17, + "lineNumber": 2, + "column": 1, + "message": "Unexpected token" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-only-import.src.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-only-import.src.js new file mode 100644 index 00000000..2a39481c --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-only-import.src.js @@ -0,0 +1 @@ +const i = import diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-trailing-comma.result.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-trailing-comma.result.js new file mode 100644 index 00000000..0f3bb54d --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-trailing-comma.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 13, + "lineNumber": 1, + "column": 14, + "message": "Trailing comma is not allowed in import()" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-trailing-comma.src.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-trailing-comma.src.js new file mode 100644 index 00000000..765c6022 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-trailing-comma.src.js @@ -0,0 +1 @@ +import(source,) diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-wrap-import.result.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-wrap-import.result.js new file mode 100644 index 00000000..c2746067 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-wrap-import.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 7, + "lineNumber": 1, + "column": 8, + "message": "Unexpected token )" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/invalid-wrap-import.src.js b/tests/fixtures/ecma-version/11/dynamic-import/invalid-wrap-import.src.js new file mode 100644 index 00000000..f1ff0c4b --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/invalid-wrap-import.src.js @@ -0,0 +1 @@ +(import)(source) diff --git a/tests/fixtures/ecma-version/11/dynamic-import/new-import.result.js b/tests/fixtures/ecma-version/11/dynamic-import/new-import.result.js new file mode 100644 index 00000000..cfa98894 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/new-import.result.js @@ -0,0 +1,218 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], + "expression": { + "type": "NewExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], + "callee": { + "type": "ImportExpression", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 5, + 19 + ], + "source": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 12, + 18 + ], + "name": "source" + } + }, + "arguments": [] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "new", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Keyword", + "value": "import", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + }, + { + "type": "Identifier", + "value": "source", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 12, + 18 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/new-import.src.js b/tests/fixtures/ecma-version/11/dynamic-import/new-import.src.js new file mode 100644 index 00000000..e9255ca5 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/new-import.src.js @@ -0,0 +1 @@ +new (import(source)) diff --git a/tests/fixtures/ecma-version/11/dynamic-import/with-assign.result.js b/tests/fixtures/ecma-version/11/dynamic-import/with-assign.result.js new file mode 100644 index 00000000..4d17a100 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/with-assign.result.js @@ -0,0 +1,219 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], + "expression": { + "type": "ImportExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 0, + 25 + ], + "source": { + "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 7, + 24 + ], + "operator": "=", + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 7, + 13 + ], + "name": "source" + }, + "right": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 16, + 24 + ], + "value": "foo.js", + "raw": "\"foo.js\"" + } + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "import", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Identifier", + "value": "source", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 7, + 13 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "String", + "value": "\"foo.js\"", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 16, + 24 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 24, + 25 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/with-assign.src.js b/tests/fixtures/ecma-version/11/dynamic-import/with-assign.src.js new file mode 100644 index 00000000..f5c12918 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/with-assign.src.js @@ -0,0 +1 @@ +import(source = "foo.js") diff --git a/tests/fixtures/ecma-version/11/dynamic-import/with-sequence.result.js b/tests/fixtures/ecma-version/11/dynamic-import/with-sequence.result.js new file mode 100644 index 00000000..d949f27a --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/with-sequence.result.js @@ -0,0 +1,255 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], + "expression": { + "type": "ImportExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], + "source": { + "type": "SequenceExpression", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 8, + 21 + ], + "expressions": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 8, + 13 + ], + "name": "dummy" + }, + { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 15, + 21 + ], + "name": "source" + } + ] + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "import", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ] + }, + { + "type": "Identifier", + "value": "dummy", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 8, + 13 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + }, + { + "type": "Identifier", + "value": "source", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 15, + 21 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 21, + 22 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 22, + 23 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/dynamic-import/with-sequence.src.js b/tests/fixtures/ecma-version/11/dynamic-import/with-sequence.src.js new file mode 100644 index 00000000..b989e0a9 --- /dev/null +++ b/tests/fixtures/ecma-version/11/dynamic-import/with-sequence.src.js @@ -0,0 +1 @@ +import((dummy, source)) diff --git a/tests/fixtures/ecma-version/6/forOf/for-of-with-function-initializer.result.js b/tests/fixtures/ecma-version/6/forOf/for-of-with-function-initializer.result.js index 344e65bf..b95a7a0a 100644 --- a/tests/fixtures/ecma-version/6/forOf/for-of-with-function-initializer.result.js +++ b/tests/fixtures/ecma-version/6/forOf/for-of-with-function-initializer.result.js @@ -1,710 +1,6 @@ module.exports = { - "type": "Program", - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 64 - } - }, - "range": [ - 0, - 64 - ], - "body": [ - { - "type": "ForOfStatement", - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 64 - } - }, - "range": [ - 0, - 64 - ], - "left": { - "type": "VariableDeclaration", - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 43 - } - }, - "range": [ - 5, - 43 - ], - "declarations": [ - { - "type": "VariableDeclarator", - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 43 - } - }, - "range": [ - 9, - 43 - ], - "id": { - "type": "Identifier", - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - } - }, - "range": [ - 9, - 10 - ], - "name": "i" - }, - "init": { - "type": "FunctionExpression", - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 43 - } - }, - "range": [ - 13, - 43 - ], - "id": null, - "generator": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 43 - } - }, - "range": [ - 24, - 43 - ], - "body": [ - { - "type": "ReturnStatement", - "loc": { - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 1, - "column": 41 - } - }, - "range": [ - 26, - 41 - ], - "argument": { - "type": "BinaryExpression", - "loc": { - "start": { - "line": 1, - "column": 33 - }, - "end": { - "line": 1, - "column": 41 - } - }, - "range": [ - 33, - 41 - ], - "left": { - "type": "Literal", - "loc": { - "start": { - "line": 1, - "column": 33 - }, - "end": { - "line": 1, - "column": 35 - } - }, - "range": [ - 33, - 35 - ], - "value": 10, - "raw": "10" - }, - "operator": "in", - "right": { - "type": "ArrayExpression", - "loc": { - "start": { - "line": 1, - "column": 39 - }, - "end": { - "line": 1, - "column": 41 - } - }, - "range": [ - 39, - 41 - ], - "elements": [] - } - } - } - ] - } - } - } - ], - "kind": "var" - }, - "right": { - "type": "Identifier", - "loc": { - "start": { - "line": 1, - "column": 47 - }, - "end": { - "line": 1, - "column": 51 - } - }, - "range": [ - 47, - 51 - ], - "name": "list" - }, - "body": { - "type": "ExpressionStatement", - "loc": { - "start": { - "line": 1, - "column": 53 - }, - "end": { - "line": 1, - "column": 64 - } - }, - "range": [ - 53, - 64 - ], - "expression": { - "type": "CallExpression", - "loc": { - "start": { - "line": 1, - "column": 53 - }, - "end": { - "line": 1, - "column": 63 - } - }, - "range": [ - 53, - 63 - ], - "callee": { - "type": "Identifier", - "loc": { - "start": { - "line": 1, - "column": 53 - }, - "end": { - "line": 1, - "column": 60 - } - }, - "range": [ - 53, - 60 - ], - "name": "process" - }, - "arguments": [ - { - "type": "Identifier", - "loc": { - "start": { - "line": 1, - "column": 61 - }, - "end": { - "line": 1, - "column": 62 - } - }, - "range": [ - 61, - 62 - ], - "name": "x" - } - ] - } - } - } - ], - "sourceType": "script", - "tokens": [ - { - "type": "Keyword", - "value": "for", - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 3 - } - }, - "range": [ - 0, - 3 - ] - }, - { - "type": "Punctuator", - "value": "(", - "loc": { - "start": { - "line": 1, - "column": 4 - }, - "end": { - "line": 1, - "column": 5 - } - }, - "range": [ - 4, - 5 - ] - }, - { - "type": "Keyword", - "value": "var", - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 8 - } - }, - "range": [ - 5, - 8 - ] - }, - { - "type": "Identifier", - "value": "i", - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - } - }, - "range": [ - 9, - 10 - ] - }, - { - "type": "Punctuator", - "value": "=", - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "range": [ - 11, - 12 - ] - }, - { - "type": "Keyword", - "value": "function", - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 21 - } - }, - "range": [ - 13, - 21 - ] - }, - { - "type": "Punctuator", - "value": "(", - "loc": { - "start": { - "line": 1, - "column": 21 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "range": [ - 21, - 22 - ] - }, - { - "type": "Punctuator", - "value": ")", - "loc": { - "start": { - "line": 1, - "column": 22 - }, - "end": { - "line": 1, - "column": 23 - } - }, - "range": [ - 22, - 23 - ] - }, - { - "type": "Punctuator", - "value": "{", - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 25 - } - }, - "range": [ - 24, - 25 - ] - }, - { - "type": "Keyword", - "value": "return", - "loc": { - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 1, - "column": 32 - } - }, - "range": [ - 26, - 32 - ] - }, - { - "type": "Numeric", - "value": "10", - "loc": { - "start": { - "line": 1, - "column": 33 - }, - "end": { - "line": 1, - "column": 35 - } - }, - "range": [ - 33, - 35 - ] - }, - { - "type": "Keyword", - "value": "in", - "loc": { - "start": { - "line": 1, - "column": 36 - }, - "end": { - "line": 1, - "column": 38 - } - }, - "range": [ - 36, - 38 - ] - }, - { - "type": "Punctuator", - "value": "[", - "loc": { - "start": { - "line": 1, - "column": 39 - }, - "end": { - "line": 1, - "column": 40 - } - }, - "range": [ - 39, - 40 - ] - }, - { - "type": "Punctuator", - "value": "]", - "loc": { - "start": { - "line": 1, - "column": 40 - }, - "end": { - "line": 1, - "column": 41 - } - }, - "range": [ - 40, - 41 - ] - }, - { - "type": "Punctuator", - "value": "}", - "loc": { - "start": { - "line": 1, - "column": 42 - }, - "end": { - "line": 1, - "column": 43 - } - }, - "range": [ - 42, - 43 - ] - }, - { - "type": "Identifier", - "value": "of", - "loc": { - "start": { - "line": 1, - "column": 44 - }, - "end": { - "line": 1, - "column": 46 - } - }, - "range": [ - 44, - 46 - ] - }, - { - "type": "Identifier", - "value": "list", - "loc": { - "start": { - "line": 1, - "column": 47 - }, - "end": { - "line": 1, - "column": 51 - } - }, - "range": [ - 47, - 51 - ] - }, - { - "type": "Punctuator", - "value": ")", - "loc": { - "start": { - "line": 1, - "column": 51 - }, - "end": { - "line": 1, - "column": 52 - } - }, - "range": [ - 51, - 52 - ] - }, - { - "type": "Identifier", - "value": "process", - "loc": { - "start": { - "line": 1, - "column": 53 - }, - "end": { - "line": 1, - "column": 60 - } - }, - "range": [ - 53, - 60 - ] - }, - { - "type": "Punctuator", - "value": "(", - "loc": { - "start": { - "line": 1, - "column": 60 - }, - "end": { - "line": 1, - "column": 61 - } - }, - "range": [ - 60, - 61 - ] - }, - { - "type": "Identifier", - "value": "x", - "loc": { - "start": { - "line": 1, - "column": 61 - }, - "end": { - "line": 1, - "column": 62 - } - }, - "range": [ - 61, - 62 - ] - }, - { - "type": "Punctuator", - "value": ")", - "loc": { - "start": { - "line": 1, - "column": 62 - }, - "end": { - "line": 1, - "column": 63 - } - }, - "range": [ - 62, - 63 - ] - }, - { - "type": "Punctuator", - "value": ";", - "loc": { - "start": { - "line": 1, - "column": 63 - }, - "end": { - "line": 1, - "column": 64 - } - }, - "range": [ - 63, - 64 - ] - } - ] -}; \ No newline at end of file + index: 5, + lineNumber: 1, + column: 6, + message: "for-of loop variable declaration may not have an initializer" +}; diff --git a/tests/lib/tester.js b/tests/lib/tester.js index 048b9280..0d7cd8eb 100644 --- a/tests/lib/tester.js +++ b/tests/lib/tester.js @@ -29,6 +29,11 @@ function getRaw(ast) { return undefined; // eslint-disable-line no-undefined } + // JSON cannot handle BigInt. + if (typeof value === "bigint") { + return null; + } + return value; })); }