diff --git a/package.json b/package.json index 90a6b1c5..53210e36 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,9 @@ }, "license": "BSD-2-Clause", "dependencies": { - "acorn": "^7.1.1", + "acorn": "^7.2.0", "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" + "eslint-visitor-keys": "^1.2.0" }, "devDependencies": { "browserify": "^16.5.0", 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 index 9771c256..f3ffb393 100644 --- 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 @@ -1,6 +1,6 @@ module.exports = { - "index": 16, + "index": 17, "lineNumber": 1, - "column": 17, - "message": "Unexpected token ." + "column": 18, + "message": "The only valid meta property for import is 'import.meta'" }; \ No newline at end of file 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 index ef8f8527..d6fe936f 100644 --- 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 @@ -3,4 +3,4 @@ module.exports = { "lineNumber": 1, "column": 5, "message": "Cannot use new with import()" -}; +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star-as-ns.result.js b/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star-as-ns.result.js new file mode 100644 index 00000000..986a481f --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star-as-ns.result.js @@ -0,0 +1,184 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], + "body": [ + { + "type": "ExportAllDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 0, + 28 + ], + "exported": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 12, + 14 + ], + "name": "ns" + }, + "source": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 20, + 28 + ], + "value": "source", + "raw": "\"source\"" + } + } + ], + "sourceType": "module", + "tokens": [ + { + "type": "Keyword", + "value": "export", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ] + }, + { + "type": "Identifier", + "value": "as", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 9, + 11 + ] + }, + { + "type": "Identifier", + "value": "ns", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 12, + 14 + ] + }, + { + "type": "Identifier", + "value": "from", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 15, + 19 + ] + }, + { + "type": "String", + "value": "\"source\"", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 20, + 28 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star-as-ns.src.js b/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star-as-ns.src.js new file mode 100644 index 00000000..9d9de82e --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star-as-ns.src.js @@ -0,0 +1 @@ +export * as ns from "source" diff --git a/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star.result.js b/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star.result.js new file mode 100644 index 00000000..7f58b56a --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star.result.js @@ -0,0 +1,131 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], + "body": [ + { + "type": "ExportAllDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 0, + 22 + ], + "exported": null, + "source": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 14, + 22 + ], + "value": "source", + "raw": "\"source\"" + } + } + ], + "sourceType": "module", + "tokens": [ + { + "type": "Keyword", + "value": "export", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ] + }, + { + "type": "Identifier", + "value": "from", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 9, + 13 + ] + }, + { + "type": "String", + "value": "\"source\"", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 14, + 22 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star.src.js b/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star.src.js new file mode 100644 index 00000000..22685348 --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/export-star-as-ns-from-source/export-star.src.js @@ -0,0 +1 @@ +export * from "source" diff --git a/tests/fixtures/ecma-version/11/modules/import-meta/import-meta.result.js b/tests/fixtures/ecma-version/11/modules/import-meta/import-meta.result.js new file mode 100644 index 00000000..5688cbb7 --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/import-meta/import-meta.result.js @@ -0,0 +1,310 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], + "body": [ + { + "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 0, + 27 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 6, + 27 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 6, + 9 + ], + "name": "url" + }, + "init": { + "type": "MemberExpression", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 12, + 27 + ], + "object": { + "type": "MetaProperty", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 12, + 23 + ], + "meta": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 12, + 18 + ], + "name": "import" + }, + "property": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 19, + 23 + ], + "name": "meta" + } + }, + "property": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 24, + 27 + ], + "name": "url" + }, + "computed": false + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "tokens": [ + { + "type": "Keyword", + "value": "const", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "url", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 6, + 9 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Keyword", + "value": "import", + "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": "Identifier", + "value": "meta", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 19, + 23 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 23, + 24 + ] + }, + { + "type": "Identifier", + "value": "url", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 24, + 27 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/modules/import-meta/import-meta.src.js b/tests/fixtures/ecma-version/11/modules/import-meta/import-meta.src.js new file mode 100644 index 00000000..2e057c24 --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/import-meta/import-meta.src.js @@ -0,0 +1 @@ +const url = import.meta.url diff --git a/tests/fixtures/ecma-version/11/modules/import-meta/invalid-not-meta.result.js b/tests/fixtures/ecma-version/11/modules/import-meta/invalid-not-meta.result.js new file mode 100644 index 00000000..53e04640 --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/import-meta/invalid-not-meta.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 19, + "lineNumber": 1, + "column": 20, + "message": "The only valid meta property for import is 'import.meta'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/modules/import-meta/invalid-not-meta.src.js b/tests/fixtures/ecma-version/11/modules/import-meta/invalid-not-meta.src.js new file mode 100644 index 00000000..ee5af500 --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/import-meta/invalid-not-meta.src.js @@ -0,0 +1 @@ +const url = import.mate.url diff --git a/tests/fixtures/ecma-version/11/modules/import-meta/invalid-unicode-sequence.result.js b/tests/fixtures/ecma-version/11/modules/import-meta/invalid-unicode-sequence.result.js new file mode 100644 index 00000000..d2d34c43 --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/import-meta/invalid-unicode-sequence.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 12, + "lineNumber": 1, + "column": 13, + "message": "'import.meta' must not contain escaped characters" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/modules/import-meta/invalid-unicode-sequence.src.js b/tests/fixtures/ecma-version/11/modules/import-meta/invalid-unicode-sequence.src.js new file mode 100644 index 00000000..e8b1f1e2 --- /dev/null +++ b/tests/fixtures/ecma-version/11/modules/import-meta/invalid-unicode-sequence.src.js @@ -0,0 +1 @@ +const url = import.\u006d\u0065\u0074\u0061.url diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-1.result.js b/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-1.result.js new file mode 100644 index 00000000..a0c55bce --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 7, + "lineNumber": 1, + "column": 8, + "message": "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-1.src.js b/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-1.src.js new file mode 100644 index 00000000..2d12bd6d --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-1.src.js @@ -0,0 +1 @@ +a || b ?? c diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-2.result.js b/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-2.result.js new file mode 100644 index 00000000..a0c55bce --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 7, + "lineNumber": 1, + "column": 8, + "message": "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-2.src.js b/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-2.src.js new file mode 100644 index 00000000..dc9a04b0 --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/invalid-qq-with-logical-or-2.src.js @@ -0,0 +1 @@ +a ?? b || c diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/one-qq.result.js b/tests/fixtures/ecma-version/11/nullish-coalescing/one-qq.result.js new file mode 100644 index 00000000..976add38 --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/one-qq.result.js @@ -0,0 +1,147 @@ +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": "LogicalExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ], + "name": "a" + }, + "operator": "??", + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "b" + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "??", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 2, + 4 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/one-qq.src.js b/tests/fixtures/ecma-version/11/nullish-coalescing/one-qq.src.js new file mode 100644 index 00000000..569f8040 --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/one-qq.src.js @@ -0,0 +1 @@ +a ?? b diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/qq-in-ternary.result.js b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-in-ternary.result.js new file mode 100644 index 00000000..564ac63d --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-in-ternary.result.js @@ -0,0 +1,272 @@ +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": "ConditionalExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "test": { + "type": "LogicalExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ], + "name": "a" + }, + "operator": "??", + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "b" + } + }, + "consequent": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], + "name": "c" + }, + "alternate": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ], + "name": "d" + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "??", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 2, + 4 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Punctuator", + "value": "?", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ] + }, + { + "type": "Identifier", + "value": "c", + "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": "Identifier", + "value": "d", + "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/nullish-coalescing/qq-in-ternary.src.js b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-in-ternary.src.js new file mode 100644 index 00000000..6d64481e --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-in-ternary.src.js @@ -0,0 +1 @@ +a ?? b ? c : d diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-bitwise-or.result.js b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-bitwise-or.result.js new file mode 100644 index 00000000..deca3563 --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-bitwise-or.result.js @@ -0,0 +1,291 @@ +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": "LogicalExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "left": { + "type": "BinaryExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ], + "name": "a" + }, + "operator": "|", + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ], + "name": "b" + } + }, + "operator": "??", + "right": { + "type": "BinaryExpression", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 9, + 14 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], + "name": "c" + }, + "operator": "|", + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ], + "name": "d" + } + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "|", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Punctuator", + "value": "??", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 6, + 8 + ] + }, + { + "type": "Identifier", + "value": "c", + "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": "Identifier", + "value": "d", + "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/nullish-coalescing/qq-with-bitwise-or.src.js b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-bitwise-or.src.js new file mode 100644 index 00000000..f78992d8 --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-bitwise-or.src.js @@ -0,0 +1 @@ +a | b ?? c | d diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-1.result.js b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-1.result.js new file mode 100644 index 00000000..47af2707 --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-1.result.js @@ -0,0 +1,255 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], + "expression": { + "type": "LogicalExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], + "left": { + "type": "LogicalExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 1, + 7 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ], + "name": "a" + }, + "operator": "||", + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "b" + } + }, + "operator": "??", + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ], + "name": "c" + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "||", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 3, + 5 + ] + }, + { + "type": "Identifier", + "value": "b", + "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": "Punctuator", + "value": "??", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 9, + 11 + ] + }, + { + "type": "Identifier", + "value": "c", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-1.src.js b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-1.src.js new file mode 100644 index 00000000..c852ab26 --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-1.src.js @@ -0,0 +1 @@ +(a || b) ?? c diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-2.result.js b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-2.result.js new file mode 100644 index 00000000..cdcf0005 --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-2.result.js @@ -0,0 +1,255 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], + "expression": { + "type": "LogicalExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ], + "name": "a" + }, + "operator": "||", + "right": { + "type": "LogicalExpression", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 6, + 12 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "b" + }, + "operator": "??", + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ], + "name": "c" + } + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "||", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 2, + 4 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Punctuator", + "value": "??", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 8, + 10 + ] + }, + { + "type": "Identifier", + "value": "c", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-2.src.js b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-2.src.js new file mode 100644 index 00000000..6f41c71c --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/qq-with-logical-or-2.src.js @@ -0,0 +1 @@ +a || (b ?? c) diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/two-qq.result.js b/tests/fixtures/ecma-version/11/nullish-coalescing/two-qq.result.js new file mode 100644 index 00000000..4dae00d8 --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/two-qq.result.js @@ -0,0 +1,219 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], + "expression": { + "type": "LogicalExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], + "left": { + "type": "LogicalExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 0, + 6 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ], + "name": "a" + }, + "operator": "??", + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "b" + } + }, + "operator": "??", + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ], + "name": "c" + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "??", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 2, + 4 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Punctuator", + "value": "??", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 7, + 9 + ] + }, + { + "type": "Identifier", + "value": "c", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/11/nullish-coalescing/two-qq.src.js b/tests/fixtures/ecma-version/11/nullish-coalescing/two-qq.src.js new file mode 100644 index 00000000..269398ee --- /dev/null +++ b/tests/fixtures/ecma-version/11/nullish-coalescing/two-qq.src.js @@ -0,0 +1 @@ +a ?? b ?? c diff --git a/tests/fixtures/ecma-version/6/newTarget/invalid-new-target.result.js b/tests/fixtures/ecma-version/6/newTarget/invalid-new-target.result.js index deaf3293..0ae569a6 100644 --- a/tests/fixtures/ecma-version/6/newTarget/invalid-new-target.result.js +++ b/tests/fixtures/ecma-version/6/newTarget/invalid-new-target.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 8, "lineNumber": 1, "column": 9, - "message": "new.target can only be used in functions" -}; \ No newline at end of file + "message": "'new.target' can only be used in functions" +}; diff --git a/tests/fixtures/ecma-version/6/newTarget/invalid-unknown-property.result.js b/tests/fixtures/ecma-version/6/newTarget/invalid-unknown-property.result.js index 52de9c60..e1dad531 100644 --- a/tests/fixtures/ecma-version/6/newTarget/invalid-unknown-property.result.js +++ b/tests/fixtures/ecma-version/6/newTarget/invalid-unknown-property.result.js @@ -2,5 +2,5 @@ module.exports = { "index": 25, "lineNumber": 1, "column": 26, - "message": "The only valid meta property for new is new.target" -}; \ No newline at end of file + "message": "The only valid meta property for new is 'new.target'" +};