From e0cd4d946ad36e23547a1ebbb0d1821b419a93b7 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Wed, 28 Apr 2021 12:56:28 +0900 Subject: [PATCH 01/11] Update: add ES2022 class features support (refs eslint/eslint#14343) --- lib/options.js | 3 +- lib/token-translator.js | 4 + package.json | 4 +- .../invalid-delete-private-optional.result.js | 6 + .../invalid-delete-private-optional.src.js | 4 + .../invalid-delete-private.result.js | 6 + .../invalid-delete-private.src.js | 4 + .../invalid-init-arguments.result.js | 6 + .../invalid-init-arguments.src.js | 5 + .../invalid-init-arrow-arguments.result.js | 6 + .../invalid-init-arrow-arguments.src.js | 5 + .../class-fields/invalid-init-yield.result.js | 6 + .../13/class-fields/invalid-init-yield.src.js | 9 + .../invalid-member-private-undef.result.js | 6 + .../invalid-member-private-undef.src.js | 6 + .../invalid-member-super-private.result.js | 6 + .../invalid-member-super-private.src.js | 4 + .../invalid-private-constructor.result.js | 6 + .../invalid-private-constructor.src.js | 3 + .../invalid-private-dupelicate.result.js | 6 + .../invalid-private-dupelicate.src.js | 4 + .../invalid-public-constructor.result.js | 6 + .../invalid-public-constructor.src.js | 3 + .../mixed-init-await.module-result.js | 6 + .../class-fields/mixed-init-await.result.js | 442 ++++ .../13/class-fields/mixed-init-await.src.js | 8 + .../valid-arguments-in-computed-key.result.js | 461 +++++ .../valid-arguments-in-computed-key.src.js | 6 + .../13/class-fields/valid-async-asi.result.js | 373 ++++ .../13/class-fields/valid-async-asi.src.js | 5 + .../class-fields/valid-computed-asi.result.js | 559 +++++ .../13/class-fields/valid-computed-asi.src.js | 8 + .../valid-computed-no-asi.result.js | 444 ++++ .../class-fields/valid-computed-no-asi.src.js | 5 + .../13/class-fields/valid-computed.result.js | 260 +++ .../13/class-fields/valid-computed.src.js | 3 + .../valid-contextual-keywords-init.result.js | 661 ++++++ .../valid-contextual-keywords-init.src.js | 6 + .../valid-contextual-keywords.result.js | 445 ++++ .../valid-contextual-keywords.src.js | 6 + .../valid-get-set-star-no-asi.result.js | 744 +++++++ .../valid-get-set-star-no-asi.src.js | 11 + .../valid-init-arguments.result.js | 572 ++++++ .../class-fields/valid-init-arguments.src.js | 8 + .../valid-init-arrow-super.result.js | 461 +++++ .../valid-init-arrow-super.src.js | 3 + .../class-fields/valid-init-arrow.result.js | 335 +++ .../13/class-fields/valid-init-arrow.src.js | 3 + .../class-fields/valid-init-super.result.js | 330 +++ .../13/class-fields/valid-init-super.src.js | 4 + ...member-private-nesting-use-first.result.js | 993 +++++++++ ...id-member-private-nesting-use-first.src.js | 10 + .../valid-member-private-nesting.result.js | 993 +++++++++ .../valid-member-private-nesting.src.js | 10 + .../valid-member-private.result.js | 517 +++++ .../class-fields/valid-member-private.src.js | 6 + .../class-fields/valid-private-asi.result.js | 371 ++++ .../13/class-fields/valid-private-asi.src.js | 5 + .../13/class-fields/valid-private.result.js | 223 ++ .../13/class-fields/valid-private.src.js | 3 + .../13/class-fields/valid-prototype.result.js | 259 +++ .../13/class-fields/valid-prototype.src.js | 3 + .../class-fields/valid-public-asi.result.js | 371 ++++ .../13/class-fields/valid-public-asi.src.js | 5 + .../13/class-fields/valid-public.result.js | 223 ++ .../13/class-fields/valid-public.src.js | 4 + .../valid-special-field-names-init.result.js | 704 +++++++ .../valid-special-field-names-init.src.js | 7 + .../valid-special-field-names.result.js | 434 ++++ .../valid-special-field-names.src.js | 7 + .../13/class-fields/valid-star-asi.result.js | 391 ++++ .../13/class-fields/valid-star-asi.src.js | 5 + .../class-fields/valid-star-no-asi.result.js | 386 ++++ .../13/class-fields/valid-star-no-asi.src.js | 5 + .../invalid-conflict-names.result.js | 6 + .../invalid-conflict-names.src.js | 4 + .../invalid-constructor.result.js | 6 + .../invalid-constructor.src.js | 3 + .../private-methods/valid-accessor.result.js | 558 +++++ .../13/private-methods/valid-accessor.src.js | 4 + .../private-methods/valid-async-asi.result.js | 615 ++++++ .../13/private-methods/valid-async-asi.src.js | 8 + ...valid-contextual-keywords-no-asi.result.js | 762 +++++++ .../valid-contextual-keywords-no-asi.src.js | 11 + .../private-methods/valid-methods.result.js | 893 ++++++++ .../13/private-methods/valid-methods.src.js | 6 + .../invalid-conflict-names.result.js | 6 + .../invalid-conflict-names.src.js | 6 + ...nvalid-private-field-constructor.result.js | 6 + .../invalid-private-field-constructor.src.js | 3 + ...valid-private-getter-constructor.result.js | 6 + .../invalid-private-getter-constructor.src.js | 3 + ...valid-private-method-constructor.result.js | 6 + .../invalid-private-method-constructor.src.js | 3 + ...valid-private-setter-constructor.result.js | 6 + .../invalid-private-setter-constructor.src.js | 3 + ...invalid-public-field-constructor.result.js | 6 + .../invalid-public-field-constructor.src.js | 3 + .../invalid-public-field-prototype.result.js | 6 + .../invalid-public-field-prototype.src.js | 3 + .../valid-async-asi.result.js | 1153 +++++++++++ .../valid-async-asi.src.js | 18 + ...valid-contextual-keywords-no-asi.result.js | 1819 +++++++++++++++++ .../valid-contextual-keywords-no-asi.src.js | 30 + .../valid-private-accessors.result.js | 630 ++++++ .../valid-private-accessors.src.js | 4 + .../valid-private-fields.result.js | 387 ++++ .../valid-private-fields.src.js | 4 + .../valid-private-methods.result.js | 965 +++++++++ .../valid-private-methods.src.js | 6 + .../valid-public-fields.result.js | 387 ++++ .../valid-public-fields.src.js | 4 + tests/lib/supported-ecmaversions.js | 4 +- 113 files changed, 20570 insertions(+), 5 deletions(-) create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/mixed-init-await.module-result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/mixed-init-await.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/mixed-init-await.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-arguments-in-computed-key.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-arguments-in-computed-key.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-async-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-async-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-computed-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-computed-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-computed-no-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-computed-no-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-computed.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-computed.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords-init.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords-init.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-get-set-star-no-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-get-set-star-no-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-init-arguments.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-init-arguments.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-init-arrow-super.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-init-arrow-super.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-init-arrow.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-init-arrow.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-init-super.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-init-super.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting-use-first.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting-use-first.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-member-private.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-member-private.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-private-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-private-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-private.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-private.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-prototype.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-prototype.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-public-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-public-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-public.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-public.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-special-field-names-init.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-special-field-names-init.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-special-field-names.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-special-field-names.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-star-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-star-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-star-no-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/class-fields/valid-star-no-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/invalid-conflict-names.result.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/invalid-conflict-names.src.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/invalid-constructor.result.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/invalid-constructor.src.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/valid-accessor.result.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/valid-accessor.src.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/valid-async-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/valid-async-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/valid-contextual-keywords-no-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/valid-contextual-keywords-no-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/valid-methods.result.js create mode 100644 tests/fixtures/ecma-version/13/private-methods/valid-methods.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-conflict-names.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-conflict-names.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-private-field-constructor.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-private-field-constructor.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-private-getter-constructor.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-private-getter-constructor.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-private-method-constructor.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-private-method-constructor.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-private-setter-constructor.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-private-setter-constructor.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-constructor.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-constructor.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-prototype.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-prototype.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-async-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-async-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-contextual-keywords-no-asi.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-contextual-keywords-no-asi.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-private-accessors.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-private-accessors.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-private-fields.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-private-fields.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-private-methods.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-private-methods.src.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-public-fields.result.js create mode 100644 tests/fixtures/ecma-version/13/static-class-features/valid-public-fields.src.js diff --git a/lib/options.js b/lib/options.js index 855d5187..0736599b 100644 --- a/lib/options.js +++ b/lib/options.js @@ -17,7 +17,8 @@ const SUPPORTED_VERSIONS = [ 9, 10, 11, - 12 + 12, + 13 ]; /** diff --git a/lib/token-translator.js b/lib/token-translator.js index 1e03ae66..9aa5e22e 100644 --- a/lib/token-translator.js +++ b/lib/token-translator.js @@ -20,6 +20,7 @@ const Token = { Boolean: "Boolean", EOF: "", Identifier: "Identifier", + PrivateIdentifier: "PrivateIdentifier", Keyword: "Keyword", Null: "Null", Numeric: "Numeric", @@ -114,6 +115,9 @@ TokenTranslator.prototype = { token.type = Token.Keyword; } + } else if (type === tt.privateId) { + token.type = Token.PrivateIdentifier; + } else if (type === tt.semi || type === tt.comma || type === tt.parenL || type === tt.parenR || type === tt.braceL || type === tt.braceR || diff --git a/package.json b/package.json index 198147fb..61b3b5e5 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,9 @@ }, "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.1.0", + "acorn": "^8.2.1", "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^2.0.0" + "eslint-visitor-keys": "github:eslint/eslint-visitor-keys#908fdf8c0d9a352c696c8c1f4901280d1a0795f7" }, "devDependencies": { "@rollup/plugin-commonjs": "^17.1.0", diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.result.js new file mode 100644 index 00000000..9b503393 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.result.js @@ -0,0 +1,6 @@ +export default { + "index": 28, + "lineNumber": 3, + "column": 11, + "message": "Private fields can not be deleted" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.src.js new file mode 100644 index 00000000..af84166b --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.src.js @@ -0,0 +1,4 @@ +class C { + #a; + f() { delete this?.#a } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.result.js new file mode 100644 index 00000000..9b503393 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.result.js @@ -0,0 +1,6 @@ +export default { + "index": 28, + "lineNumber": 3, + "column": 11, + "message": "Private fields can not be deleted" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.src.js new file mode 100644 index 00000000..87c0ca40 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.src.js @@ -0,0 +1,4 @@ +class C { + #a; + f() { delete this.#a } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.result.js new file mode 100644 index 00000000..6704351a --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.result.js @@ -0,0 +1,6 @@ +export default { + "index": 43, + "lineNumber": 3, + "column": 15, + "message": "Cannot use 'arguments' in class field initializer" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.src.js new file mode 100644 index 00000000..ec2d75c6 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.src.js @@ -0,0 +1,5 @@ +function f() { + class C { + aaa = arguments + } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.result.js new file mode 100644 index 00000000..68b5bd4e --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.result.js @@ -0,0 +1,6 @@ +export default { + "index": 49, + "lineNumber": 3, + "column": 21, + "message": "Cannot use 'arguments' in class field initializer" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.src.js new file mode 100644 index 00000000..15614ac7 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.src.js @@ -0,0 +1,5 @@ +function f() { + class C { + aaa = () => arguments + } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.result.js new file mode 100644 index 00000000..8065c0aa --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.result.js @@ -0,0 +1,6 @@ +export default { + "index": 333, + "lineNumber": 7, + "column": 15, + "message": "The keyword 'yield' is reserved" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.src.js new file mode 100644 index 00000000..326b3b99 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.src.js @@ -0,0 +1,9 @@ +function* f() { + class C { + // `yield` is an identifier reference in field initializers even if it's in a generator function. + // But `yield` as identifier references is disallowed in strict mode. + // And the inside of classes is always strict mode. + // Therefore this is a syntax error. + aaa = yield + } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.result.js new file mode 100644 index 00000000..6a528b4c --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.result.js @@ -0,0 +1,6 @@ +export default { + "index": 41, + "lineNumber": 4, + "column": 14, + "message": "Private field '#b' must be declared in an enclosing class" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.src.js new file mode 100644 index 00000000..f92ef155 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.src.js @@ -0,0 +1,6 @@ +class C { + #a; + f() { + this.#b + } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.result.js new file mode 100644 index 00000000..511f4c88 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.result.js @@ -0,0 +1,6 @@ +export default { + "index": 49, + "lineNumber": 3, + "column": 17, + "message": "Unexpected token #foo" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.src.js new file mode 100644 index 00000000..07c20b59 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.src.js @@ -0,0 +1,4 @@ +class C extends Base { + #foo; + f() { super.#foo } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.result.js new file mode 100644 index 00000000..c9c25ffb --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.result.js @@ -0,0 +1,6 @@ +export default { + "index": 14, + "lineNumber": 2, + "column": 5, + "message": "Classes can't have an element named '#constructor'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.src.js new file mode 100644 index 00000000..c360f6b6 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.src.js @@ -0,0 +1,3 @@ +class C { + #constructor = () => {} +} diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.result.js new file mode 100644 index 00000000..5e653264 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.result.js @@ -0,0 +1,6 @@ +export default { + "index": 22, + "lineNumber": 3, + "column": 5, + "message": "Identifier '#a' has already been declared" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.src.js new file mode 100644 index 00000000..9634ef9d --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.src.js @@ -0,0 +1,4 @@ +class C { + #a; + #a; +} diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.result.js b/tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.result.js new file mode 100644 index 00000000..f399d5a3 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.result.js @@ -0,0 +1,6 @@ +export default { + "index": 14, + "lineNumber": 2, + "column": 5, + "message": "Classes can't have a field named 'constructor'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.src.js b/tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.src.js new file mode 100644 index 00000000..9e81de64 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.src.js @@ -0,0 +1,3 @@ +class C { + constructor = () => {} +} diff --git a/tests/fixtures/ecma-version/13/class-fields/mixed-init-await.module-result.js b/tests/fixtures/ecma-version/13/class-fields/mixed-init-await.module-result.js new file mode 100644 index 00000000..821df907 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/mixed-init-await.module-result.js @@ -0,0 +1,6 @@ +export default { + "index": 304, + "lineNumber": 6, + "column": 15, + "message": "Cannot use keyword 'await' outside an async function" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/mixed-init-await.result.js b/tests/fixtures/ecma-version/13/class-fields/mixed-init-await.result.js new file mode 100644 index 00000000..8bb610e1 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/mixed-init-await.result.js @@ -0,0 +1,442 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 0, + 317 + ], + "body": [ + { + "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 0, + 317 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ], + "name": "f" + }, + "expression": false, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 19, + 317 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 7, + "column": 5 + } + }, + "range": [ + 25, + 315 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 31, + 32 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 7, + "column": 5 + } + }, + "range": [ + 33, + 315 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 298, + 309 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "range": [ + 298, + 301 + ], + "name": "aaa" + }, + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 304, + 309 + ], + "name": "await" + } + } + ] + } + } + ] + } + } + ], + "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": "f", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 25, + 30 + ] + }, + { + "type": "Identifier", + "value": "C", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 33, + 34 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "range": [ + 298, + 301 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "range": [ + 302, + 303 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 304, + 309 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 5 + } + }, + "range": [ + 314, + 315 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 316, + 317 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/mixed-init-await.src.js b/tests/fixtures/ecma-version/13/class-fields/mixed-init-await.src.js new file mode 100644 index 00000000..c5466e8a --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/mixed-init-await.src.js @@ -0,0 +1,8 @@ +async function f() { + class C { + // `await` is an identifier reference in field initializers even if it's in async function body. + // But ES modules disallow `await` as identifier references. + // Therefore, it's Identifier in script and it's syntax error in module. + aaa = await + } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-arguments-in-computed-key.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-arguments-in-computed-key.result.js new file mode 100644 index 00000000..a3217ba9 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-arguments-in-computed-key.result.js @@ -0,0 +1,461 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 166 + ], + "body": [ + { + "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 166 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], + "name": "f" + }, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 13, + 166 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "range": [ + 19, + 164 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 25, + 26 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "range": [ + 27, + 164 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "range": [ + 143, + 158 + ], + "static": false, + "computed": true, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "range": [ + 144, + 153 + ], + "name": "arguments" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 4, + "column": 22 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "range": [ + 157, + 158 + ], + "value": 0, + "raw": "0" + } + } + ] + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 0, + 8 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + }, + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 24 + ] + }, + { + "type": "Identifier", + "value": "C", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 25, + 26 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 27, + 28 + ] + }, + { + "type": "Punctuator", + "value": "[", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 143, + 144 + ] + }, + { + "type": "Identifier", + "value": "arguments", + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "range": [ + 144, + 153 + ] + }, + { + "type": "Punctuator", + "value": "]", + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "range": [ + 153, + 154 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 21 + } + }, + "range": [ + 155, + 156 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 4, + "column": 22 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "range": [ + 157, + 158 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "range": [ + 163, + 164 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 165, + 166 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-arguments-in-computed-key.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-arguments-in-computed-key.src.js new file mode 100644 index 00000000..1b4db221 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-arguments-in-computed-key.src.js @@ -0,0 +1,6 @@ +function f() { + class C { + // `arguments` in computed keys is allowed (on the other hand, disallowed in field initializers). + [arguments] = 0 + } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-async-asi.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-async-asi.result.js new file mode 100644 index 00000000..1757b8a8 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-async-asi.result.js @@ -0,0 +1,373 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 98 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 98 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 8, + 98 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 75, + 80 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 75, + 80 + ], + "name": "async" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 85, + 96 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 85, + 91 + ], + "name": "method" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 91, + 96 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 94, + 96 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 75, + 80 + ] + }, + { + "type": "Identifier", + "value": "method", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 85, + 91 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 91, + 92 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 92, + 93 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "range": [ + 94, + 95 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 95, + 96 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 97, + 98 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-async-asi.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-async-asi.src.js new file mode 100644 index 00000000..49f07272 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-async-asi.src.js @@ -0,0 +1,5 @@ +class C { + // Line breaks preceded by `async` create fields by ASI. + async + method() {} +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-computed-asi.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-computed-asi.result.js new file mode 100644 index 00000000..4f44c719 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-computed-asi.result.js @@ -0,0 +1,559 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 0, + 133 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 0, + 133 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 8, + 133 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 91, + 94 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 91, + 94 + ], + "name": "aaa" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 99, + 106 + ], + "static": false, + "computed": true, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 100, + 105 + ], + "value": "bbb", + "raw": "\"bbb\"" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "range": [ + 112, + 115 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "range": [ + 112, + 115 + ], + "name": "ccc" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 15 + } + }, + "range": [ + 120, + 131 + ], + "static": false, + "computed": true, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 7, + "column": 5 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "range": [ + 121, + 126 + ], + "value": "ddd", + "raw": "\"ddd\"" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 15 + } + }, + "range": [ + 127, + 131 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 15 + } + }, + "range": [ + 129, + 131 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 91, + 94 + ] + }, + { + "type": "Punctuator", + "value": "[", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 99, + 100 + ] + }, + { + "type": "String", + "value": "\"bbb\"", + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 100, + 105 + ] + }, + { + "type": "Punctuator", + "value": "]", + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 105, + 106 + ] + }, + { + "type": "Identifier", + "value": "ccc", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "range": [ + 112, + 115 + ] + }, + { + "type": "Punctuator", + "value": "[", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 5 + } + }, + "range": [ + 120, + 121 + ] + }, + { + "type": "String", + "value": "\"ddd\"", + "loc": { + "start": { + "line": 7, + "column": 5 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "range": [ + 121, + 126 + ] + }, + { + "type": "Punctuator", + "value": "]", + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "range": [ + 126, + 127 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 127, + 128 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "range": [ + 128, + 129 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "range": [ + 129, + 130 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 15 + } + }, + "range": [ + 130, + 131 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 132, + 133 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-computed-asi.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-computed-asi.src.js new file mode 100644 index 00000000..36dc8056 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-computed-asi.src.js @@ -0,0 +1,8 @@ +class C { + // Line breaks make fields by ASI. (there are three fields and a method) + aaa + ["bbb"] + + ccc + ["ddd"](){} +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-computed-no-asi.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-computed-no-asi.result.js new file mode 100644 index 00000000..e5ac4f59 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-computed-no-asi.result.js @@ -0,0 +1,444 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 80 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 80 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 8, + 80 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 59, + 78 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 59, + 62 + ], + "name": "aaa" + }, + "value": { + "type": "MemberExpression", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 65, + 78 + ], + "object": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 65, + 68 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 66, + 67 + ], + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 66, + 67 + ], + "name": "f" + }, + "kind": "init", + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 66, + 67 + ], + "name": "f" + } + } + ] + }, + "property": { + "type": "Literal", + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 74, + 77 + ], + "value": "f", + "raw": "\"f\"" + }, + "computed": true, + "optional": false + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 59, + 62 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 63, + 64 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 65, + 66 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 66, + 67 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 67, + 68 + ] + }, + { + "type": "Punctuator", + "value": "[", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 73, + 74 + ] + }, + { + "type": "String", + "value": "\"f\"", + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 74, + 77 + ] + }, + { + "type": "Punctuator", + "value": "]", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 77, + 78 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 79, + 80 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-computed-no-asi.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-computed-no-asi.src.js new file mode 100644 index 00000000..f2175dc8 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-computed-no-asi.src.js @@ -0,0 +1,5 @@ +class C { + // This is `{f}["f"]` member expression. + aaa = {f} + ["f"] +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-computed.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-computed.result.js new file mode 100644 index 00000000..6d14f563 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-computed.result.js @@ -0,0 +1,260 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 22 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 22 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 8, + 22 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "range": [ + 14, + 20 + ], + "static": false, + "computed": true, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 15, + 18 + ], + "value": "a", + "raw": "\"a\"" + }, + "value": null + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Punctuator", + "value": "[", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "String", + "value": "\"a\"", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 15, + 18 + ] + }, + { + "type": "Punctuator", + "value": "]", + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 21, + 22 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-computed.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-computed.src.js new file mode 100644 index 00000000..66c98d27 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-computed.src.js @@ -0,0 +1,3 @@ +class C { + ["a"]; +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords-init.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords-init.result.js new file mode 100644 index 00000000..2d37bbaa --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords-init.result.js @@ -0,0 +1,661 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 68 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 68 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 8, + 68 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 14, + 22 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ], + "name": "get" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 20, + 21 + ], + "value": 0, + "raw": "0" + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 27, + 35 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 27, + 30 + ], + "name": "set" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 33, + 34 + ], + "value": 0, + "raw": "0" + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 40, + 51 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 40, + 46 + ], + "name": "static" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "range": [ + 49, + 50 + ], + "value": 0, + "raw": "0" + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "range": [ + 56, + 66 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "range": [ + 56, + 61 + ], + "name": "async" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "range": [ + 64, + 65 + ], + "value": 0, + "raw": "0" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "get", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 20, + 21 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 21, + 22 + ] + }, + { + "type": "Identifier", + "value": "set", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 27, + 30 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 33, + 34 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 34, + 35 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 40, + 46 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 47, + 48 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "range": [ + 49, + 50 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 50, + 51 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "range": [ + 56, + 61 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "range": [ + 62, + 63 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "range": [ + 64, + 65 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "range": [ + 65, + 66 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 67, + 68 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords-init.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords-init.src.js new file mode 100644 index 00000000..43bb5fa9 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords-init.src.js @@ -0,0 +1,6 @@ +class C { + get = 0; + set = 0; + static = 0; + async = 0; +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords.result.js new file mode 100644 index 00000000..450c243e --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords.result.js @@ -0,0 +1,445 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 52 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 52 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 8, + 52 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 14, + 18 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ], + "name": "get" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 23, + 27 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 23, + 26 + ], + "name": "set" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 32, + 39 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 32, + 38 + ], + "name": "static" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 44, + 50 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "range": [ + 44, + 49 + ], + "name": "async" + }, + "value": null + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "get", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Identifier", + "value": "set", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 23, + 26 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 26, + 27 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 32, + 38 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 38, + 39 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "range": [ + 44, + 49 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 49, + 50 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 51, + 52 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords.src.js new file mode 100644 index 00000000..d47e822c --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-contextual-keywords.src.js @@ -0,0 +1,6 @@ +class C { + get; + set; + static; + async; +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-get-set-star-no-asi.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-get-set-star-no-asi.result.js new file mode 100644 index 00000000..95d02bab --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-get-set-star-no-asi.result.js @@ -0,0 +1,744 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 0, + 118 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 0, + 118 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 8, + 118 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 59, + 74 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "range": [ + 67, + 70 + ], + "name": "get" + }, + "kind": "get", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 70, + 74 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 72, + 74 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 80, + 96 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "range": [ + 88, + 91 + ], + "name": "set" + }, + "kind": "set", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 91, + 96 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "range": [ + 92, + 93 + ], + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 94, + 96 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 102, + 116 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 10, + "column": 4 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "range": [ + 108, + 112 + ], + "name": "star" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 112, + 116 + ], + "id": null, + "expression": false, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 114, + 116 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "get", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 59, + 62 + ] + }, + { + "type": "Identifier", + "value": "get", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "range": [ + 67, + 70 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 70, + 71 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 71, + 72 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 72, + 73 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 73, + 74 + ] + }, + { + "type": "Identifier", + "value": "set", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "range": [ + 80, + 83 + ] + }, + { + "type": "Identifier", + "value": "set", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "range": [ + 88, + 91 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "range": [ + 91, + 92 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "range": [ + 92, + 93 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "range": [ + 93, + 94 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "range": [ + 94, + 95 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 95, + 96 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "range": [ + 102, + 103 + ] + }, + { + "type": "Identifier", + "value": "star", + "loc": { + "start": { + "line": 10, + "column": 4 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "range": [ + 108, + 112 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "range": [ + 112, + 113 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "range": [ + 113, + 114 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "range": [ + 114, + 115 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 115, + 116 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 117, + 118 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-get-set-star-no-asi.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-get-set-star-no-asi.src.js new file mode 100644 index 00000000..f13ac182 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-get-set-star-no-asi.src.js @@ -0,0 +1,11 @@ +class C { + // Line breaks don't make fields by ASI. + get + get(){} + + set + set(x){} + + * + star(){} +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-init-arguments.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-init-arguments.result.js new file mode 100644 index 00000000..088f7e92 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-init-arguments.result.js @@ -0,0 +1,572 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 0, + 198 + ], + "body": [ + { + "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 0, + 198 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], + "name": "f" + }, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 13, + 198 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 7, + "column": 5 + } + }, + "range": [ + 19, + 196 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 25, + 26 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 7, + "column": 5 + } + }, + "range": [ + 27, + 196 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 140, + 190 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 140, + 143 + ], + "name": "aaa" + }, + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 146, + 190 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 157, + 190 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 21 + } + }, + "range": [ + 171, + 180 + ], + "expression": { + "type": "Identifier", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 21 + } + }, + "range": [ + 171, + 180 + ], + "name": "arguments" + } + } + ] + } + } + } + ] + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 0, + 8 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + }, + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 24 + ] + }, + { + "type": "Identifier", + "value": "C", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 25, + 26 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 27, + 28 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 140, + 143 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 144, + 145 + ] + }, + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 146, + 154 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 22 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "range": [ + 154, + 155 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "range": [ + 155, + 156 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "range": [ + 157, + 158 + ] + }, + { + "type": "Identifier", + "value": "arguments", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 21 + } + }, + "range": [ + 171, + 180 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 189, + 190 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 5 + } + }, + "range": [ + 195, + 196 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 197, + 198 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-init-arguments.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-init-arguments.src.js new file mode 100644 index 00000000..946a705a --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-init-arguments.src.js @@ -0,0 +1,8 @@ +function f() { + class C { + // Field initializers disallow `arguments` reference, but it's OK in function expression body. + aaa = function() { + arguments + } + } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow-super.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow-super.result.js new file mode 100644 index 00000000..85753e4c --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow-super.result.js @@ -0,0 +1,461 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 49 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 49 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 8, + 49 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "range": [ + 14, + 47 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 14, + 22 + ], + "name": "toString" + }, + "value": { + "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "range": [ + 25, + 47 + ], + "id": null, + "expression": true, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "CallExpression", + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "range": [ + 31, + 47 + ], + "callee": { + "type": "MemberExpression", + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "range": [ + 31, + 45 + ], + "object": { + "type": "Super", + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "range": [ + 31, + 36 + ] + }, + "property": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "range": [ + 37, + 45 + ], + "name": "toString" + }, + "computed": false, + "optional": false + }, + "arguments": [], + "optional": false + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "toString", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 14, + 22 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 23, + 24 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 25, + 26 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 26, + 27 + ] + }, + { + "type": "Punctuator", + "value": "=>", + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "range": [ + 28, + 30 + ] + }, + { + "type": "Keyword", + "value": "super", + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "range": [ + 31, + 36 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "range": [ + 36, + 37 + ] + }, + { + "type": "Identifier", + "value": "toString", + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "range": [ + 37, + 45 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "range": [ + 45, + 46 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 2, + "column": 36 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "range": [ + 46, + 47 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 48, + 49 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow-super.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow-super.src.js new file mode 100644 index 00000000..815789f4 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow-super.src.js @@ -0,0 +1,3 @@ +class C { + toString = () => super.toString() +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow.result.js new file mode 100644 index 00000000..61a21fcf --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow.result.js @@ -0,0 +1,335 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 29 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 29 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 8, + 29 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 14, + 27 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ], + "name": "aaa" + }, + "value": { + "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 20, + 27 + ], + "id": null, + "expression": true, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "Literal", + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 26, + 27 + ], + "value": 0, + "raw": "0" + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 20, + 21 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 21, + 22 + ] + }, + { + "type": "Punctuator", + "value": "=>", + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 25 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 26, + 27 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 28, + 29 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow.src.js new file mode 100644 index 00000000..32cf142e --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-init-arrow.src.js @@ -0,0 +1,3 @@ +class C { + aaa = () => 0 +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-init-super.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-init-super.result.js new file mode 100644 index 00000000..9e688158 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-init-super.result.js @@ -0,0 +1,330 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 126 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 126 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 8, + 126 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "range": [ + 104, + 124 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 104, + 107 + ], + "name": "aaa" + }, + "value": { + "type": "MemberExpression", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "range": [ + 110, + 124 + ], + "object": { + "type": "Super", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 110, + 115 + ] + }, + "property": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "range": [ + 116, + 124 + ], + "name": "toString" + }, + "computed": false, + "optional": false + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 104, + 107 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 108, + 109 + ] + }, + { + "type": "Keyword", + "value": "super", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 110, + 115 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 115, + 116 + ] + }, + { + "type": "Identifier", + "value": "toString", + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "range": [ + 116, + 124 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 125, + 126 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-init-super.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-init-super.src.js new file mode 100644 index 00000000..6c843d52 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-init-super.src.js @@ -0,0 +1,4 @@ +class C { + // Field initializers allow `super` properties even if it's outside of any functions. + aaa = super.toString +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting-use-first.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting-use-first.result.js new file mode 100644 index 00000000..e1fe0f52 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting-use-first.result.js @@ -0,0 +1,993 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "range": [ + 0, + 181 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "range": [ + 0, + 181 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 6, + 11 + ], + "name": "Outer" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "range": [ + 12, + 181 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "range": [ + 18, + 171 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 18, + 23 + ], + "name": "Inner" + }, + "value": { + "type": "ClassExpression", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "range": [ + 26, + 171 + ], + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "range": [ + 32, + 171 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 42, + 153 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 42, + 43 + ], + "name": "f" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 43, + 153 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 44, + 45 + ], + "name": "x" + }, + { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 47, + 48 + ], + "name": "y" + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 50, + 153 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "range": [ + 132, + 143 + ], + "expression": { + "type": "BinaryExpression", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "range": [ + 132, + 143 + ], + "left": { + "type": "MemberExpression", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "range": [ + 132, + 136 + ], + "object": { + "type": "Identifier", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "range": [ + 132, + 133 + ], + "name": "x" + }, + "property": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "range": [ + 134, + 136 + ], + "name": "a" + }, + "computed": false, + "optional": false + }, + "operator": "+", + "right": { + "type": "MemberExpression", + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "range": [ + 139, + 143 + ], + "object": { + "type": "Identifier", + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 20 + } + }, + "range": [ + 139, + 140 + ], + "name": "y" + }, + "property": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 5, + "column": 21 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "range": [ + 141, + 143 + ], + "name": "b" + }, + "computed": false, + "optional": false + } + } + } + ] + } + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "range": [ + 162, + 165 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "range": [ + 162, + 164 + ], + "name": "b" + }, + "value": null + } + ] + } + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "range": [ + 176, + 179 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "range": [ + 176, + 178 + ], + "name": "a" + }, + "value": null + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "Outer", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 6, + 11 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "Identifier", + "value": "Inner", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 18, + 23 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 24, + 25 + ] + }, + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 26, + 31 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "range": [ + 32, + 33 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 42, + 43 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 43, + 44 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 44, + 45 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 45, + 46 + ] + }, + { + "type": "Identifier", + "value": "y", + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 47, + 48 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 48, + 49 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 50, + 51 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "range": [ + 132, + 133 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "range": [ + 133, + 134 + ] + }, + { + "type": "PrivateIdentifier", + "value": "a", + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "range": [ + 134, + 136 + ] + }, + { + "type": "Punctuator", + "value": "+", + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 18 + } + }, + "range": [ + 137, + 138 + ] + }, + { + "type": "Identifier", + "value": "y", + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 20 + } + }, + "range": [ + 139, + 140 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 21 + } + }, + "range": [ + 140, + 141 + ] + }, + { + "type": "PrivateIdentifier", + "value": "b", + "loc": { + "start": { + "line": 5, + "column": 21 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "range": [ + 141, + 143 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 152, + 153 + ] + }, + { + "type": "PrivateIdentifier", + "value": "b", + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "range": [ + 162, + 164 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "range": [ + 164, + 165 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "range": [ + 170, + 171 + ] + }, + { + "type": "PrivateIdentifier", + "value": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "range": [ + 176, + 178 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "range": [ + 178, + 179 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "range": [ + 180, + 181 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting-use-first.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting-use-first.src.js new file mode 100644 index 00000000..c90f1332 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting-use-first.src.js @@ -0,0 +1,10 @@ +class Outer { + Inner = class { + f(x, y) { + // OK even if the private fields are defined after use. + x.#a + y.#b + } + #b; + } + #a; +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting.result.js new file mode 100644 index 00000000..d622b958 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting.result.js @@ -0,0 +1,993 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "range": [ + 0, + 182 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "range": [ + 0, + 182 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 6, + 11 + ], + "name": "Outer" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "range": [ + 12, + 182 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 87, + 90 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "range": [ + 87, + 89 + ], + "name": "a" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "range": [ + 95, + 180 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 95, + 100 + ], + "name": "Inner" + }, + "value": { + "type": "ClassExpression", + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "range": [ + 103, + 180 + ], + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "range": [ + 109, + 180 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "range": [ + 119, + 122 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 119, + 121 + ], + "name": "b" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "range": [ + 131, + 174 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 131, + 132 + ], + "name": "f" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "range": [ + 132, + 174 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "range": [ + 133, + 134 + ], + "name": "x" + }, + { + "type": "Identifier", + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 136, + 137 + ], + "name": "y" + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "range": [ + 139, + 174 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "range": [ + 153, + 164 + ], + "expression": { + "type": "BinaryExpression", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "range": [ + 153, + 164 + ], + "left": { + "type": "MemberExpression", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "range": [ + 153, + 157 + ], + "object": { + "type": "Identifier", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "range": [ + 153, + 154 + ], + "name": "x" + }, + "property": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "range": [ + 155, + 157 + ], + "name": "a" + }, + "computed": false, + "optional": false + }, + "operator": "+", + "right": { + "type": "MemberExpression", + "loc": { + "start": { + "line": 7, + "column": 19 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "range": [ + 160, + 164 + ], + "object": { + "type": "Identifier", + "loc": { + "start": { + "line": 7, + "column": 19 + }, + "end": { + "line": 7, + "column": 20 + } + }, + "range": [ + 160, + 161 + ], + "name": "y" + }, + "property": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 7, + "column": 21 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "range": [ + 162, + 164 + ], + "name": "b" + }, + "computed": false, + "optional": false + } + } + } + ] + } + } + } + ] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "Outer", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 6, + 11 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "PrivateIdentifier", + "value": "a", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "range": [ + 87, + 89 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 89, + 90 + ] + }, + { + "type": "Identifier", + "value": "Inner", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 95, + 100 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 101, + 102 + ] + }, + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "range": [ + 103, + 108 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "range": [ + 109, + 110 + ] + }, + { + "type": "PrivateIdentifier", + "value": "b", + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 119, + 121 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "range": [ + 121, + 122 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 131, + 132 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "range": [ + 132, + 133 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "range": [ + 133, + 134 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "range": [ + 134, + 135 + ] + }, + { + "type": "Identifier", + "value": "y", + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 136, + 137 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "range": [ + 137, + 138 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "range": [ + 139, + 140 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "range": [ + 153, + 154 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "range": [ + 154, + 155 + ] + }, + { + "type": "PrivateIdentifier", + "value": "a", + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "range": [ + 155, + 157 + ] + }, + { + "type": "Punctuator", + "value": "+", + "loc": { + "start": { + "line": 7, + "column": 17 + }, + "end": { + "line": 7, + "column": 18 + } + }, + "range": [ + 158, + 159 + ] + }, + { + "type": "Identifier", + "value": "y", + "loc": { + "start": { + "line": 7, + "column": 19 + }, + "end": { + "line": 7, + "column": 20 + } + }, + "range": [ + 160, + 161 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 7, + "column": 20 + }, + "end": { + "line": 7, + "column": 21 + } + }, + "range": [ + 161, + 162 + ] + }, + { + "type": "PrivateIdentifier", + "value": "b", + "loc": { + "start": { + "line": 7, + "column": 21 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "range": [ + 162, + 164 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "range": [ + 173, + 174 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "range": [ + 179, + 180 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "range": [ + 181, + 182 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting.src.js new file mode 100644 index 00000000..d1cd08e0 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-member-private-nesting.src.js @@ -0,0 +1,10 @@ +class Outer { + // Inner classes can access the private fields of outer classes. + #a; + Inner = class { + #b; + f(x, y) { + x.#a + y.#b + } + } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-member-private.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-member-private.result.js new file mode 100644 index 00000000..6dd762ab --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-member-private.result.js @@ -0,0 +1,517 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 51 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 51 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 8, + 51 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "range": [ + 14, + 16 + ], + "name": "a" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "range": [ + 22, + 49 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 22, + 23 + ], + "name": "f" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "range": [ + 23, + 49 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "range": [ + 26, + 49 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 36, + 43 + ], + "expression": { + "type": "MemberExpression", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 36, + 43 + ], + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 36, + 40 + ] + }, + "property": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 41, + 43 + ], + "name": "a" + }, + "computed": false, + "optional": false + } + } + ] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "PrivateIdentifier", + "value": "a", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "range": [ + 14, + 16 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "range": [ + 22, + 23 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "range": [ + 23, + 24 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 24, + 25 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 26, + 27 + ] + }, + { + "type": "Keyword", + "value": "this", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 36, + 40 + ] + }, + { + "type": "Punctuator", + "value": ".", + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 40, + 41 + ] + }, + { + "type": "PrivateIdentifier", + "value": "a", + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 41, + 43 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "range": [ + 48, + 49 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 50, + 51 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-member-private.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-member-private.src.js new file mode 100644 index 00000000..0ebd993f --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-member-private.src.js @@ -0,0 +1,6 @@ +class C { + #a; + f() { + this.#a + } +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-private-asi.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-private-asi.result.js new file mode 100644 index 00000000..829e04f2 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-private-asi.result.js @@ -0,0 +1,371 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 42 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 42 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 8, + 42 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 14, + 18 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 14, + 18 + ], + "name": "aaa" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 23, + 31 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 23, + 27 + ], + "name": "bbb" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 30, + 31 + ], + "value": 0, + "raw": "0" + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 36, + 40 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 36, + 40 + ], + "name": "ccc" + }, + "value": null + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "PrivateIdentifier", + "value": "aaa", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 14, + 18 + ] + }, + { + "type": "PrivateIdentifier", + "value": "bbb", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 23, + 27 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 28, + 29 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 30, + 31 + ] + }, + { + "type": "PrivateIdentifier", + "value": "ccc", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 36, + 40 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 41, + 42 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-private-asi.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-private-asi.src.js new file mode 100644 index 00000000..873abc17 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-private-asi.src.js @@ -0,0 +1,5 @@ +class C { + #aaa + #bbb = 0 + #ccc +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-private.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-private.result.js new file mode 100644 index 00000000..f3f5be9c --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-private.result.js @@ -0,0 +1,223 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 21 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 21 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 8, + 21 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 14, + 19 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 14, + 18 + ], + "name": "aaa" + }, + "value": null + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "PrivateIdentifier", + "value": "aaa", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 14, + 18 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 20, + 21 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-private.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-private.src.js new file mode 100644 index 00000000..4351b5cc --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-private.src.js @@ -0,0 +1,3 @@ +class C { + #aaa; +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-prototype.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-prototype.result.js new file mode 100644 index 00000000..768fea17 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-prototype.result.js @@ -0,0 +1,259 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 29 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 0, + 29 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 8, + 29 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 14, + 27 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 14, + 23 + ], + "name": "prototype" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 26, + 27 + ], + "value": 0, + "raw": "0" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "prototype", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 14, + 23 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 25 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 26, + 27 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "range": [ + 28, + 29 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-prototype.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-prototype.src.js new file mode 100644 index 00000000..c38df329 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-prototype.src.js @@ -0,0 +1,3 @@ +class C { + prototype = 0 +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-public-asi.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-public-asi.result.js new file mode 100644 index 00000000..2656721b --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-public-asi.result.js @@ -0,0 +1,371 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 39 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 39 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 8, + 39 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ], + "name": "aaa" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 22, + 29 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 22, + 25 + ], + "name": "bbb" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 28, + 29 + ], + "value": 0, + "raw": "0" + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "range": [ + 34, + 37 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "range": [ + 34, + 37 + ], + "name": "ccc" + }, + "value": null + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ] + }, + { + "type": "Identifier", + "value": "bbb", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 22, + 25 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 26, + 27 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 28, + 29 + ] + }, + { + "type": "Identifier", + "value": "ccc", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "range": [ + 34, + 37 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 38, + 39 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-public-asi.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-public-asi.src.js new file mode 100644 index 00000000..bcada874 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-public-asi.src.js @@ -0,0 +1,5 @@ +class C { + aaa + bbb = 0 + ccc +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-public.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-public.result.js new file mode 100644 index 00000000..19b4f2aa --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-public.result.js @@ -0,0 +1,223 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 81 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 81 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 8, + 81 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 75, + 79 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 75, + 78 + ], + "name": "aaa" + }, + "value": null + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 75, + 78 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 78, + 79 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 80, + 81 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-public.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-public.src.js new file mode 100644 index 00000000..2838d1ed --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-public.src.js @@ -0,0 +1,4 @@ +class C { + // Semicolon is in the range of PropertyDefinition node. + aaa; +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names-init.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names-init.result.js new file mode 100644 index 00000000..d0fb9081 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names-init.result.js @@ -0,0 +1,704 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 0, + 83 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 0, + 83 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 8, + 83 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 14, + 21 + ], + "static": false, + "computed": false, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ], + "value": 1000, + "raw": "1e3" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 20, + 21 + ], + "value": 0, + "raw": "0" + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 26, + 38 + ], + "static": false, + "computed": false, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 26, + 34 + ], + "value": "double", + "raw": "\"double\"" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 37, + 38 + ], + "value": 0, + "raw": "0" + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 43, + 55 + ], + "static": false, + "computed": false, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 43, + 51 + ], + "value": "single", + "raw": "'single'" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 54, + 55 + ], + "value": 0, + "raw": "0" + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 60, + 66 + ], + "static": false, + "computed": false, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "range": [ + 60, + 62 + ], + "value": 1n, + "raw": "1n", + "bigint": "1" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 65, + 66 + ], + "value": 0, + "raw": "0" + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 71, + 81 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "range": [ + 71, + 77 + ], + "name": "A" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 80, + 81 + ], + "value": 0, + "raw": "0" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Numeric", + "value": "1e3", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 20, + 21 + ] + }, + { + "type": "String", + "value": "\"double\"", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 26, + 34 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 35, + 36 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 37, + 38 + ] + }, + { + "type": "String", + "value": "'single'", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 43, + 51 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "range": [ + 52, + 53 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 54, + 55 + ] + }, + { + "type": "Numeric", + "value": "1n", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "range": [ + 60, + 62 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "range": [ + 63, + 64 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 65, + 66 + ] + }, + { + "type": "Identifier", + "value": "A", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "range": [ + 71, + 77 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "range": [ + 78, + 79 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 80, + 81 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 82, + 83 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names-init.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names-init.src.js new file mode 100644 index 00000000..1b21a82c --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names-init.src.js @@ -0,0 +1,7 @@ +class C { + 1e3 = 0 + "double" = 0 + 'single' = 0 + 1n = 0 + \u0041 = 0 +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names.result.js new file mode 100644 index 00000000..e795e89c --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names.result.js @@ -0,0 +1,434 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 0, + 63 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 0, + 63 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 8, + 63 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ], + "static": false, + "computed": false, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ], + "value": 1000, + "raw": "1e3" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 22, + 30 + ], + "static": false, + "computed": false, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 22, + 30 + ], + "value": "double", + "raw": "\"double\"" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 35, + 43 + ], + "static": false, + "computed": false, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 35, + 43 + ], + "value": "single", + "raw": "'single'" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "range": [ + 48, + 50 + ], + "static": false, + "computed": false, + "key": { + "type": "Literal", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "range": [ + 48, + 50 + ], + "value": 1n, + "raw": "1n", + "bigint": "1" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "range": [ + 55, + 61 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "range": [ + 55, + 61 + ], + "name": "A" + }, + "value": null + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Numeric", + "value": "1e3", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ] + }, + { + "type": "String", + "value": "\"double\"", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 22, + 30 + ] + }, + { + "type": "String", + "value": "'single'", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 35, + 43 + ] + }, + { + "type": "Numeric", + "value": "1n", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "range": [ + 48, + 50 + ] + }, + { + "type": "Identifier", + "value": "A", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "range": [ + 55, + 61 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "range": [ + 62, + 63 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names.src.js new file mode 100644 index 00000000..c6b427c3 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-special-field-names.src.js @@ -0,0 +1,7 @@ +class C { + 1e3 + "double" + 'single' + 1n + \u0041 +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-star-asi.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-star-asi.result.js new file mode 100644 index 00000000..29496308 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-star-asi.result.js @@ -0,0 +1,391 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 71 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 71 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 8, + 71 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 55, + 58 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 55, + 58 + ], + "name": "aaa" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 63, + 69 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "range": [ + 64, + 65 + ], + "name": "f" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 65, + 69 + ], + "id": null, + "expression": false, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 67, + 69 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 55, + 58 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 63, + 64 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "range": [ + 64, + 65 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "range": [ + 65, + 66 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 66, + 67 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 67, + 68 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 68, + 69 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 70, + 71 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-star-asi.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-star-asi.src.js new file mode 100644 index 00000000..27b2b8ef --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-star-asi.src.js @@ -0,0 +1,5 @@ +class C { + // Line breaks create fields by ASI. + aaa + *f(){} +} diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-star-no-asi.result.js b/tests/fixtures/ecma-version/13/class-fields/valid-star-no-asi.result.js new file mode 100644 index 00000000..f8ad6c33 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-star-no-asi.result.js @@ -0,0 +1,386 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 57 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 57 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 8, + 57 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 39, + 55 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 39, + 42 + ], + "name": "aaa" + }, + "value": { + "type": "BinaryExpression", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 45, + 55 + ], + "left": { + "type": "Literal", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 45, + 46 + ], + "value": 2, + "raw": "2" + }, + "operator": "*", + "right": { + "type": "CallExpression", + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 52, + 55 + ], + "callee": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "range": [ + 52, + 53 + ], + "name": "f" + }, + "arguments": [], + "optional": false + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 39, + 42 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 43, + 44 + ] + }, + { + "type": "Numeric", + "value": "2", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 45, + 46 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 51, + 52 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "range": [ + 52, + 53 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "range": [ + 53, + 54 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 54, + 55 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 56, + 57 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/class-fields/valid-star-no-asi.src.js b/tests/fixtures/ecma-version/13/class-fields/valid-star-no-asi.src.js new file mode 100644 index 00000000..4eec00e2 --- /dev/null +++ b/tests/fixtures/ecma-version/13/class-fields/valid-star-no-asi.src.js @@ -0,0 +1,5 @@ +class C { + // This is `2 * f()` + aaa = 2 + *f() +} diff --git a/tests/fixtures/ecma-version/13/private-methods/invalid-conflict-names.result.js b/tests/fixtures/ecma-version/13/private-methods/invalid-conflict-names.result.js new file mode 100644 index 00000000..71125475 --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/invalid-conflict-names.result.js @@ -0,0 +1,6 @@ +export default { + "index": 25, + "lineNumber": 3, + "column": 5, + "message": "Identifier '#a' has already been declared" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/private-methods/invalid-conflict-names.src.js b/tests/fixtures/ecma-version/13/private-methods/invalid-conflict-names.src.js new file mode 100644 index 00000000..720d6100 --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/invalid-conflict-names.src.js @@ -0,0 +1,4 @@ +class C { + #a(){} + #a(){} +} diff --git a/tests/fixtures/ecma-version/13/private-methods/invalid-constructor.result.js b/tests/fixtures/ecma-version/13/private-methods/invalid-constructor.result.js new file mode 100644 index 00000000..c9c25ffb --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/invalid-constructor.result.js @@ -0,0 +1,6 @@ +export default { + "index": 14, + "lineNumber": 2, + "column": 5, + "message": "Classes can't have an element named '#constructor'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/private-methods/invalid-constructor.src.js b/tests/fixtures/ecma-version/13/private-methods/invalid-constructor.src.js new file mode 100644 index 00000000..51e1df4a --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/invalid-constructor.src.js @@ -0,0 +1,3 @@ +class C { + #constructor() {} +} diff --git a/tests/fixtures/ecma-version/13/private-methods/valid-accessor.result.js b/tests/fixtures/ecma-version/13/private-methods/valid-accessor.result.js new file mode 100644 index 00000000..fac9f926 --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/valid-accessor.result.js @@ -0,0 +1,558 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 48 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 48 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 8, + 48 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 14, + 27 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 18, + 22 + ], + "name": "aaa" + }, + "kind": "get", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 22, + 27 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 25, + 27 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "range": [ + 32, + 46 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 36, + 40 + ], + "name": "aaa" + }, + "kind": "set", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "range": [ + 40, + 46 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 41, + 42 + ], + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "range": [ + 44, + 46 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "get", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 14, + 17 + ] + }, + { + "type": "PrivateIdentifier", + "value": "aaa", + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 18, + 22 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 22, + 23 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 23, + 24 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 25, + 26 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 26, + 27 + ] + }, + { + "type": "Identifier", + "value": "set", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 32, + 35 + ] + }, + { + "type": "PrivateIdentifier", + "value": "aaa", + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 36, + 40 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 40, + 41 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 41, + 42 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 42, + 43 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 44, + 45 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "range": [ + 45, + 46 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 47, + 48 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/private-methods/valid-accessor.src.js b/tests/fixtures/ecma-version/13/private-methods/valid-accessor.src.js new file mode 100644 index 00000000..5960dc5f --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/valid-accessor.src.js @@ -0,0 +1,4 @@ +class C { + get #aaa() {} + set #aaa(x) {} +} diff --git a/tests/fixtures/ecma-version/13/private-methods/valid-async-asi.result.js b/tests/fixtures/ecma-version/13/private-methods/valid-async-asi.result.js new file mode 100644 index 00000000..263381c7 --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/valid-async-asi.result.js @@ -0,0 +1,615 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 0, + 136 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 0, + 136 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 8, + 136 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 75, + 80 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 75, + 80 + ], + "name": "async" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 85, + 97 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 85, + 92 + ], + "name": "method" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 92, + 97 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 95, + 97 + ], + "body": [] + } + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 107, + 112 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 107, + 112 + ], + "name": "async" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 21 + } + }, + "range": [ + 117, + 134 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "range": [ + 119, + 129 + ], + "name": "generator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 7, + "column": 21 + } + }, + "range": [ + 129, + 134 + ], + "id": null, + "expression": false, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 7, + "column": 19 + }, + "end": { + "line": 7, + "column": 21 + } + }, + "range": [ + 132, + 134 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 75, + 80 + ] + }, + { + "type": "PrivateIdentifier", + "value": "method", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 85, + 92 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 92, + 93 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 93, + 94 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 95, + 96 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 96, + 97 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 107, + 112 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 5 + } + }, + "range": [ + 117, + 118 + ] + }, + { + "type": "PrivateIdentifier", + "value": "generator", + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "range": [ + 119, + 129 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 7, + "column": 17 + } + }, + "range": [ + 129, + 130 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 7, + "column": 17 + }, + "end": { + "line": 7, + "column": 18 + } + }, + "range": [ + 130, + 131 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 7, + "column": 19 + }, + "end": { + "line": 7, + "column": 20 + } + }, + "range": [ + 132, + 133 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 7, + "column": 20 + }, + "end": { + "line": 7, + "column": 21 + } + }, + "range": [ + 133, + 134 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 135, + 136 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/private-methods/valid-async-asi.src.js b/tests/fixtures/ecma-version/13/private-methods/valid-async-asi.src.js new file mode 100644 index 00000000..9db6c94b --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/valid-async-asi.src.js @@ -0,0 +1,8 @@ +class C { + // Line breaks preceded by `async` create fields by ASI. + async + #method() {} + + async + * #generator() {} +} diff --git a/tests/fixtures/ecma-version/13/private-methods/valid-contextual-keywords-no-asi.result.js b/tests/fixtures/ecma-version/13/private-methods/valid-contextual-keywords-no-asi.result.js new file mode 100644 index 00000000..2e6fdcee --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/valid-contextual-keywords-no-asi.result.js @@ -0,0 +1,762 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 0, + 142 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 0, + 142 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 8, + 142 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 59, + 78 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 67, + 74 + ], + "name": "getter" + }, + "kind": "get", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 74, + 78 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 76, + 78 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "range": [ + 84, + 104 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "range": [ + 92, + 99 + ], + "name": "setter" + }, + "kind": "set", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "range": [ + 99, + 104 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "range": [ + 100, + 101 + ], + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "range": [ + 102, + 104 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 10, + "column": 23 + } + }, + "range": [ + 110, + 140 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 10, + "column": 4 + }, + "end": { + "line": 10, + "column": 19 + } + }, + "range": [ + 121, + 136 + ], + "name": "asyncGenerator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 23 + } + }, + "range": [ + 136, + 140 + ], + "id": null, + "expression": false, + "generator": true, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 10, + "column": 21 + }, + "end": { + "line": 10, + "column": 23 + } + }, + "range": [ + 138, + 140 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "get", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 59, + 62 + ] + }, + { + "type": "PrivateIdentifier", + "value": "getter", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 67, + 74 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "range": [ + 74, + 75 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 75, + 76 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "range": [ + 76, + 77 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 77, + 78 + ] + }, + { + "type": "Identifier", + "value": "set", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "range": [ + 84, + 87 + ] + }, + { + "type": "PrivateIdentifier", + "value": "setter", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "range": [ + 92, + 99 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 99, + 100 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "range": [ + 100, + 101 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "range": [ + 101, + 102 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 15 + } + }, + "range": [ + 102, + 103 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 7, + "column": 15 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "range": [ + 103, + 104 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "range": [ + 110, + 115 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "range": [ + 115, + 116 + ] + }, + { + "type": "PrivateIdentifier", + "value": "asyncGenerator", + "loc": { + "start": { + "line": 10, + "column": 4 + }, + "end": { + "line": 10, + "column": 19 + } + }, + "range": [ + 121, + 136 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 20 + } + }, + "range": [ + 136, + 137 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 21 + } + }, + "range": [ + 137, + 138 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 10, + "column": 21 + }, + "end": { + "line": 10, + "column": 22 + } + }, + "range": [ + 138, + 139 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 10, + "column": 22 + }, + "end": { + "line": 10, + "column": 23 + } + }, + "range": [ + 139, + 140 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 141, + 142 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/private-methods/valid-contextual-keywords-no-asi.src.js b/tests/fixtures/ecma-version/13/private-methods/valid-contextual-keywords-no-asi.src.js new file mode 100644 index 00000000..bf8227b1 --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/valid-contextual-keywords-no-asi.src.js @@ -0,0 +1,11 @@ +class C { + // Line breaks don't make fields by ASI. + get + #getter(){} + + set + #setter(x){} + + async* + #asyncGenerator(){} +} diff --git a/tests/fixtures/ecma-version/13/private-methods/valid-methods.result.js b/tests/fixtures/ecma-version/13/private-methods/valid-methods.result.js new file mode 100644 index 00000000..ae5afd90 --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/valid-methods.result.js @@ -0,0 +1,893 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 104 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 104 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 8, + 104 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 14, + 26 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 14, + 21 + ], + "name": "normal" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 21, + 26 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 24, + 26 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 31, + 48 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 37, + 43 + ], + "name": "async" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 43, + 48 + ], + "id": null, + "expression": false, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 46, + 48 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 21 + } + }, + "range": [ + 53, + 70 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 55, + 65 + ], + "name": "generator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 21 + } + }, + "range": [ + 65, + 70 + ], + "id": null, + "expression": false, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 21 + } + }, + "range": [ + 68, + 70 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "range": [ + 75, + 102 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "range": [ + 82, + 97 + ], + "name": "asyncGenerator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "range": [ + 97, + 102 + ], + "id": null, + "expression": false, + "generator": true, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "range": [ + 100, + 102 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "PrivateIdentifier", + "value": "normal", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 14, + 21 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 21, + 22 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 22, + 23 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 25 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 25, + 26 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "range": [ + 31, + 36 + ] + }, + { + "type": "PrivateIdentifier", + "value": "async", + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 37, + 43 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 43, + 44 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "range": [ + 44, + 45 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "range": [ + 46, + 47 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 47, + 48 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 53, + 54 + ] + }, + { + "type": "PrivateIdentifier", + "value": "generator", + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 55, + 65 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "range": [ + 65, + 66 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "range": [ + 66, + 67 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 20 + } + }, + "range": [ + 68, + 69 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 21 + } + }, + "range": [ + 69, + 70 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "range": [ + 75, + 80 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 80, + 81 + ] + }, + { + "type": "PrivateIdentifier", + "value": "asyncGenerator", + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "range": [ + 82, + 97 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 27 + } + }, + "range": [ + 97, + 98 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "range": [ + 98, + 99 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "range": [ + 100, + 101 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "range": [ + 101, + 102 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 103, + 104 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/private-methods/valid-methods.src.js b/tests/fixtures/ecma-version/13/private-methods/valid-methods.src.js new file mode 100644 index 00000000..c1a99bca --- /dev/null +++ b/tests/fixtures/ecma-version/13/private-methods/valid-methods.src.js @@ -0,0 +1,6 @@ +class C { + #normal() {} + async #async() {} + * #generator() {} + async* #asyncGenerator() {} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-conflict-names.result.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-conflict-names.result.js new file mode 100644 index 00000000..17688abc --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-conflict-names.result.js @@ -0,0 +1,6 @@ +export default { + "index": 210, + "lineNumber": 5, + "column": 16, + "message": "Identifier '#a' has already been declared" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-conflict-names.src.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-conflict-names.src.js new file mode 100644 index 00000000..d5a9090b --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-conflict-names.src.js @@ -0,0 +1,6 @@ +class C { + // getter/setter pair conflicts if `static` attributes are different. + // (static members and instance members are on the same namespace about naming conflicts.) + get #a() {} + static set #a(x) {} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-private-field-constructor.result.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-field-constructor.result.js new file mode 100644 index 00000000..5320beb0 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-field-constructor.result.js @@ -0,0 +1,6 @@ +export default { + "index": 21, + "lineNumber": 2, + "column": 12, + "message": "Classes can't have an element named '#constructor'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-private-field-constructor.src.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-field-constructor.src.js new file mode 100644 index 00000000..77132340 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-field-constructor.src.js @@ -0,0 +1,3 @@ +class C { + static #constructor = () => {} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-private-getter-constructor.result.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-getter-constructor.result.js new file mode 100644 index 00000000..fcb083c2 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-getter-constructor.result.js @@ -0,0 +1,6 @@ +export default { + "index": 25, + "lineNumber": 2, + "column": 16, + "message": "Classes can't have an element named '#constructor'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-private-getter-constructor.src.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-getter-constructor.src.js new file mode 100644 index 00000000..7e89b4da --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-getter-constructor.src.js @@ -0,0 +1,3 @@ +class C { + static get #constructor() {} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-private-method-constructor.result.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-method-constructor.result.js new file mode 100644 index 00000000..5320beb0 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-method-constructor.result.js @@ -0,0 +1,6 @@ +export default { + "index": 21, + "lineNumber": 2, + "column": 12, + "message": "Classes can't have an element named '#constructor'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-private-method-constructor.src.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-method-constructor.src.js new file mode 100644 index 00000000..59124f3e --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-method-constructor.src.js @@ -0,0 +1,3 @@ +class C { + static #constructor() {} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-private-setter-constructor.result.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-setter-constructor.result.js new file mode 100644 index 00000000..fcb083c2 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-setter-constructor.result.js @@ -0,0 +1,6 @@ +export default { + "index": 25, + "lineNumber": 2, + "column": 16, + "message": "Classes can't have an element named '#constructor'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-private-setter-constructor.src.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-setter-constructor.src.js new file mode 100644 index 00000000..25d7a530 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-private-setter-constructor.src.js @@ -0,0 +1,3 @@ +class C { + static set #constructor(x) {} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-constructor.result.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-constructor.result.js new file mode 100644 index 00000000..6f1ac47e --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-constructor.result.js @@ -0,0 +1,6 @@ +export default { + "index": 21, + "lineNumber": 2, + "column": 12, + "message": "Classes can't have a field named 'constructor'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-constructor.src.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-constructor.src.js new file mode 100644 index 00000000..cbd8d3c9 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-constructor.src.js @@ -0,0 +1,3 @@ +class C { + static constructor = () => {} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-prototype.result.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-prototype.result.js new file mode 100644 index 00000000..831bed4c --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-prototype.result.js @@ -0,0 +1,6 @@ +export default { + "index": 21, + "lineNumber": 2, + "column": 12, + "message": "Classes can't have a static field named 'prototype'" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-prototype.src.js b/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-prototype.src.js new file mode 100644 index 00000000..53bbb5df --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/invalid-public-field-prototype.src.js @@ -0,0 +1,3 @@ +class C { + static prototype = {} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-async-asi.result.js b/tests/fixtures/ecma-version/13/static-class-features/valid-async-asi.result.js new file mode 100644 index 00000000..843841d4 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-async-asi.result.js @@ -0,0 +1,1153 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 18, + "column": 1 + } + }, + "range": [ + 0, + 247 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 18, + "column": 1 + } + }, + "range": [ + 0, + 247 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 18, + "column": 1 + } + }, + "range": [ + 8, + 247 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 75, + 91 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 86, + 91 + ], + "name": "async" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "range": [ + 96, + 108 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "range": [ + 96, + 103 + ], + "name": "method" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "range": [ + 103, + 108 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "range": [ + 106, + 108 + ], + "body": [] + } + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "range": [ + 118, + 134 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "range": [ + 129, + 134 + ], + "name": "async" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 21 + } + }, + "range": [ + 139, + 156 + ], + "static": false, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 16 + } + }, + "range": [ + 141, + 151 + ], + "name": "generator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 9, + "column": 16 + }, + "end": { + "line": 9, + "column": 21 + } + }, + "range": [ + 151, + 156 + ], + "id": null, + "expression": false, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 9, + "column": 19 + }, + "end": { + "line": 9, + "column": 21 + } + }, + "range": [ + 154, + 156 + ], + "body": [] + } + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 11, + "column": 4 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "range": [ + 166, + 182 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "range": [ + 177, + 182 + ], + "name": "async" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 15 + } + }, + "range": [ + 187, + 198 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "range": [ + 187, + 193 + ], + "name": "method" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 13, + "column": 15 + } + }, + "range": [ + 193, + 198 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 13, + "column": 13 + }, + "end": { + "line": 13, + "column": 15 + } + }, + "range": [ + 196, + 198 + ], + "body": [] + } + } + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 15, + "column": 4 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "range": [ + 208, + 224 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "range": [ + 219, + 224 + ], + "name": "async" + }, + "value": null + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 17, + "column": 4 + }, + "end": { + "line": 17, + "column": 20 + } + }, + "range": [ + 229, + 245 + ], + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 15 + } + }, + "range": [ + 231, + 240 + ], + "name": "generator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 17, + "column": 15 + }, + "end": { + "line": 17, + "column": 20 + } + }, + "range": [ + 240, + 245 + ], + "id": null, + "expression": false, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 17, + "column": 18 + }, + "end": { + "line": 17, + "column": 20 + } + }, + "range": [ + 243, + 245 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 75, + 81 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 86, + 91 + ] + }, + { + "type": "PrivateIdentifier", + "value": "method", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "range": [ + 96, + 103 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 12 + } + }, + "range": [ + 103, + 104 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "range": [ + 104, + 105 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "range": [ + 106, + 107 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "range": [ + 107, + 108 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "range": [ + 118, + 124 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "range": [ + 129, + 134 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "range": [ + 139, + 140 + ] + }, + { + "type": "PrivateIdentifier", + "value": "generator", + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 16 + } + }, + "range": [ + 141, + 151 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 9, + "column": 16 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "range": [ + 151, + 152 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 18 + } + }, + "range": [ + 152, + 153 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 9, + "column": 19 + }, + "end": { + "line": 9, + "column": 20 + } + }, + "range": [ + 154, + 155 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 9, + "column": 20 + }, + "end": { + "line": 9, + "column": 21 + } + }, + "range": [ + 155, + 156 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 11, + "column": 4 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "range": [ + 166, + 172 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "range": [ + 177, + 182 + ] + }, + { + "type": "Identifier", + "value": "method", + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "range": [ + 187, + 193 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 13, + "column": 11 + } + }, + "range": [ + 193, + 194 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 13, + "column": 11 + }, + "end": { + "line": 13, + "column": 12 + } + }, + "range": [ + 194, + 195 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 13, + "column": 13 + }, + "end": { + "line": 13, + "column": 14 + } + }, + "range": [ + 196, + 197 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 13, + "column": 14 + }, + "end": { + "line": 13, + "column": 15 + } + }, + "range": [ + 197, + 198 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 15, + "column": 4 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "range": [ + 208, + 214 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "range": [ + 219, + 224 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 17, + "column": 4 + }, + "end": { + "line": 17, + "column": 5 + } + }, + "range": [ + 229, + 230 + ] + }, + { + "type": "Identifier", + "value": "generator", + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 15 + } + }, + "range": [ + 231, + 240 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 17, + "column": 15 + }, + "end": { + "line": 17, + "column": 16 + } + }, + "range": [ + 240, + 241 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 17, + "column": 17 + } + }, + "range": [ + 241, + 242 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 17, + "column": 18 + }, + "end": { + "line": 17, + "column": 19 + } + }, + "range": [ + 243, + 244 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 20 + } + }, + "range": [ + 244, + 245 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 1 + } + }, + "range": [ + 246, + 247 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-async-asi.src.js b/tests/fixtures/ecma-version/13/static-class-features/valid-async-asi.src.js new file mode 100644 index 00000000..b1f91eed --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-async-asi.src.js @@ -0,0 +1,18 @@ +class C { + // Line breaks preceded by `async` create fields by ASI. + static + async + #method() {} + + static + async + * #generator() {} + + static + async + method() {} + + static + async + * generator() {} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-contextual-keywords-no-asi.result.js b/tests/fixtures/ecma-version/13/static-class-features/valid-contextual-keywords-no-asi.result.js new file mode 100644 index 00000000..874bf3d2 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-contextual-keywords-no-asi.result.js @@ -0,0 +1,1819 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 30, + "column": 1 + } + }, + "range": [ + 0, + 351 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 30, + "column": 1 + } + }, + "range": [ + 0, + 351 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 30, + "column": 1 + } + }, + "range": [ + 8, + 351 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 59, + 77 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "range": [ + 70, + 73 + ], + "name": "get" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 73, + 77 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 75, + 77 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 83, + 102 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "range": [ + 94, + 97 + ], + "name": "set" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 97, + 102 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "range": [ + 98, + 99 + ], + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 100, + 102 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 10, + "column": 13 + } + }, + "range": [ + 108, + 128 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 10, + "column": 4 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "range": [ + 119, + 124 + ], + "name": "async" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 13 + } + }, + "range": [ + 124, + 128 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 13 + } + }, + "range": [ + 126, + 128 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "range": [ + 134, + 169 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 16 + } + }, + "range": [ + 153, + 165 + ], + "name": "staticGetter" + }, + "kind": "get", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 14, + "column": 16 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "range": [ + 165, + 169 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 14, + "column": 18 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "range": [ + 167, + 169 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 18, + "column": 21 + } + }, + "range": [ + 175, + 211 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 18, + "column": 4 + }, + "end": { + "line": 18, + "column": 16 + } + }, + "range": [ + 194, + 206 + ], + "name": "staticGetter" + }, + "kind": "set", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 18, + "column": 16 + }, + "end": { + "line": 18, + "column": 21 + } + }, + "range": [ + 206, + 211 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 18 + } + }, + "range": [ + 207, + 208 + ], + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 18, + "column": 19 + }, + "end": { + "line": 18, + "column": 21 + } + }, + "range": [ + 209, + 211 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 20, + "column": 4 + }, + "end": { + "line": 22, + "column": 23 + } + }, + "range": [ + 217, + 253 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 22, + "column": 4 + }, + "end": { + "line": 22, + "column": 19 + } + }, + "range": [ + 234, + 249 + ], + "name": "staticGenerator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 22, + "column": 19 + }, + "end": { + "line": 22, + "column": 23 + } + }, + "range": [ + 249, + 253 + ], + "id": null, + "expression": false, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 22, + "column": 23 + } + }, + "range": [ + 251, + 253 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 24, + "column": 4 + }, + "end": { + "line": 25, + "column": 31 + } + }, + "range": [ + 259, + 297 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 25, + "column": 10 + }, + "end": { + "line": 25, + "column": 27 + } + }, + "range": [ + 276, + 293 + ], + "name": "staticAsyncMethod" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 25, + "column": 27 + }, + "end": { + "line": 25, + "column": 31 + } + }, + "range": [ + 293, + 297 + ], + "id": null, + "expression": false, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 25, + "column": 29 + }, + "end": { + "line": 25, + "column": 31 + } + }, + "range": [ + 295, + 297 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 27, + "column": 4 + }, + "end": { + "line": 29, + "column": 28 + } + }, + "range": [ + 303, + 349 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 29, + "column": 4 + }, + "end": { + "line": 29, + "column": 24 + } + }, + "range": [ + 325, + 345 + ], + "name": "staticAsyncGenerator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 29, + "column": 24 + }, + "end": { + "line": 29, + "column": 28 + } + }, + "range": [ + 345, + 349 + ], + "id": null, + "expression": false, + "generator": true, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 29, + "column": 26 + }, + "end": { + "line": 29, + "column": 28 + } + }, + "range": [ + 347, + 349 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 59, + 65 + ] + }, + { + "type": "Identifier", + "value": "get", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "range": [ + 70, + 73 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 73, + 74 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 74, + 75 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 75, + 76 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "range": [ + 76, + 77 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "range": [ + 83, + 89 + ] + }, + { + "type": "Identifier", + "value": "set", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "range": [ + 94, + 97 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "range": [ + 97, + 98 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "range": [ + 98, + 99 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "range": [ + 99, + 100 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "range": [ + 100, + 101 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 101, + 102 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "range": [ + 108, + 114 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 10, + "column": 4 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "range": [ + 119, + 124 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "range": [ + 124, + 125 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "range": [ + 125, + 126 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 126, + 127 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 10, + "column": 12 + }, + "end": { + "line": 10, + "column": 13 + } + }, + "range": [ + 127, + 128 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 10 + } + }, + "range": [ + 134, + 140 + ] + }, + { + "type": "Identifier", + "value": "get", + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 7 + } + }, + "range": [ + 145, + 148 + ] + }, + { + "type": "Identifier", + "value": "staticGetter", + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 16 + } + }, + "range": [ + 153, + 165 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 14, + "column": 16 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "range": [ + 165, + 166 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 18 + } + }, + "range": [ + 166, + 167 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 14, + "column": 18 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "range": [ + 167, + 168 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "range": [ + 168, + 169 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "range": [ + 175, + 181 + ] + }, + { + "type": "Identifier", + "value": "set", + "loc": { + "start": { + "line": 17, + "column": 4 + }, + "end": { + "line": 17, + "column": 7 + } + }, + "range": [ + 186, + 189 + ] + }, + { + "type": "Identifier", + "value": "staticGetter", + "loc": { + "start": { + "line": 18, + "column": 4 + }, + "end": { + "line": 18, + "column": 16 + } + }, + "range": [ + 194, + 206 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 18, + "column": 16 + }, + "end": { + "line": 18, + "column": 17 + } + }, + "range": [ + 206, + 207 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 18 + } + }, + "range": [ + 207, + 208 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 18, + "column": 18 + }, + "end": { + "line": 18, + "column": 19 + } + }, + "range": [ + 208, + 209 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 18, + "column": 19 + }, + "end": { + "line": 18, + "column": 20 + } + }, + "range": [ + 209, + 210 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 21 + } + }, + "range": [ + 210, + 211 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 20, + "column": 4 + }, + "end": { + "line": 20, + "column": 10 + } + }, + "range": [ + 217, + 223 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 21, + "column": 4 + }, + "end": { + "line": 21, + "column": 5 + } + }, + "range": [ + 228, + 229 + ] + }, + { + "type": "Identifier", + "value": "staticGenerator", + "loc": { + "start": { + "line": 22, + "column": 4 + }, + "end": { + "line": 22, + "column": 19 + } + }, + "range": [ + 234, + 249 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 22, + "column": 19 + }, + "end": { + "line": 22, + "column": 20 + } + }, + "range": [ + 249, + 250 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 22, + "column": 20 + }, + "end": { + "line": 22, + "column": 21 + } + }, + "range": [ + 250, + 251 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 22, + "column": 22 + } + }, + "range": [ + 251, + 252 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 22, + "column": 22 + }, + "end": { + "line": 22, + "column": 23 + } + }, + "range": [ + 252, + 253 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 24, + "column": 4 + }, + "end": { + "line": 24, + "column": 10 + } + }, + "range": [ + 259, + 265 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 25, + "column": 4 + }, + "end": { + "line": 25, + "column": 9 + } + }, + "range": [ + 270, + 275 + ] + }, + { + "type": "Identifier", + "value": "staticAsyncMethod", + "loc": { + "start": { + "line": 25, + "column": 10 + }, + "end": { + "line": 25, + "column": 27 + } + }, + "range": [ + 276, + 293 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 25, + "column": 27 + }, + "end": { + "line": 25, + "column": 28 + } + }, + "range": [ + 293, + 294 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 25, + "column": 28 + }, + "end": { + "line": 25, + "column": 29 + } + }, + "range": [ + 294, + 295 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 25, + "column": 29 + }, + "end": { + "line": 25, + "column": 30 + } + }, + "range": [ + 295, + 296 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 25, + "column": 30 + }, + "end": { + "line": 25, + "column": 31 + } + }, + "range": [ + 296, + 297 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 27, + "column": 4 + }, + "end": { + "line": 27, + "column": 10 + } + }, + "range": [ + 303, + 309 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 28, + "column": 4 + }, + "end": { + "line": 28, + "column": 9 + } + }, + "range": [ + 314, + 319 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 28, + "column": 9 + }, + "end": { + "line": 28, + "column": 10 + } + }, + "range": [ + 319, + 320 + ] + }, + { + "type": "Identifier", + "value": "staticAsyncGenerator", + "loc": { + "start": { + "line": 29, + "column": 4 + }, + "end": { + "line": 29, + "column": 24 + } + }, + "range": [ + 325, + 345 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 29, + "column": 24 + }, + "end": { + "line": 29, + "column": 25 + } + }, + "range": [ + 345, + 346 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 29, + "column": 25 + }, + "end": { + "line": 29, + "column": 26 + } + }, + "range": [ + 346, + 347 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 29, + "column": 26 + }, + "end": { + "line": 29, + "column": 27 + } + }, + "range": [ + 347, + 348 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 29, + "column": 27 + }, + "end": { + "line": 29, + "column": 28 + } + }, + "range": [ + 348, + 349 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 30, + "column": 0 + }, + "end": { + "line": 30, + "column": 1 + } + }, + "range": [ + 350, + 351 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-contextual-keywords-no-asi.src.js b/tests/fixtures/ecma-version/13/static-class-features/valid-contextual-keywords-no-asi.src.js new file mode 100644 index 00000000..0e70bbf5 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-contextual-keywords-no-asi.src.js @@ -0,0 +1,30 @@ +class C { + // Line breaks don't make fields by ASI. + static + get(){} + + static + set(x){} + + static + async(){} + + static + get + staticGetter(){} + + static + set + staticGetter(x){} + + static + * + staticGenerator(){} + + static + async staticAsyncMethod(){} + + static + async* + staticAsyncGenerator(){} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-private-accessors.result.js b/tests/fixtures/ecma-version/13/static-class-features/valid-private-accessors.result.js new file mode 100644 index 00000000..2d01ed55 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-private-accessors.result.js @@ -0,0 +1,630 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 62 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 62 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 8, + 62 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 14, + 33 + ], + "static": true, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "range": [ + 25, + 29 + ], + "name": "aaa" + }, + "kind": "get", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 29, + 33 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 31, + 33 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "range": [ + 39, + 59 + ], + "static": true, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [ + 50, + 54 + ], + "name": "aaa" + }, + "kind": "set", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "range": [ + 54, + 59 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 55, + 56 + ], + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "range": [ + 57, + 59 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "range": [ + 14, + 20 + ] + }, + { + "type": "Identifier", + "value": "get", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 21, + 24 + ] + }, + { + "type": "PrivateIdentifier", + "value": "aaa", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "range": [ + 25, + 29 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "range": [ + 29, + 30 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 30, + 31 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 32, + 33 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "range": [ + 33, + 34 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 39, + 45 + ] + }, + { + "type": "Identifier", + "value": "set", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 46, + 49 + ] + }, + { + "type": "PrivateIdentifier", + "value": "aaa", + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [ + 50, + 54 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "range": [ + 54, + 55 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 55, + 56 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "range": [ + 56, + 57 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 57, + 58 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "range": [ + 58, + 59 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "range": [ + 59, + 60 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 61, + 62 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-private-accessors.src.js b/tests/fixtures/ecma-version/13/static-class-features/valid-private-accessors.src.js new file mode 100644 index 00000000..917efe58 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-private-accessors.src.js @@ -0,0 +1,4 @@ +class C { + static get #aaa(){}; + static set #aaa(x){}; +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-private-fields.result.js b/tests/fixtures/ecma-version/13/static-class-features/valid-private-fields.result.js new file mode 100644 index 00000000..1f747b02 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-private-fields.result.js @@ -0,0 +1,387 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 49 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 49 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 8, + 49 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 14, + 26 + ], + "static": true, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 21, + 25 + ], + "name": "aaa" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "range": [ + 31, + 47 + ], + "static": true, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 38, + 42 + ], + "name": "bbb" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [ + 45, + 46 + ], + "value": 0, + "raw": "0" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "range": [ + 14, + 20 + ] + }, + { + "type": "PrivateIdentifier", + "value": "aaa", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 21, + 25 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 25, + 26 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 31, + 37 + ] + }, + { + "type": "PrivateIdentifier", + "value": "bbb", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 38, + 42 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 43, + 44 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [ + 45, + 46 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "range": [ + 46, + 47 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 48, + 49 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-private-fields.src.js b/tests/fixtures/ecma-version/13/static-class-features/valid-private-fields.src.js new file mode 100644 index 00000000..07be5668 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-private-fields.src.js @@ -0,0 +1,4 @@ +class C { + static #aaa; + static #bbb = 0; +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-private-methods.result.js b/tests/fixtures/ecma-version/13/static-class-features/valid-private-methods.result.js new file mode 100644 index 00000000..8064b579 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-private-methods.result.js @@ -0,0 +1,965 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 128 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 0, + 128 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 8, + 128 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 14, + 32 + ], + "static": true, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 21, + 28 + ], + "name": "method" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 28, + 32 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 30, + 32 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 27 + } + }, + "range": [ + 37, + 60 + ], + "static": true, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 46, + 56 + ], + "name": "generator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 3, + "column": 27 + } + }, + "range": [ + 56, + 60 + ], + "id": null, + "expression": false, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 27 + } + }, + "range": [ + 58, + 60 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 27 + } + }, + "range": [ + 65, + 88 + ], + "static": true, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "range": [ + 78, + 84 + ], + "name": "async" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 27 + } + }, + "range": [ + 84, + 88 + ], + "id": null, + "expression": false, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 27 + } + }, + "range": [ + 86, + 88 + ], + "body": [] + } + } + }, + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "range": [ + 93, + 126 + ], + "static": true, + "computed": false, + "key": { + "type": "PrivateIdentifier", + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "range": [ + 107, + 122 + ], + "name": "asyncGenerator" + }, + "kind": "method", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "range": [ + 122, + 126 + ], + "id": null, + "expression": false, + "generator": true, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "range": [ + 124, + 126 + ], + "body": [] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "range": [ + 14, + 20 + ] + }, + { + "type": "PrivateIdentifier", + "value": "method", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 21, + 28 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "range": [ + 28, + 29 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "range": [ + 29, + 30 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 30, + 31 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 37, + 43 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "range": [ + 44, + 45 + ] + }, + { + "type": "PrivateIdentifier", + "value": "generator", + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 46, + 56 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "range": [ + 56, + 57 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "range": [ + 57, + 58 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 58, + 59 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 27 + } + }, + "range": [ + 59, + 60 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "range": [ + 65, + 71 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 72, + 77 + ] + }, + { + "type": "PrivateIdentifier", + "value": "async", + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "range": [ + 78, + 84 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "range": [ + 84, + 85 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "range": [ + 85, + 86 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "range": [ + 86, + 87 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 4, + "column": 27 + } + }, + "range": [ + 87, + 88 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 93, + 99 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "range": [ + 100, + 105 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 17 + } + }, + "range": [ + 105, + 106 + ] + }, + { + "type": "PrivateIdentifier", + "value": "asyncGenerator", + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "range": [ + 107, + 122 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "range": [ + 122, + 123 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 5, + "column": 35 + } + }, + "range": [ + 123, + 124 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 36 + } + }, + "range": [ + 124, + 125 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 5, + "column": 36 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "range": [ + 125, + 126 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 127, + 128 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-private-methods.src.js b/tests/fixtures/ecma-version/13/static-class-features/valid-private-methods.src.js new file mode 100644 index 00000000..8cfe5f40 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-private-methods.src.js @@ -0,0 +1,6 @@ +class C { + static #method(){} + static * #generator(){} + static async #async(){} + static async* #asyncGenerator(){} +} diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-public-fields.result.js b/tests/fixtures/ecma-version/13/static-class-features/valid-public-fields.result.js new file mode 100644 index 00000000..9aebd4ce --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-public-fields.result.js @@ -0,0 +1,387 @@ +export default { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 47 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 47 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 8, + 47 + ], + "body": [ + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 14, + 25 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 21, + 24 + ], + "name": "aaa" + }, + "value": null + }, + { + "type": "PropertyDefinition", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [ + 30, + 45 + ], + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 37, + 40 + ], + "name": "bbb" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "range": [ + 43, + 44 + ], + "value": 0, + "raw": "0" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "C", + "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": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "range": [ + 14, + 20 + ] + }, + { + "type": "Identifier", + "value": "aaa", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 21, + 24 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 25 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "range": [ + 30, + 36 + ] + }, + { + "type": "Identifier", + "value": "bbb", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 37, + 40 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 41, + 42 + ] + }, + { + "type": "Numeric", + "value": "0", + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "range": [ + 43, + 44 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [ + 44, + 45 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 46, + 47 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/13/static-class-features/valid-public-fields.src.js b/tests/fixtures/ecma-version/13/static-class-features/valid-public-fields.src.js new file mode 100644 index 00000000..fd1cf0e1 --- /dev/null +++ b/tests/fixtures/ecma-version/13/static-class-features/valid-public-fields.src.js @@ -0,0 +1,4 @@ +class C { + static aaa; + static bbb = 0; +} diff --git a/tests/lib/supported-ecmaversions.js b/tests/lib/supported-ecmaversions.js index 8f66cf15..328e208b 100644 --- a/tests/lib/supported-ecmaversions.js +++ b/tests/lib/supported-ecmaversions.js @@ -17,7 +17,7 @@ import * as espree from "../../espree.js"; describe("latestEcmaVersion", () => { it("should return the latest supported ecmaVersion", () => { - assert.strictEqual(espree.latestEcmaVersion, 12); + assert.strictEqual(espree.latestEcmaVersion, 13); }); }); @@ -25,7 +25,7 @@ describe("supportedEcmaVersions", () => { it("should return an array of all supported versions", () => { assert.deepStrictEqual( espree.supportedEcmaVersions, - [3, 5, 6, 7, 8, 9, 10, 11, 12] + [3, 5, 6, 7, 8, 9, 10, 11, 12, 13] ); }); }); From 81bdee7d462dd9d8a0d7cd10b1f0db7855009b24 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Wed, 28 Apr 2021 13:09:17 +0900 Subject: [PATCH 02/11] update README.md --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0c445c02..33434bd5 100644 --- a/README.md +++ b/README.md @@ -140,8 +140,8 @@ const options = { // create a top-level tokens array containing all tokens tokens: false, - // Set to 3, 5 (default), 6, 7, 8, 9, 10, 11, or 12 to specify the version of ECMAScript syntax you want to use. - // You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), or 2021 (same as 12) to use the year-based naming. + // Set to 3, 5 (default), 6, 7, 8, 9, 10, 11, 12, or 13 to specify the version of ECMAScript syntax you want to use. + // You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), 2021 (same as 12), or 2022 (same as 13) to use the year-based naming. ecmaVersion: 5, // specify which type of script you're parsing ("script" or "module") @@ -228,12 +228,13 @@ We are building on top of Acorn, however, so that we can contribute back and hel ### What ECMAScript features do you support? -Espree supports all ECMAScript 2020 features and partially supports ECMAScript 2021 features. +Espree supports all ECMAScript 2021 features and partially supports ECMAScript 2022 features. -Because ECMAScript 2021 is still under development, we are implementing features as they are finalized. Currently, Espree supports: +Because ECMAScript 2022 is still under development, we are implementing features as they are finalized. Currently, Espree supports: -* [Logical Assignment Operators](https://github.com/tc39/proposal-logical-assignment) -* [Numeric Separators](https://github.com/tc39/proposal-numeric-separator) +* [Class instance fields](https://github.com/tc39/proposal-class-fields) +* [Class private instance methods and accessors](https://github.com/tc39/proposal-private-methods) +* [Class static fields, static private methods and accessors](https://github.com/tc39/proposal-static-class-features) See [finished-proposals.md](https://github.com/tc39/proposals/blob/master/finished-proposals.md) to know what features are finalized. From d7673b305d38dd76b118584df2f8020823baee35 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Wed, 28 Apr 2021 13:15:08 +0900 Subject: [PATCH 03/11] update tools and add docs for adding new syntax --- .eslintignore | 4 +- .eslintrc.cjs | 21 +++- CONTRIBUTING.md | 15 +++ tools/update-ecma-version-tests.js | 156 +++++++++++++++++++++++++++++ tools/update-tests.js | 19 ---- 5 files changed, 191 insertions(+), 24 deletions(-) create mode 100644 tools/update-ecma-version-tests.js diff --git a/.eslintignore b/.eslintignore index d14e0cdb..91e18159 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,5 @@ /node_modules /tests/fixtures -/tools +/tools/* +!/tools/update-ecma-version-tests.js +/dist diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 27ba0233..93fc39dc 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -4,17 +4,30 @@ module.exports = { root: true, extends: "eslint", env: { - es6: true + es2020: true + }, + parserOptions: { + ecmaVersion: 2020, + sourceType: "module" }, overrides: [ { - files: ["tests/lib/**"], + files: ["*.cjs"], parserOptions: { - ecmaVersion: 2020 - }, + sourceType: "script" + } + }, + { + files: ["tests/lib/**"], env: { mocha: true } + }, + { + files: ["tools/**"], + rules: { + "no-console": "off" + } } ] }; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b8e18be4..174e83ea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,3 +6,18 @@ Please sign the [jQuery Foundation Contributor License Agreement](https://contri Our full contribution guidelines can be found at: + +# How to update espree to support new syntax + +1. Update `acorn` package the upstream. +1. `npm install acorn@latest` +1. If a new `ecmaVersion` value is added, update `SUPPORTED_VERSIONS` constant in `lib/options.js` and tests in `tests\lib\supported-ecmaversions.js`. +1. If new token types are added, update `lib/token-translator.js` file to translate the tokens. +1. Add tests in `tests/fixtures/ecma-version//`. + - Add a directory named the new syntax name. + - Add `valid-.src.js` files for parseable codes. + - Add `invalid-.src.js` files for syntax error codes. + - Run `node tools/update-ecma-version-tests.js ` command to generate `.result.js` files. + - Check the `.result.js` files are expected results. +1. Update `README.md`. +1. Send a pull request. diff --git a/tools/update-ecma-version-tests.js b/tools/update-ecma-version-tests.js new file mode 100644 index 00000000..6ef96efd --- /dev/null +++ b/tools/update-ecma-version-tests.js @@ -0,0 +1,156 @@ +/** + * @fileoverview Generate `.result.js` from `.src.js` in + * `tests/fixtures/ecma-version//**` directory. + * @author Nicholas C. Zakas + * @author Toru Nagashima + * + * Usage: + * node tools/update-ecma-version-tests.js + * + */ + +//------------------------------------------------------------------------------ +// Imports +//------------------------------------------------------------------------------ + +import path from "path"; +import { fileURLToPath } from "url"; +import util from "util"; +import shelljs from "shelljs"; +import * as espree from "../espree.js"; +import tester from "../tests/lib/tester.js"; + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +/** + * Get the parse result. + * @param {string} code The source code to get. + * @param {Object} config The espree options. + * @returns {string} The parse result. + */ +function getExpectedResult(code, config) { + try { + return tester.getRaw(espree.parse(code, config)); + } catch (ex) { + const raw = tester.getRaw(ex); + + raw.message = ex.message; + return raw; + } +} + +/** + * Find the test cases from a given directory. + * Tests are the name of files that end with `.src.js`. + * @param {string} directory The root directory to find. + * @returns {string[]} The found test names. + */ +function findTests(directory) { + return shelljs.find(directory) + .filter(filename => filename.endsWith(".src.js")) + .map(filename => filename.slice(0, -".src.js".length)); // strip off ".src.js" +} + +/** + * Write the parse result to the result file (`.result.js`). + * @param {Object} result The parse result to write. + * @param {string} testResultFilename The path to the result file. + * @returns {void} + */ +function outputResult(result, testResultFilename) { + let code = `export default ${JSON.stringify(result, (key, value) => ((typeof value === "bigint") ? `bigint<${value}n>` : value), 4)};`; + + code = code.replace(/"bigint<(\d+n)>"/gu, "$1"); + + code.to(testResultFilename); +} + +/** + * Entry point. + * @returns {void} + */ +function main() { + const thisFilePath = fileURLToPath(import.meta.url); + const ecmaVersion = process.argv[2] ?? ""; + const rootDir = path.resolve(thisFilePath, "../../tests/fixtures/ecma-version", ecmaVersion); + + if (!ecmaVersion) { + console.error(); + console.error("Usage: node tools/update-ecma-version-tests.js "); + console.error(); + console.error(" ... The ECMA version to update tests."); + console.error(); + return; + } + if (!/^\d+$/u.test(ecmaVersion)) { + console.error("Error: The version number must be an positive integer."); + return; + } + if (!shelljs.test("-d", rootDir)) { + console.error("Error: %o is must be a directory.", rootDir); + return; + } + + for (const name of findTests(rootDir)) { + const scriptOnly = name.includes("not-strict") || name.includes("edge-cases"); + const moduleOnly = !scriptOnly && name.includes("modules"); + const expectedToBeError = name.includes("/invalid-"); + const expectedToBeOK = name.includes("/valid-"); + const sourceFilePath = `${path.resolve(rootDir, name)}.src.js`; + const resultFilePath = `${path.resolve(rootDir, name)}.result.js`; + const moduleResultFilePath = `${path.resolve(rootDir, name)}.module-result.js`; + const relSourceFilePath = path.relative(process.cwd(), sourceFilePath); + const code = shelljs.cat(sourceFilePath); + const parserOptions = { + loc: true, + range: true, + tokens: true, + ecmaVersion: Number(ecmaVersion) + }; + const scriptResult = moduleOnly + ? null + : getExpectedResult(code, { ...parserOptions, sourceType: "script" }); + const moduleResult = scriptOnly + ? null + : getExpectedResult(code, { ...parserOptions, sourceType: "module" }); + const resultsAreSame = util.isDeepStrictEqual( + { ...scriptResult, sourceType: null }, + { ...moduleResult, sourceType: null } + ); + + if (scriptOnly || moduleOnly || resultsAreSame) { + const result = scriptResult ?? moduleResult; + + if (expectedToBeError && typeof result.type === "string") { + console.warn("Warn: expected to be syntax error, but succeeded to parse: %o", relSourceFilePath); + } else if (expectedToBeOK && typeof result.type !== "string") { + console.warn("Warn: expected to succeed to parse, but thrown syntax error: %o", relSourceFilePath); + } + + outputResult(result, resultFilePath); + } else { + console.warn("Warn: got different results between script and module: %o", relSourceFilePath); + if (expectedToBeError && typeof scriptResult.type === "string") { + console.warn("Warn: expected to be syntax error, but succeeded to parse in script: %o", relSourceFilePath); + } else if (expectedToBeOK && typeof scriptResult.type !== "string") { + console.warn("Warn: expected to succeed to parse, but thrown syntax error in script: %o", relSourceFilePath); + } + if (expectedToBeError && typeof moduleResult.type === "string") { + console.warn("Warn: expected to be syntax error, but succeeded to parse in module: %o", relSourceFilePath); + } else if (expectedToBeOK && typeof moduleResult.type !== "string") { + console.warn("Warn: expected to succeed to parse, but thrown syntax error in module: %o", relSourceFilePath); + } + + outputResult(scriptResult, resultFilePath); + outputResult(moduleResult, moduleResultFilePath); + } + } +} + +//------------------------------------------------------------------------------ +// Setup +//------------------------------------------------------------------------------ + +main(); diff --git a/tools/update-tests.js b/tools/update-tests.js index 62e8a782..3d54ef6c 100644 --- a/tools/update-tests.js +++ b/tools/update-tests.js @@ -65,11 +65,9 @@ function outputResult(result, testResultFilename) { //------------------------------------------------------------------------------ var FIXTURES_DIR = "./tests/fixtures/ecma-features", - FIXTURES_VERSION_DIR = "./tests/fixtures/ecma-version", LIBRARIES_DIR = "./tests/fixtures/libraries"; var testFiles = getTestFilenames(FIXTURES_DIR), - versionFiles = getTestFilenames(FIXTURES_VERSION_DIR), libraryFiles = getLibraryFilenames(LIBRARIES_DIR); libraryFiles.forEach(function(filename) { @@ -103,20 +101,3 @@ testFiles.forEach(function(filename) { outputResult(result, testResultFilename); }); - -versionFiles.forEach(function(filename) { - - var version = Number(filename.substring(0, filename.indexOf("/"))), - code = shelljs.cat(path.resolve(FIXTURES_VERSION_DIR, filename) + ".src.js"), - config = { - loc: true, - range: true, - tokens: true, - ecmaVersion: version - }; - - var testResultFilename = path.resolve(__dirname, "..", FIXTURES_VERSION_DIR, filename) + ".result.js", - result = getExpectedResult(code, config); - - outputResult(result, testResultFilename); -}); From 3e9caa787c0d4945401f1abf093b03be9fb44c6c Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Wed, 28 Apr 2021 16:02:42 +0900 Subject: [PATCH 04/11] add dist --- .gitignore | 3 +- dist/espree.cjs | 946 ++++++++++++++++++++++++++++++++++++++++++++ dist/espree.cjs.map | 1 + 3 files changed, 948 insertions(+), 2 deletions(-) create mode 100644 dist/espree.cjs create mode 100644 dist/espree.cjs.map diff --git a/.gitignore b/.gitignore index 97375681..51dbd21e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,10 @@ build coverage node_modules .DS_Store -dist npm-debug.log _test.js .idea .nyc_output .eslint-release-info.json yarn.lock -package-lock.json \ No newline at end of file +package-lock.json diff --git a/dist/espree.cjs b/dist/espree.cjs new file mode 100644 index 00000000..6f15ca78 --- /dev/null +++ b/dist/espree.cjs @@ -0,0 +1,946 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var acorn = require('acorn'); +var jsx = require('acorn-jsx'); +var visitorKeys = require('eslint-visitor-keys'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { + return e[k]; + } + }); + } + }); + } + n['default'] = e; + return Object.freeze(n); +} + +var acorn__namespace = /*#__PURE__*/_interopNamespace(acorn); +var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx); +var visitorKeys__default = /*#__PURE__*/_interopDefaultLegacy(visitorKeys); + +/** + * @fileoverview The AST node types produced by the parser. + * @author Nicholas C. Zakas + */ + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// None! + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +var astNodeTypes = { + AssignmentExpression: "AssignmentExpression", + AssignmentPattern: "AssignmentPattern", + ArrayExpression: "ArrayExpression", + ArrayPattern: "ArrayPattern", + ArrowFunctionExpression: "ArrowFunctionExpression", + AwaitExpression: "AwaitExpression", + BlockStatement: "BlockStatement", + BinaryExpression: "BinaryExpression", + BreakStatement: "BreakStatement", + CallExpression: "CallExpression", + CatchClause: "CatchClause", + ClassBody: "ClassBody", + ClassDeclaration: "ClassDeclaration", + ClassExpression: "ClassExpression", + ConditionalExpression: "ConditionalExpression", + ContinueStatement: "ContinueStatement", + DoWhileStatement: "DoWhileStatement", + DebuggerStatement: "DebuggerStatement", + EmptyStatement: "EmptyStatement", + ExpressionStatement: "ExpressionStatement", + ForStatement: "ForStatement", + ForInStatement: "ForInStatement", + ForOfStatement: "ForOfStatement", + FunctionDeclaration: "FunctionDeclaration", + FunctionExpression: "FunctionExpression", + Identifier: "Identifier", + IfStatement: "IfStatement", + Literal: "Literal", + LabeledStatement: "LabeledStatement", + LogicalExpression: "LogicalExpression", + MemberExpression: "MemberExpression", + MetaProperty: "MetaProperty", + MethodDefinition: "MethodDefinition", + NewExpression: "NewExpression", + ObjectExpression: "ObjectExpression", + ObjectPattern: "ObjectPattern", + Program: "Program", + Property: "Property", + RestElement: "RestElement", + ReturnStatement: "ReturnStatement", + SequenceExpression: "SequenceExpression", + SpreadElement: "SpreadElement", + Super: "Super", + SwitchCase: "SwitchCase", + SwitchStatement: "SwitchStatement", + TaggedTemplateExpression: "TaggedTemplateExpression", + TemplateElement: "TemplateElement", + TemplateLiteral: "TemplateLiteral", + ThisExpression: "ThisExpression", + ThrowStatement: "ThrowStatement", + TryStatement: "TryStatement", + UnaryExpression: "UnaryExpression", + UpdateExpression: "UpdateExpression", + VariableDeclaration: "VariableDeclaration", + VariableDeclarator: "VariableDeclarator", + WhileStatement: "WhileStatement", + WithStatement: "WithStatement", + YieldExpression: "YieldExpression", + JSXIdentifier: "JSXIdentifier", + JSXNamespacedName: "JSXNamespacedName", + JSXMemberExpression: "JSXMemberExpression", + JSXEmptyExpression: "JSXEmptyExpression", + JSXExpressionContainer: "JSXExpressionContainer", + JSXElement: "JSXElement", + JSXClosingElement: "JSXClosingElement", + JSXOpeningElement: "JSXOpeningElement", + JSXAttribute: "JSXAttribute", + JSXSpreadAttribute: "JSXSpreadAttribute", + JSXText: "JSXText", + ExportDefaultDeclaration: "ExportDefaultDeclaration", + ExportNamedDeclaration: "ExportNamedDeclaration", + ExportAllDeclaration: "ExportAllDeclaration", + ExportSpecifier: "ExportSpecifier", + ImportDeclaration: "ImportDeclaration", + ImportSpecifier: "ImportSpecifier", + ImportDefaultSpecifier: "ImportDefaultSpecifier", + ImportNamespaceSpecifier: "ImportNamespaceSpecifier" +}; + +/** + * @fileoverview Translates tokens between Acorn format and Esprima format. + * @author Nicholas C. Zakas + */ +/* eslint no-underscore-dangle: 0 */ + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// none! + +//------------------------------------------------------------------------------ +// Private +//------------------------------------------------------------------------------ + + +// Esprima Token Types +const Token = { + Boolean: "Boolean", + EOF: "", + Identifier: "Identifier", + PrivateIdentifier: "PrivateIdentifier", + Keyword: "Keyword", + Null: "Null", + Numeric: "Numeric", + Punctuator: "Punctuator", + String: "String", + RegularExpression: "RegularExpression", + Template: "Template", + JSXIdentifier: "JSXIdentifier", + JSXText: "JSXText" +}; + +/** + * Converts part of a template into an Esprima token. + * @param {AcornToken[]} tokens The Acorn tokens representing the template. + * @param {string} code The source code. + * @returns {EsprimaToken} The Esprima equivalent of the template token. + * @private + */ +function convertTemplatePart(tokens, code) { + const firstToken = tokens[0], + lastTemplateToken = tokens[tokens.length - 1]; + + const token = { + type: Token.Template, + value: code.slice(firstToken.start, lastTemplateToken.end) + }; + + if (firstToken.loc) { + token.loc = { + start: firstToken.loc.start, + end: lastTemplateToken.loc.end + }; + } + + if (firstToken.range) { + token.start = firstToken.range[0]; + token.end = lastTemplateToken.range[1]; + token.range = [token.start, token.end]; + } + + return token; +} + +/** + * Contains logic to translate Acorn tokens into Esprima tokens. + * @param {Object} acornTokTypes The Acorn token types. + * @param {string} code The source code Acorn is parsing. This is necessary + * to correct the "value" property of some tokens. + * @constructor + */ +function TokenTranslator(acornTokTypes, code) { + + // token types + this._acornTokTypes = acornTokTypes; + + // token buffer for templates + this._tokens = []; + + // track the last curly brace + this._curlyBrace = null; + + // the source code + this._code = code; + +} + +TokenTranslator.prototype = { + constructor: TokenTranslator, + + /** + * Translates a single Esprima token to a single Acorn token. This may be + * inaccurate due to how templates are handled differently in Esprima and + * Acorn, but should be accurate for all other tokens. + * @param {AcornToken} token The Acorn token to translate. + * @param {Object} extra Espree extra object. + * @returns {EsprimaToken} The Esprima version of the token. + */ + translate(token, extra) { + + const type = token.type, + tt = this._acornTokTypes; + + if (type === tt.name) { + token.type = Token.Identifier; + + // TODO: See if this is an Acorn bug + if (token.value === "static") { + token.type = Token.Keyword; + } + + if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) { + token.type = Token.Keyword; + } + + } else if (type === tt.privateId) { + token.type = Token.PrivateIdentifier; + + } else if (type === tt.semi || type === tt.comma || + type === tt.parenL || type === tt.parenR || + type === tt.braceL || type === tt.braceR || + type === tt.dot || type === tt.bracketL || + type === tt.colon || type === tt.question || + type === tt.bracketR || type === tt.ellipsis || + type === tt.arrow || type === tt.jsxTagStart || + type === tt.incDec || type === tt.starstar || + type === tt.jsxTagEnd || type === tt.prefix || + type === tt.questionDot || + (type.binop && !type.keyword) || + type.isAssign) { + + token.type = Token.Punctuator; + token.value = this._code.slice(token.start, token.end); + } else if (type === tt.jsxName) { + token.type = Token.JSXIdentifier; + } else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) { + token.type = Token.JSXText; + } else if (type.keyword) { + if (type.keyword === "true" || type.keyword === "false") { + token.type = Token.Boolean; + } else if (type.keyword === "null") { + token.type = Token.Null; + } else { + token.type = Token.Keyword; + } + } else if (type === tt.num) { + token.type = Token.Numeric; + token.value = this._code.slice(token.start, token.end); + } else if (type === tt.string) { + + if (extra.jsxAttrValueToken) { + extra.jsxAttrValueToken = false; + token.type = Token.JSXText; + } else { + token.type = Token.String; + } + + token.value = this._code.slice(token.start, token.end); + } else if (type === tt.regexp) { + token.type = Token.RegularExpression; + const value = token.value; + + token.regex = { + flags: value.flags, + pattern: value.pattern + }; + token.value = `/${value.pattern}/${value.flags}`; + } + + return token; + }, + + /** + * Function to call during Acorn's onToken handler. + * @param {AcornToken} token The Acorn token. + * @param {Object} extra The Espree extra object. + * @returns {void} + */ + onToken(token, extra) { + + const that = this, + tt = this._acornTokTypes, + tokens = extra.tokens, + templateTokens = this._tokens; + + /** + * Flushes the buffered template tokens and resets the template + * tracking. + * @returns {void} + * @private + */ + function translateTemplateTokens() { + tokens.push(convertTemplatePart(that._tokens, that._code)); + that._tokens = []; + } + + if (token.type === tt.eof) { + + // might be one last curlyBrace + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + } + + return; + } + + if (token.type === tt.backQuote) { + + // if there's already a curly, it's not part of the template + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + this._curlyBrace = null; + } + + templateTokens.push(token); + + // it's the end + if (templateTokens.length > 1) { + translateTemplateTokens(); + } + + return; + } + if (token.type === tt.dollarBraceL) { + templateTokens.push(token); + translateTemplateTokens(); + return; + } + if (token.type === tt.braceR) { + + // if there's already a curly, it's not part of the template + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + } + + // store new curly for later + this._curlyBrace = token; + return; + } + if (token.type === tt.template || token.type === tt.invalidTemplate) { + if (this._curlyBrace) { + templateTokens.push(this._curlyBrace); + this._curlyBrace = null; + } + + templateTokens.push(token); + return; + } + + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + this._curlyBrace = null; + } + + tokens.push(this.translate(token, extra)); + } +}; + +/** + * @fileoverview A collection of methods for processing Espree's options. + * @author Kai Cataldo + */ + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +const DEFAULT_ECMA_VERSION = 5; +const SUPPORTED_VERSIONS = [ + 3, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 +]; + +/** + * Normalize ECMAScript version from the initial config + * @param {number} ecmaVersion ECMAScript version from the initial config + * @throws {Error} throws an error if the ecmaVersion is invalid. + * @returns {number} normalized ECMAScript version + */ +function normalizeEcmaVersion(ecmaVersion = DEFAULT_ECMA_VERSION) { + if (typeof ecmaVersion !== "number") { + throw new Error(`ecmaVersion must be a number. Received value of type ${typeof ecmaVersion} instead.`); + } + + let version = ecmaVersion; + + // Calculate ECMAScript edition number from official year version starting with + // ES2015, which corresponds with ES6 (or a difference of 2009). + if (version >= 2015) { + version -= 2009; + } + + if (!SUPPORTED_VERSIONS.includes(version)) { + throw new Error("Invalid ecmaVersion."); + } + + return version; +} + +/** + * Normalize sourceType from the initial config + * @param {string} sourceType to normalize + * @throws {Error} throw an error if sourceType is invalid + * @returns {string} normalized sourceType + */ +function normalizeSourceType(sourceType = "script") { + if (sourceType === "script" || sourceType === "module") { + return sourceType; + } + throw new Error("Invalid sourceType."); +} + +/** + * Normalize parserOptions + * @param {Object} options the parser options to normalize + * @throws {Error} throw an error if found invalid option. + * @returns {Object} normalized options + */ +function normalizeOptions(options) { + const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion); + const sourceType = normalizeSourceType(options.sourceType); + const ranges = options.range === true; + const locations = options.loc === true; + + if (sourceType === "module" && ecmaVersion < 6) { + throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options."); + } + return Object.assign({}, options, { ecmaVersion, sourceType, ranges, locations }); +} + +/** + * Get the latest ECMAScript version supported by Espree. + * @returns {number} The latest ECMAScript version. + */ +function getLatestEcmaVersion() { + return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1]; +} + +/** + * Get the list of ECMAScript versions supported by Espree. + * @returns {number[]} An array containing the supported ECMAScript versions. + */ +function getSupportedEcmaVersions() { + return [...SUPPORTED_VERSIONS]; +} + +/* eslint-disable no-param-reassign*/ + + +const STATE = Symbol("espree's internal state"); +const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode"); + + +/** + * Converts an Acorn comment to a Esprima comment. + * @param {boolean} block True if it's a block comment, false if not. + * @param {string} text The text of the comment. + * @param {int} start The index at which the comment starts. + * @param {int} end The index at which the comment ends. + * @param {Location} startLoc The location at which the comment starts. + * @param {Location} endLoc The location at which the comment ends. + * @returns {Object} The comment object. + * @private + */ +function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) { + const comment = { + type: block ? "Block" : "Line", + value: text + }; + + if (typeof start === "number") { + comment.start = start; + comment.end = end; + comment.range = [start, end]; + } + + if (typeof startLoc === "object") { + comment.loc = { + start: startLoc, + end: endLoc + }; + } + + return comment; +} + +var espree = () => Parser => { + const tokTypes = Object.assign({}, Parser.acorn.tokTypes); + + if (Parser.acornJsx) { + Object.assign(tokTypes, Parser.acornJsx.tokTypes); + } + + return class Espree extends Parser { + constructor(opts, code) { + if (typeof opts !== "object" || opts === null) { + opts = {}; + } + if (typeof code !== "string" && !(code instanceof String)) { + code = String(code); + } + + const options = normalizeOptions(opts); + const ecmaFeatures = options.ecmaFeatures || {}; + const tokenTranslator = + options.tokens === true + ? new TokenTranslator(tokTypes, code) + : null; + + // Initialize acorn parser. + super({ + + // TODO: use {...options} when spread is supported(Node.js >= 8.3.0). + ecmaVersion: options.ecmaVersion, + sourceType: options.sourceType, + ranges: options.ranges, + locations: options.locations, + + // Truthy value is true for backward compatibility. + allowReturnOutsideFunction: Boolean(ecmaFeatures.globalReturn), + + // Collect tokens + onToken: token => { + if (tokenTranslator) { + + // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state. + tokenTranslator.onToken(token, this[STATE]); + } + if (token.type !== tokTypes.eof) { + this[STATE].lastToken = token; + } + }, + + // Collect comments + onComment: (block, text, start, end, startLoc, endLoc) => { + if (this[STATE].comments) { + const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc); + + this[STATE].comments.push(comment); + } + } + }, code); + + // Initialize internal state. + this[STATE] = { + tokens: tokenTranslator ? [] : null, + comments: options.comment === true ? [] : null, + impliedStrict: ecmaFeatures.impliedStrict === true && this.options.ecmaVersion >= 5, + ecmaVersion: this.options.ecmaVersion, + jsxAttrValueToken: false, + lastToken: null + }; + } + + tokenize() { + do { + this.next(); + } while (this.type !== tokTypes.eof); + + // Consume the final eof token + this.next(); + + const extra = this[STATE]; + const tokens = extra.tokens; + + if (extra.comments) { + tokens.comments = extra.comments; + } + + return tokens; + } + + finishNode(...args) { + const result = super.finishNode(...args); + + return this[ESPRIMA_FINISH_NODE](result); + } + + finishNodeAt(...args) { + const result = super.finishNodeAt(...args); + + return this[ESPRIMA_FINISH_NODE](result); + } + + parse() { + const extra = this[STATE]; + const program = super.parse(); + + program.sourceType = this.options.sourceType; + + if (extra.comments) { + program.comments = extra.comments; + } + if (extra.tokens) { + program.tokens = extra.tokens; + } + + /* + * Adjust opening and closing position of program to match Esprima. + * Acorn always starts programs at range 0 whereas Esprima starts at the + * first AST node's start (the only real difference is when there's leading + * whitespace or leading comments). Acorn also counts trailing whitespace + * as part of the program whereas Esprima only counts up to the last token. + */ + if (program.range) { + program.range[0] = program.body.length ? program.body[0].range[0] : program.range[0]; + program.range[1] = extra.lastToken ? extra.lastToken.range[1] : program.range[1]; + } + if (program.loc) { + program.loc.start = program.body.length ? program.body[0].loc.start : program.loc.start; + program.loc.end = extra.lastToken ? extra.lastToken.loc.end : program.loc.end; + } + + return program; + } + + parseTopLevel(node) { + if (this[STATE].impliedStrict) { + this.strict = true; + } + return super.parseTopLevel(node); + } + + /** + * Overwrites the default raise method to throw Esprima-style errors. + * @param {int} pos The position of the error. + * @param {string} message The error message. + * @throws {SyntaxError} A syntax error. + * @returns {void} + */ + raise(pos, message) { + const loc = Parser.acorn.getLineInfo(this.input, pos); + const err = new SyntaxError(message); + + err.index = pos; + err.lineNumber = loc.line; + err.column = loc.column + 1; // acorn uses 0-based columns + throw err; + } + + /** + * Overwrites the default raise method to throw Esprima-style errors. + * @param {int} pos The position of the error. + * @param {string} message The error message. + * @throws {SyntaxError} A syntax error. + * @returns {void} + */ + raiseRecoverable(pos, message) { + this.raise(pos, message); + } + + /** + * Overwrites the default unexpected method to throw Esprima-style errors. + * @param {int} pos The position of the error. + * @throws {SyntaxError} A syntax error. + * @returns {void} + */ + unexpected(pos) { + let message = "Unexpected token"; + + if (pos !== null && pos !== void 0) { + this.pos = pos; + + if (this.options.locations) { + while (this.pos < this.lineStart) { + this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1; + --this.curLine; + } + } + + this.nextToken(); + } + + if (this.end > this.start) { + message += ` ${this.input.slice(this.start, this.end)}`; + } + + this.raise(this.start, message); + } + + /* + * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX + * uses regular tt.string without any distinction between this and regular JS + * strings. As such, we intercept an attempt to read a JSX string and set a flag + * on extra so that when tokens are converted, the next token will be switched + * to JSXText via onToken. + */ + jsx_readString(quote) { // eslint-disable-line camelcase + const result = super.jsx_readString(quote); + + if (this.type === tokTypes.string) { + this[STATE].jsxAttrValueToken = true; + } + return result; + } + + /** + * Performs last-minute Esprima-specific compatibility checks and fixes. + * @param {ASTNode} result The node to check. + * @returns {ASTNode} The finished node. + */ + [ESPRIMA_FINISH_NODE](result) { + + // Acorn doesn't count the opening and closing backticks as part of templates + // so we have to adjust ranges/locations appropriately. + if (result.type === "TemplateElement") { + + // additional adjustment needed if ${ is the last token + const terminalDollarBraceL = this.input.slice(result.end, result.end + 2) === "${"; + + if (result.range) { + result.range[0]--; + result.range[1] += (terminalDollarBraceL ? 2 : 1); + } + + if (result.loc) { + result.loc.start.column--; + result.loc.end.column += (terminalDollarBraceL ? 2 : 1); + } + } + + if (result.type.includes("Function") && !result.generator) { + result.generator = false; + } + + return result; + } + }; +}; + +const version$1 = "main"; + +/** + * @fileoverview Main Espree file that converts Acorn into Esprima output. + * + * This file contains code from the following MIT-licensed projects: + * 1. Acorn + * 2. Babylon + * 3. Babel-ESLint + * + * This file also contains code from Esprima, which is BSD licensed. + * + * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS) + * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS) + * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +// To initialize lazily. +const parsers = { + _regular: null, + _jsx: null, + + get regular() { + if (this._regular === null) { + this._regular = acorn__namespace.Parser.extend(espree()); + } + return this._regular; + }, + + get jsx() { + if (this._jsx === null) { + this._jsx = acorn__namespace.Parser.extend(jsx__default['default'](), espree()); + } + return this._jsx; + }, + + get(options) { + const useJsx = Boolean( + options && + options.ecmaFeatures && + options.ecmaFeatures.jsx + ); + + return useJsx ? this.jsx : this.regular; + } +}; + +//------------------------------------------------------------------------------ +// Tokenizer +//------------------------------------------------------------------------------ + +/** + * Tokenizes the given code. + * @param {string} code The code to tokenize. + * @param {Object} options Options defining how to tokenize. + * @returns {Token[]} An array of tokens. + * @throws {SyntaxError} If the input code is invalid. + * @private + */ +function tokenize(code, options) { + const Parser = parsers.get(options); + + // Ensure to collect tokens. + if (!options || options.tokens !== true) { + options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign + } + + return new Parser(options, code).tokenize(); +} + +//------------------------------------------------------------------------------ +// Parser +//------------------------------------------------------------------------------ + +/** + * Parses the given code. + * @param {string} code The code to tokenize. + * @param {Object} options Options defining how to tokenize. + * @returns {ASTNode} The "Program" AST node. + * @throws {SyntaxError} If the input code is invalid. + */ +function parse(code, options) { + const Parser = parsers.get(options); + + return new Parser(options, code).parse(); +} + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +const version = version$1; + + +// Deep copy. +/* istanbul ignore next */ +const Syntax = (function() { + let name, + types = {}; + + if (typeof Object.create === "function") { + types = Object.create(null); + } + + for (name in astNodeTypes) { + if (Object.hasOwnProperty.call(astNodeTypes, name)) { + types[name] = astNodeTypes[name]; + } + } + + if (typeof Object.freeze === "function") { + Object.freeze(types); + } + + return types; +}()); + +/* istanbul ignore next */ +const VisitorKeys = (function() { + return visitorKeys__default['default'].KEYS; +}()); + +const latestEcmaVersion = getLatestEcmaVersion(); + +const supportedEcmaVersions = getSupportedEcmaVersions(); + +exports.Syntax = Syntax; +exports.VisitorKeys = VisitorKeys; +exports.latestEcmaVersion = latestEcmaVersion; +exports.parse = parse; +exports.supportedEcmaVersions = supportedEcmaVersions; +exports.tokenize = tokenize; +exports.version = version; +//# sourceMappingURL=espree.cjs.map diff --git a/dist/espree.cjs.map b/dist/espree.cjs.map new file mode 100644 index 00000000..3c25eb09 --- /dev/null +++ b/dist/espree.cjs.map @@ -0,0 +1 @@ +{"version":3,"file":"espree.cjs","sources":["../lib/ast-node-types.js","../lib/token-translator.js","../lib/options.js","../lib/espree.js","../lib/version.js","../espree.js"],"sourcesContent":["/**\n * @fileoverview The AST node types produced by the parser.\n * @author Nicholas C. Zakas\n */\n\n//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\n// None!\n\n//------------------------------------------------------------------------------\n// Public\n//------------------------------------------------------------------------------\n\nexport default {\n AssignmentExpression: \"AssignmentExpression\",\n AssignmentPattern: \"AssignmentPattern\",\n ArrayExpression: \"ArrayExpression\",\n ArrayPattern: \"ArrayPattern\",\n ArrowFunctionExpression: \"ArrowFunctionExpression\",\n AwaitExpression: \"AwaitExpression\",\n BlockStatement: \"BlockStatement\",\n BinaryExpression: \"BinaryExpression\",\n BreakStatement: \"BreakStatement\",\n CallExpression: \"CallExpression\",\n CatchClause: \"CatchClause\",\n ClassBody: \"ClassBody\",\n ClassDeclaration: \"ClassDeclaration\",\n ClassExpression: \"ClassExpression\",\n ConditionalExpression: \"ConditionalExpression\",\n ContinueStatement: \"ContinueStatement\",\n DoWhileStatement: \"DoWhileStatement\",\n DebuggerStatement: \"DebuggerStatement\",\n EmptyStatement: \"EmptyStatement\",\n ExpressionStatement: \"ExpressionStatement\",\n ForStatement: \"ForStatement\",\n ForInStatement: \"ForInStatement\",\n ForOfStatement: \"ForOfStatement\",\n FunctionDeclaration: \"FunctionDeclaration\",\n FunctionExpression: \"FunctionExpression\",\n Identifier: \"Identifier\",\n IfStatement: \"IfStatement\",\n Literal: \"Literal\",\n LabeledStatement: \"LabeledStatement\",\n LogicalExpression: \"LogicalExpression\",\n MemberExpression: \"MemberExpression\",\n MetaProperty: \"MetaProperty\",\n MethodDefinition: \"MethodDefinition\",\n NewExpression: \"NewExpression\",\n ObjectExpression: \"ObjectExpression\",\n ObjectPattern: \"ObjectPattern\",\n Program: \"Program\",\n Property: \"Property\",\n RestElement: \"RestElement\",\n ReturnStatement: \"ReturnStatement\",\n SequenceExpression: \"SequenceExpression\",\n SpreadElement: \"SpreadElement\",\n Super: \"Super\",\n SwitchCase: \"SwitchCase\",\n SwitchStatement: \"SwitchStatement\",\n TaggedTemplateExpression: \"TaggedTemplateExpression\",\n TemplateElement: \"TemplateElement\",\n TemplateLiteral: \"TemplateLiteral\",\n ThisExpression: \"ThisExpression\",\n ThrowStatement: \"ThrowStatement\",\n TryStatement: \"TryStatement\",\n UnaryExpression: \"UnaryExpression\",\n UpdateExpression: \"UpdateExpression\",\n VariableDeclaration: \"VariableDeclaration\",\n VariableDeclarator: \"VariableDeclarator\",\n WhileStatement: \"WhileStatement\",\n WithStatement: \"WithStatement\",\n YieldExpression: \"YieldExpression\",\n JSXIdentifier: \"JSXIdentifier\",\n JSXNamespacedName: \"JSXNamespacedName\",\n JSXMemberExpression: \"JSXMemberExpression\",\n JSXEmptyExpression: \"JSXEmptyExpression\",\n JSXExpressionContainer: \"JSXExpressionContainer\",\n JSXElement: \"JSXElement\",\n JSXClosingElement: \"JSXClosingElement\",\n JSXOpeningElement: \"JSXOpeningElement\",\n JSXAttribute: \"JSXAttribute\",\n JSXSpreadAttribute: \"JSXSpreadAttribute\",\n JSXText: \"JSXText\",\n ExportDefaultDeclaration: \"ExportDefaultDeclaration\",\n ExportNamedDeclaration: \"ExportNamedDeclaration\",\n ExportAllDeclaration: \"ExportAllDeclaration\",\n ExportSpecifier: \"ExportSpecifier\",\n ImportDeclaration: \"ImportDeclaration\",\n ImportSpecifier: \"ImportSpecifier\",\n ImportDefaultSpecifier: \"ImportDefaultSpecifier\",\n ImportNamespaceSpecifier: \"ImportNamespaceSpecifier\"\n};\n","/**\n * @fileoverview Translates tokens between Acorn format and Esprima format.\n * @author Nicholas C. Zakas\n */\n/* eslint no-underscore-dangle: 0 */\n\n//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\n// none!\n\n//------------------------------------------------------------------------------\n// Private\n//------------------------------------------------------------------------------\n\n\n// Esprima Token Types\nconst Token = {\n Boolean: \"Boolean\",\n EOF: \"\",\n Identifier: \"Identifier\",\n PrivateIdentifier: \"PrivateIdentifier\",\n Keyword: \"Keyword\",\n Null: \"Null\",\n Numeric: \"Numeric\",\n Punctuator: \"Punctuator\",\n String: \"String\",\n RegularExpression: \"RegularExpression\",\n Template: \"Template\",\n JSXIdentifier: \"JSXIdentifier\",\n JSXText: \"JSXText\"\n};\n\n/**\n * Converts part of a template into an Esprima token.\n * @param {AcornToken[]} tokens The Acorn tokens representing the template.\n * @param {string} code The source code.\n * @returns {EsprimaToken} The Esprima equivalent of the template token.\n * @private\n */\nfunction convertTemplatePart(tokens, code) {\n const firstToken = tokens[0],\n lastTemplateToken = tokens[tokens.length - 1];\n\n const token = {\n type: Token.Template,\n value: code.slice(firstToken.start, lastTemplateToken.end)\n };\n\n if (firstToken.loc) {\n token.loc = {\n start: firstToken.loc.start,\n end: lastTemplateToken.loc.end\n };\n }\n\n if (firstToken.range) {\n token.start = firstToken.range[0];\n token.end = lastTemplateToken.range[1];\n token.range = [token.start, token.end];\n }\n\n return token;\n}\n\n/**\n * Contains logic to translate Acorn tokens into Esprima tokens.\n * @param {Object} acornTokTypes The Acorn token types.\n * @param {string} code The source code Acorn is parsing. This is necessary\n * to correct the \"value\" property of some tokens.\n * @constructor\n */\nfunction TokenTranslator(acornTokTypes, code) {\n\n // token types\n this._acornTokTypes = acornTokTypes;\n\n // token buffer for templates\n this._tokens = [];\n\n // track the last curly brace\n this._curlyBrace = null;\n\n // the source code\n this._code = code;\n\n}\n\nTokenTranslator.prototype = {\n constructor: TokenTranslator,\n\n /**\n * Translates a single Esprima token to a single Acorn token. This may be\n * inaccurate due to how templates are handled differently in Esprima and\n * Acorn, but should be accurate for all other tokens.\n * @param {AcornToken} token The Acorn token to translate.\n * @param {Object} extra Espree extra object.\n * @returns {EsprimaToken} The Esprima version of the token.\n */\n translate(token, extra) {\n\n const type = token.type,\n tt = this._acornTokTypes;\n\n if (type === tt.name) {\n token.type = Token.Identifier;\n\n // TODO: See if this is an Acorn bug\n if (token.value === \"static\") {\n token.type = Token.Keyword;\n }\n\n if (extra.ecmaVersion > 5 && (token.value === \"yield\" || token.value === \"let\")) {\n token.type = Token.Keyword;\n }\n\n } else if (type === tt.privateId) {\n token.type = Token.PrivateIdentifier;\n\n } else if (type === tt.semi || type === tt.comma ||\n type === tt.parenL || type === tt.parenR ||\n type === tt.braceL || type === tt.braceR ||\n type === tt.dot || type === tt.bracketL ||\n type === tt.colon || type === tt.question ||\n type === tt.bracketR || type === tt.ellipsis ||\n type === tt.arrow || type === tt.jsxTagStart ||\n type === tt.incDec || type === tt.starstar ||\n type === tt.jsxTagEnd || type === tt.prefix ||\n type === tt.questionDot ||\n (type.binop && !type.keyword) ||\n type.isAssign) {\n\n token.type = Token.Punctuator;\n token.value = this._code.slice(token.start, token.end);\n } else if (type === tt.jsxName) {\n token.type = Token.JSXIdentifier;\n } else if (type.label === \"jsxText\" || type === tt.jsxAttrValueToken) {\n token.type = Token.JSXText;\n } else if (type.keyword) {\n if (type.keyword === \"true\" || type.keyword === \"false\") {\n token.type = Token.Boolean;\n } else if (type.keyword === \"null\") {\n token.type = Token.Null;\n } else {\n token.type = Token.Keyword;\n }\n } else if (type === tt.num) {\n token.type = Token.Numeric;\n token.value = this._code.slice(token.start, token.end);\n } else if (type === tt.string) {\n\n if (extra.jsxAttrValueToken) {\n extra.jsxAttrValueToken = false;\n token.type = Token.JSXText;\n } else {\n token.type = Token.String;\n }\n\n token.value = this._code.slice(token.start, token.end);\n } else if (type === tt.regexp) {\n token.type = Token.RegularExpression;\n const value = token.value;\n\n token.regex = {\n flags: value.flags,\n pattern: value.pattern\n };\n token.value = `/${value.pattern}/${value.flags}`;\n }\n\n return token;\n },\n\n /**\n * Function to call during Acorn's onToken handler.\n * @param {AcornToken} token The Acorn token.\n * @param {Object} extra The Espree extra object.\n * @returns {void}\n */\n onToken(token, extra) {\n\n const that = this,\n tt = this._acornTokTypes,\n tokens = extra.tokens,\n templateTokens = this._tokens;\n\n /**\n * Flushes the buffered template tokens and resets the template\n * tracking.\n * @returns {void}\n * @private\n */\n function translateTemplateTokens() {\n tokens.push(convertTemplatePart(that._tokens, that._code));\n that._tokens = [];\n }\n\n if (token.type === tt.eof) {\n\n // might be one last curlyBrace\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n }\n\n return;\n }\n\n if (token.type === tt.backQuote) {\n\n // if there's already a curly, it's not part of the template\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n this._curlyBrace = null;\n }\n\n templateTokens.push(token);\n\n // it's the end\n if (templateTokens.length > 1) {\n translateTemplateTokens();\n }\n\n return;\n }\n if (token.type === tt.dollarBraceL) {\n templateTokens.push(token);\n translateTemplateTokens();\n return;\n }\n if (token.type === tt.braceR) {\n\n // if there's already a curly, it's not part of the template\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n }\n\n // store new curly for later\n this._curlyBrace = token;\n return;\n }\n if (token.type === tt.template || token.type === tt.invalidTemplate) {\n if (this._curlyBrace) {\n templateTokens.push(this._curlyBrace);\n this._curlyBrace = null;\n }\n\n templateTokens.push(token);\n return;\n }\n\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n this._curlyBrace = null;\n }\n\n tokens.push(this.translate(token, extra));\n }\n};\n\n//------------------------------------------------------------------------------\n// Public\n//------------------------------------------------------------------------------\n\nexport default TokenTranslator;\n","/**\n * @fileoverview A collection of methods for processing Espree's options.\n * @author Kai Cataldo\n */\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\nconst DEFAULT_ECMA_VERSION = 5;\nconst SUPPORTED_VERSIONS = [\n 3,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13\n];\n\n/**\n * Normalize ECMAScript version from the initial config\n * @param {number} ecmaVersion ECMAScript version from the initial config\n * @throws {Error} throws an error if the ecmaVersion is invalid.\n * @returns {number} normalized ECMAScript version\n */\nfunction normalizeEcmaVersion(ecmaVersion = DEFAULT_ECMA_VERSION) {\n if (typeof ecmaVersion !== \"number\") {\n throw new Error(`ecmaVersion must be a number. Received value of type ${typeof ecmaVersion} instead.`);\n }\n\n let version = ecmaVersion;\n\n // Calculate ECMAScript edition number from official year version starting with\n // ES2015, which corresponds with ES6 (or a difference of 2009).\n if (version >= 2015) {\n version -= 2009;\n }\n\n if (!SUPPORTED_VERSIONS.includes(version)) {\n throw new Error(\"Invalid ecmaVersion.\");\n }\n\n return version;\n}\n\n/**\n * Normalize sourceType from the initial config\n * @param {string} sourceType to normalize\n * @throws {Error} throw an error if sourceType is invalid\n * @returns {string} normalized sourceType\n */\nfunction normalizeSourceType(sourceType = \"script\") {\n if (sourceType === \"script\" || sourceType === \"module\") {\n return sourceType;\n }\n throw new Error(\"Invalid sourceType.\");\n}\n\n/**\n * Normalize parserOptions\n * @param {Object} options the parser options to normalize\n * @throws {Error} throw an error if found invalid option.\n * @returns {Object} normalized options\n */\nexport function normalizeOptions(options) {\n const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);\n const sourceType = normalizeSourceType(options.sourceType);\n const ranges = options.range === true;\n const locations = options.loc === true;\n\n if (sourceType === \"module\" && ecmaVersion < 6) {\n throw new Error(\"sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.\");\n }\n return Object.assign({}, options, { ecmaVersion, sourceType, ranges, locations });\n}\n\n/**\n * Get the latest ECMAScript version supported by Espree.\n * @returns {number} The latest ECMAScript version.\n */\nexport function getLatestEcmaVersion() {\n return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1];\n}\n\n/**\n * Get the list of ECMAScript versions supported by Espree.\n * @returns {number[]} An array containing the supported ECMAScript versions.\n */\nexport function getSupportedEcmaVersions() {\n return [...SUPPORTED_VERSIONS];\n}\n","/* eslint-disable no-param-reassign*/\nimport TokenTranslator from \"./token-translator.js\";\nimport { normalizeOptions } from \"./options.js\";\n\n\nconst STATE = Symbol(\"espree's internal state\");\nconst ESPRIMA_FINISH_NODE = Symbol(\"espree's esprimaFinishNode\");\n\n\n/**\n * Converts an Acorn comment to a Esprima comment.\n * @param {boolean} block True if it's a block comment, false if not.\n * @param {string} text The text of the comment.\n * @param {int} start The index at which the comment starts.\n * @param {int} end The index at which the comment ends.\n * @param {Location} startLoc The location at which the comment starts.\n * @param {Location} endLoc The location at which the comment ends.\n * @returns {Object} The comment object.\n * @private\n */\nfunction convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) {\n const comment = {\n type: block ? \"Block\" : \"Line\",\n value: text\n };\n\n if (typeof start === \"number\") {\n comment.start = start;\n comment.end = end;\n comment.range = [start, end];\n }\n\n if (typeof startLoc === \"object\") {\n comment.loc = {\n start: startLoc,\n end: endLoc\n };\n }\n\n return comment;\n}\n\nexport default () => Parser => {\n const tokTypes = Object.assign({}, Parser.acorn.tokTypes);\n\n if (Parser.acornJsx) {\n Object.assign(tokTypes, Parser.acornJsx.tokTypes);\n }\n\n return class Espree extends Parser {\n constructor(opts, code) {\n if (typeof opts !== \"object\" || opts === null) {\n opts = {};\n }\n if (typeof code !== \"string\" && !(code instanceof String)) {\n code = String(code);\n }\n\n const options = normalizeOptions(opts);\n const ecmaFeatures = options.ecmaFeatures || {};\n const tokenTranslator =\n options.tokens === true\n ? new TokenTranslator(tokTypes, code)\n : null;\n\n // Initialize acorn parser.\n super({\n\n // TODO: use {...options} when spread is supported(Node.js >= 8.3.0).\n ecmaVersion: options.ecmaVersion,\n sourceType: options.sourceType,\n ranges: options.ranges,\n locations: options.locations,\n\n // Truthy value is true for backward compatibility.\n allowReturnOutsideFunction: Boolean(ecmaFeatures.globalReturn),\n\n // Collect tokens\n onToken: token => {\n if (tokenTranslator) {\n\n // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.\n tokenTranslator.onToken(token, this[STATE]);\n }\n if (token.type !== tokTypes.eof) {\n this[STATE].lastToken = token;\n }\n },\n\n // Collect comments\n onComment: (block, text, start, end, startLoc, endLoc) => {\n if (this[STATE].comments) {\n const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc);\n\n this[STATE].comments.push(comment);\n }\n }\n }, code);\n\n // Initialize internal state.\n this[STATE] = {\n tokens: tokenTranslator ? [] : null,\n comments: options.comment === true ? [] : null,\n impliedStrict: ecmaFeatures.impliedStrict === true && this.options.ecmaVersion >= 5,\n ecmaVersion: this.options.ecmaVersion,\n jsxAttrValueToken: false,\n lastToken: null\n };\n }\n\n tokenize() {\n do {\n this.next();\n } while (this.type !== tokTypes.eof);\n\n // Consume the final eof token\n this.next();\n\n const extra = this[STATE];\n const tokens = extra.tokens;\n\n if (extra.comments) {\n tokens.comments = extra.comments;\n }\n\n return tokens;\n }\n\n finishNode(...args) {\n const result = super.finishNode(...args);\n\n return this[ESPRIMA_FINISH_NODE](result);\n }\n\n finishNodeAt(...args) {\n const result = super.finishNodeAt(...args);\n\n return this[ESPRIMA_FINISH_NODE](result);\n }\n\n parse() {\n const extra = this[STATE];\n const program = super.parse();\n\n program.sourceType = this.options.sourceType;\n\n if (extra.comments) {\n program.comments = extra.comments;\n }\n if (extra.tokens) {\n program.tokens = extra.tokens;\n }\n\n /*\n * Adjust opening and closing position of program to match Esprima.\n * Acorn always starts programs at range 0 whereas Esprima starts at the\n * first AST node's start (the only real difference is when there's leading\n * whitespace or leading comments). Acorn also counts trailing whitespace\n * as part of the program whereas Esprima only counts up to the last token.\n */\n if (program.range) {\n program.range[0] = program.body.length ? program.body[0].range[0] : program.range[0];\n program.range[1] = extra.lastToken ? extra.lastToken.range[1] : program.range[1];\n }\n if (program.loc) {\n program.loc.start = program.body.length ? program.body[0].loc.start : program.loc.start;\n program.loc.end = extra.lastToken ? extra.lastToken.loc.end : program.loc.end;\n }\n\n return program;\n }\n\n parseTopLevel(node) {\n if (this[STATE].impliedStrict) {\n this.strict = true;\n }\n return super.parseTopLevel(node);\n }\n\n /**\n * Overwrites the default raise method to throw Esprima-style errors.\n * @param {int} pos The position of the error.\n * @param {string} message The error message.\n * @throws {SyntaxError} A syntax error.\n * @returns {void}\n */\n raise(pos, message) {\n const loc = Parser.acorn.getLineInfo(this.input, pos);\n const err = new SyntaxError(message);\n\n err.index = pos;\n err.lineNumber = loc.line;\n err.column = loc.column + 1; // acorn uses 0-based columns\n throw err;\n }\n\n /**\n * Overwrites the default raise method to throw Esprima-style errors.\n * @param {int} pos The position of the error.\n * @param {string} message The error message.\n * @throws {SyntaxError} A syntax error.\n * @returns {void}\n */\n raiseRecoverable(pos, message) {\n this.raise(pos, message);\n }\n\n /**\n * Overwrites the default unexpected method to throw Esprima-style errors.\n * @param {int} pos The position of the error.\n * @throws {SyntaxError} A syntax error.\n * @returns {void}\n */\n unexpected(pos) {\n let message = \"Unexpected token\";\n\n if (pos !== null && pos !== void 0) {\n this.pos = pos;\n\n if (this.options.locations) {\n while (this.pos < this.lineStart) {\n this.lineStart = this.input.lastIndexOf(\"\\n\", this.lineStart - 2) + 1;\n --this.curLine;\n }\n }\n\n this.nextToken();\n }\n\n if (this.end > this.start) {\n message += ` ${this.input.slice(this.start, this.end)}`;\n }\n\n this.raise(this.start, message);\n }\n\n /*\n * Esprima-FB represents JSX strings as tokens called \"JSXText\", but Acorn-JSX\n * uses regular tt.string without any distinction between this and regular JS\n * strings. As such, we intercept an attempt to read a JSX string and set a flag\n * on extra so that when tokens are converted, the next token will be switched\n * to JSXText via onToken.\n */\n jsx_readString(quote) { // eslint-disable-line camelcase\n const result = super.jsx_readString(quote);\n\n if (this.type === tokTypes.string) {\n this[STATE].jsxAttrValueToken = true;\n }\n return result;\n }\n\n /**\n * Performs last-minute Esprima-specific compatibility checks and fixes.\n * @param {ASTNode} result The node to check.\n * @returns {ASTNode} The finished node.\n */\n [ESPRIMA_FINISH_NODE](result) {\n\n // Acorn doesn't count the opening and closing backticks as part of templates\n // so we have to adjust ranges/locations appropriately.\n if (result.type === \"TemplateElement\") {\n\n // additional adjustment needed if ${ is the last token\n const terminalDollarBraceL = this.input.slice(result.end, result.end + 2) === \"${\";\n\n if (result.range) {\n result.range[0]--;\n result.range[1] += (terminalDollarBraceL ? 2 : 1);\n }\n\n if (result.loc) {\n result.loc.start.column--;\n result.loc.end.column += (terminalDollarBraceL ? 2 : 1);\n }\n }\n\n if (result.type.includes(\"Function\") && !result.generator) {\n result.generator = false;\n }\n\n return result;\n }\n };\n};\n","const version = \"main\";\n\nexport default version;\n","/**\n * @fileoverview Main Espree file that converts Acorn into Esprima output.\n *\n * This file contains code from the following MIT-licensed projects:\n * 1. Acorn\n * 2. Babylon\n * 3. Babel-ESLint\n *\n * This file also contains code from Esprima, which is BSD licensed.\n *\n * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)\n * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)\n * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie \n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n/* eslint no-undefined:0, no-use-before-define: 0 */\n\nimport * as acorn from \"acorn\";\nimport jsx from \"acorn-jsx\";\nimport astNodeTypes from \"./lib/ast-node-types.js\";\nimport espree from \"./lib/espree.js\";\nimport espreeVersion from \"./lib/version.js\";\nimport visitorKeys from \"eslint-visitor-keys\";\nimport { getLatestEcmaVersion, getSupportedEcmaVersions } from \"./lib/options.js\";\n\n\n// To initialize lazily.\nconst parsers = {\n _regular: null,\n _jsx: null,\n\n get regular() {\n if (this._regular === null) {\n this._regular = acorn.Parser.extend(espree());\n }\n return this._regular;\n },\n\n get jsx() {\n if (this._jsx === null) {\n this._jsx = acorn.Parser.extend(jsx(), espree());\n }\n return this._jsx;\n },\n\n get(options) {\n const useJsx = Boolean(\n options &&\n options.ecmaFeatures &&\n options.ecmaFeatures.jsx\n );\n\n return useJsx ? this.jsx : this.regular;\n }\n};\n\n//------------------------------------------------------------------------------\n// Tokenizer\n//------------------------------------------------------------------------------\n\n/**\n * Tokenizes the given code.\n * @param {string} code The code to tokenize.\n * @param {Object} options Options defining how to tokenize.\n * @returns {Token[]} An array of tokens.\n * @throws {SyntaxError} If the input code is invalid.\n * @private\n */\nexport function tokenize(code, options) {\n const Parser = parsers.get(options);\n\n // Ensure to collect tokens.\n if (!options || options.tokens !== true) {\n options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign\n }\n\n return new Parser(options, code).tokenize();\n}\n\n//------------------------------------------------------------------------------\n// Parser\n//------------------------------------------------------------------------------\n\n/**\n * Parses the given code.\n * @param {string} code The code to tokenize.\n * @param {Object} options Options defining how to tokenize.\n * @returns {ASTNode} The \"Program\" AST node.\n * @throws {SyntaxError} If the input code is invalid.\n */\nexport function parse(code, options) {\n const Parser = parsers.get(options);\n\n return new Parser(options, code).parse();\n}\n\n//------------------------------------------------------------------------------\n// Public\n//------------------------------------------------------------------------------\n\nexport const version = espreeVersion;\n\n\n// Deep copy.\n/* istanbul ignore next */\nexport const Syntax = (function() {\n let name,\n types = {};\n\n if (typeof Object.create === \"function\") {\n types = Object.create(null);\n }\n\n for (name in astNodeTypes) {\n if (Object.hasOwnProperty.call(astNodeTypes, name)) {\n types[name] = astNodeTypes[name];\n }\n }\n\n if (typeof Object.freeze === \"function\") {\n Object.freeze(types);\n }\n\n return types;\n}());\n\n/* istanbul ignore next */\nexport const VisitorKeys = (function() {\n return visitorKeys.KEYS;\n}());\n\nexport const latestEcmaVersion = getLatestEcmaVersion();\n\nexport const supportedEcmaVersions = getSupportedEcmaVersions();\n"],"names":["version","acorn","jsx","espreeVersion","visitorKeys"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAe;AACf,IAAI,oBAAoB,EAAE,sBAAsB;AAChD,IAAI,iBAAiB,EAAE,mBAAmB;AAC1C,IAAI,eAAe,EAAE,iBAAiB;AACtC,IAAI,YAAY,EAAE,cAAc;AAChC,IAAI,uBAAuB,EAAE,yBAAyB;AACtD,IAAI,eAAe,EAAE,iBAAiB;AACtC,IAAI,cAAc,EAAE,gBAAgB;AACpC,IAAI,gBAAgB,EAAE,kBAAkB;AACxC,IAAI,cAAc,EAAE,gBAAgB;AACpC,IAAI,cAAc,EAAE,gBAAgB;AACpC,IAAI,WAAW,EAAE,aAAa;AAC9B,IAAI,SAAS,EAAE,WAAW;AAC1B,IAAI,gBAAgB,EAAE,kBAAkB;AACxC,IAAI,eAAe,EAAE,iBAAiB;AACtC,IAAI,qBAAqB,EAAE,uBAAuB;AAClD,IAAI,iBAAiB,EAAE,mBAAmB;AAC1C,IAAI,gBAAgB,EAAE,kBAAkB;AACxC,IAAI,iBAAiB,EAAE,mBAAmB;AAC1C,IAAI,cAAc,EAAE,gBAAgB;AACpC,IAAI,mBAAmB,EAAE,qBAAqB;AAC9C,IAAI,YAAY,EAAE,cAAc;AAChC,IAAI,cAAc,EAAE,gBAAgB;AACpC,IAAI,cAAc,EAAE,gBAAgB;AACpC,IAAI,mBAAmB,EAAE,qBAAqB;AAC9C,IAAI,kBAAkB,EAAE,oBAAoB;AAC5C,IAAI,UAAU,EAAE,YAAY;AAC5B,IAAI,WAAW,EAAE,aAAa;AAC9B,IAAI,OAAO,EAAE,SAAS;AACtB,IAAI,gBAAgB,EAAE,kBA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D,YAAY,KAAK,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;AAC7C,SAAS;AACT,KAAK;AACL;AACA,IAAI,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC7C,QAAQ,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7B,KAAK;AACL;AACA,IAAI,OAAO,KAAK,CAAC;AACjB,CAAC,EAAE,EAAE;AACL;AACA;AACY,MAAC,WAAW,IAAI,WAAW;AACvC,IAAI,OAAOC,+BAAW,CAAC,IAAI,CAAC;AAC5B,CAAC,EAAE,EAAE;AACL;AACY,MAAC,iBAAiB,GAAG,oBAAoB,GAAG;AACxD;AACY,MAAC,qBAAqB,GAAG,wBAAwB;;;;;;;;;;"} \ No newline at end of file From 2deee8a96abf475d8279fba88a5e9914e9c7db6e Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Fri, 7 May 2021 11:58:28 +0900 Subject: [PATCH 05/11] upgrade eslint-visitor-keys --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61b3b5e5..083c614b 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "dependencies": { "acorn": "^8.2.1", "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "github:eslint/eslint-visitor-keys#908fdf8c0d9a352c696c8c1f4901280d1a0795f7" + "eslint-visitor-keys": "^2.1.0" }, "devDependencies": { "@rollup/plugin-commonjs": "^17.1.0", From aa07bbed4c2093f9ef390944aa35e2dc8e5452c4 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Fri, 7 May 2021 11:58:49 +0900 Subject: [PATCH 06/11] Revert "add dist" This reverts commit 3e9caa787c0d4945401f1abf093b03be9fb44c6c. --- .gitignore | 3 +- dist/espree.cjs | 946 -------------------------------------------- dist/espree.cjs.map | 1 - 3 files changed, 2 insertions(+), 948 deletions(-) delete mode 100644 dist/espree.cjs delete mode 100644 dist/espree.cjs.map diff --git a/.gitignore b/.gitignore index 51dbd21e..97375681 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,11 @@ build coverage node_modules .DS_Store +dist npm-debug.log _test.js .idea .nyc_output .eslint-release-info.json yarn.lock -package-lock.json +package-lock.json \ No newline at end of file diff --git a/dist/espree.cjs b/dist/espree.cjs deleted file mode 100644 index 6f15ca78..00000000 --- a/dist/espree.cjs +++ /dev/null @@ -1,946 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var acorn = require('acorn'); -var jsx = require('acorn-jsx'); -var visitorKeys = require('eslint-visitor-keys'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -var acorn__namespace = /*#__PURE__*/_interopNamespace(acorn); -var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx); -var visitorKeys__default = /*#__PURE__*/_interopDefaultLegacy(visitorKeys); - -/** - * @fileoverview The AST node types produced by the parser. - * @author Nicholas C. Zakas - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -// None! - -//------------------------------------------------------------------------------ -// Public -//------------------------------------------------------------------------------ - -var astNodeTypes = { - AssignmentExpression: "AssignmentExpression", - AssignmentPattern: "AssignmentPattern", - ArrayExpression: "ArrayExpression", - ArrayPattern: "ArrayPattern", - ArrowFunctionExpression: "ArrowFunctionExpression", - AwaitExpression: "AwaitExpression", - BlockStatement: "BlockStatement", - BinaryExpression: "BinaryExpression", - BreakStatement: "BreakStatement", - CallExpression: "CallExpression", - CatchClause: "CatchClause", - ClassBody: "ClassBody", - ClassDeclaration: "ClassDeclaration", - ClassExpression: "ClassExpression", - ConditionalExpression: "ConditionalExpression", - ContinueStatement: "ContinueStatement", - DoWhileStatement: "DoWhileStatement", - DebuggerStatement: "DebuggerStatement", - EmptyStatement: "EmptyStatement", - ExpressionStatement: "ExpressionStatement", - ForStatement: "ForStatement", - ForInStatement: "ForInStatement", - ForOfStatement: "ForOfStatement", - FunctionDeclaration: "FunctionDeclaration", - FunctionExpression: "FunctionExpression", - Identifier: "Identifier", - IfStatement: "IfStatement", - Literal: "Literal", - LabeledStatement: "LabeledStatement", - LogicalExpression: "LogicalExpression", - MemberExpression: "MemberExpression", - MetaProperty: "MetaProperty", - MethodDefinition: "MethodDefinition", - NewExpression: "NewExpression", - ObjectExpression: "ObjectExpression", - ObjectPattern: "ObjectPattern", - Program: "Program", - Property: "Property", - RestElement: "RestElement", - ReturnStatement: "ReturnStatement", - SequenceExpression: "SequenceExpression", - SpreadElement: "SpreadElement", - Super: "Super", - SwitchCase: "SwitchCase", - SwitchStatement: "SwitchStatement", - TaggedTemplateExpression: "TaggedTemplateExpression", - TemplateElement: "TemplateElement", - TemplateLiteral: "TemplateLiteral", - ThisExpression: "ThisExpression", - ThrowStatement: "ThrowStatement", - TryStatement: "TryStatement", - UnaryExpression: "UnaryExpression", - UpdateExpression: "UpdateExpression", - VariableDeclaration: "VariableDeclaration", - VariableDeclarator: "VariableDeclarator", - WhileStatement: "WhileStatement", - WithStatement: "WithStatement", - YieldExpression: "YieldExpression", - JSXIdentifier: "JSXIdentifier", - JSXNamespacedName: "JSXNamespacedName", - JSXMemberExpression: "JSXMemberExpression", - JSXEmptyExpression: "JSXEmptyExpression", - JSXExpressionContainer: "JSXExpressionContainer", - JSXElement: "JSXElement", - JSXClosingElement: "JSXClosingElement", - JSXOpeningElement: "JSXOpeningElement", - JSXAttribute: "JSXAttribute", - JSXSpreadAttribute: "JSXSpreadAttribute", - JSXText: "JSXText", - ExportDefaultDeclaration: "ExportDefaultDeclaration", - ExportNamedDeclaration: "ExportNamedDeclaration", - ExportAllDeclaration: "ExportAllDeclaration", - ExportSpecifier: "ExportSpecifier", - ImportDeclaration: "ImportDeclaration", - ImportSpecifier: "ImportSpecifier", - ImportDefaultSpecifier: "ImportDefaultSpecifier", - ImportNamespaceSpecifier: "ImportNamespaceSpecifier" -}; - -/** - * @fileoverview Translates tokens between Acorn format and Esprima format. - * @author Nicholas C. Zakas - */ -/* eslint no-underscore-dangle: 0 */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -// none! - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - - -// Esprima Token Types -const Token = { - Boolean: "Boolean", - EOF: "", - Identifier: "Identifier", - PrivateIdentifier: "PrivateIdentifier", - Keyword: "Keyword", - Null: "Null", - Numeric: "Numeric", - Punctuator: "Punctuator", - String: "String", - RegularExpression: "RegularExpression", - Template: "Template", - JSXIdentifier: "JSXIdentifier", - JSXText: "JSXText" -}; - -/** - * Converts part of a template into an Esprima token. - * @param {AcornToken[]} tokens The Acorn tokens representing the template. - * @param {string} code The source code. - * @returns {EsprimaToken} The Esprima equivalent of the template token. - * @private - */ -function convertTemplatePart(tokens, code) { - const firstToken = tokens[0], - lastTemplateToken = tokens[tokens.length - 1]; - - const token = { - type: Token.Template, - value: code.slice(firstToken.start, lastTemplateToken.end) - }; - - if (firstToken.loc) { - token.loc = { - start: firstToken.loc.start, - end: lastTemplateToken.loc.end - }; - } - - if (firstToken.range) { - token.start = firstToken.range[0]; - token.end = lastTemplateToken.range[1]; - token.range = [token.start, token.end]; - } - - return token; -} - -/** - * Contains logic to translate Acorn tokens into Esprima tokens. - * @param {Object} acornTokTypes The Acorn token types. - * @param {string} code The source code Acorn is parsing. This is necessary - * to correct the "value" property of some tokens. - * @constructor - */ -function TokenTranslator(acornTokTypes, code) { - - // token types - this._acornTokTypes = acornTokTypes; - - // token buffer for templates - this._tokens = []; - - // track the last curly brace - this._curlyBrace = null; - - // the source code - this._code = code; - -} - -TokenTranslator.prototype = { - constructor: TokenTranslator, - - /** - * Translates a single Esprima token to a single Acorn token. This may be - * inaccurate due to how templates are handled differently in Esprima and - * Acorn, but should be accurate for all other tokens. - * @param {AcornToken} token The Acorn token to translate. - * @param {Object} extra Espree extra object. - * @returns {EsprimaToken} The Esprima version of the token. - */ - translate(token, extra) { - - const type = token.type, - tt = this._acornTokTypes; - - if (type === tt.name) { - token.type = Token.Identifier; - - // TODO: See if this is an Acorn bug - if (token.value === "static") { - token.type = Token.Keyword; - } - - if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) { - token.type = Token.Keyword; - } - - } else if (type === tt.privateId) { - token.type = Token.PrivateIdentifier; - - } else if (type === tt.semi || type === tt.comma || - type === tt.parenL || type === tt.parenR || - type === tt.braceL || type === tt.braceR || - type === tt.dot || type === tt.bracketL || - type === tt.colon || type === tt.question || - type === tt.bracketR || type === tt.ellipsis || - type === tt.arrow || type === tt.jsxTagStart || - type === tt.incDec || type === tt.starstar || - type === tt.jsxTagEnd || type === tt.prefix || - type === tt.questionDot || - (type.binop && !type.keyword) || - type.isAssign) { - - token.type = Token.Punctuator; - token.value = this._code.slice(token.start, token.end); - } else if (type === tt.jsxName) { - token.type = Token.JSXIdentifier; - } else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) { - token.type = Token.JSXText; - } else if (type.keyword) { - if (type.keyword === "true" || type.keyword === "false") { - token.type = Token.Boolean; - } else if (type.keyword === "null") { - token.type = Token.Null; - } else { - token.type = Token.Keyword; - } - } else if (type === tt.num) { - token.type = Token.Numeric; - token.value = this._code.slice(token.start, token.end); - } else if (type === tt.string) { - - if (extra.jsxAttrValueToken) { - extra.jsxAttrValueToken = false; - token.type = Token.JSXText; - } else { - token.type = Token.String; - } - - token.value = this._code.slice(token.start, token.end); - } else if (type === tt.regexp) { - token.type = Token.RegularExpression; - const value = token.value; - - token.regex = { - flags: value.flags, - pattern: value.pattern - }; - token.value = `/${value.pattern}/${value.flags}`; - } - - return token; - }, - - /** - * Function to call during Acorn's onToken handler. - * @param {AcornToken} token The Acorn token. - * @param {Object} extra The Espree extra object. - * @returns {void} - */ - onToken(token, extra) { - - const that = this, - tt = this._acornTokTypes, - tokens = extra.tokens, - templateTokens = this._tokens; - - /** - * Flushes the buffered template tokens and resets the template - * tracking. - * @returns {void} - * @private - */ - function translateTemplateTokens() { - tokens.push(convertTemplatePart(that._tokens, that._code)); - that._tokens = []; - } - - if (token.type === tt.eof) { - - // might be one last curlyBrace - if (this._curlyBrace) { - tokens.push(this.translate(this._curlyBrace, extra)); - } - - return; - } - - if (token.type === tt.backQuote) { - - // if there's already a curly, it's not part of the template - if (this._curlyBrace) { - tokens.push(this.translate(this._curlyBrace, extra)); - this._curlyBrace = null; - } - - templateTokens.push(token); - - // it's the end - if (templateTokens.length > 1) { - translateTemplateTokens(); - } - - return; - } - if (token.type === tt.dollarBraceL) { - templateTokens.push(token); - translateTemplateTokens(); - return; - } - if (token.type === tt.braceR) { - - // if there's already a curly, it's not part of the template - if (this._curlyBrace) { - tokens.push(this.translate(this._curlyBrace, extra)); - } - - // store new curly for later - this._curlyBrace = token; - return; - } - if (token.type === tt.template || token.type === tt.invalidTemplate) { - if (this._curlyBrace) { - templateTokens.push(this._curlyBrace); - this._curlyBrace = null; - } - - templateTokens.push(token); - return; - } - - if (this._curlyBrace) { - tokens.push(this.translate(this._curlyBrace, extra)); - this._curlyBrace = null; - } - - tokens.push(this.translate(token, extra)); - } -}; - -/** - * @fileoverview A collection of methods for processing Espree's options. - * @author Kai Cataldo - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const DEFAULT_ECMA_VERSION = 5; -const SUPPORTED_VERSIONS = [ - 3, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13 -]; - -/** - * Normalize ECMAScript version from the initial config - * @param {number} ecmaVersion ECMAScript version from the initial config - * @throws {Error} throws an error if the ecmaVersion is invalid. - * @returns {number} normalized ECMAScript version - */ -function normalizeEcmaVersion(ecmaVersion = DEFAULT_ECMA_VERSION) { - if (typeof ecmaVersion !== "number") { - throw new Error(`ecmaVersion must be a number. Received value of type ${typeof ecmaVersion} instead.`); - } - - let version = ecmaVersion; - - // Calculate ECMAScript edition number from official year version starting with - // ES2015, which corresponds with ES6 (or a difference of 2009). - if (version >= 2015) { - version -= 2009; - } - - if (!SUPPORTED_VERSIONS.includes(version)) { - throw new Error("Invalid ecmaVersion."); - } - - return version; -} - -/** - * Normalize sourceType from the initial config - * @param {string} sourceType to normalize - * @throws {Error} throw an error if sourceType is invalid - * @returns {string} normalized sourceType - */ -function normalizeSourceType(sourceType = "script") { - if (sourceType === "script" || sourceType === "module") { - return sourceType; - } - throw new Error("Invalid sourceType."); -} - -/** - * Normalize parserOptions - * @param {Object} options the parser options to normalize - * @throws {Error} throw an error if found invalid option. - * @returns {Object} normalized options - */ -function normalizeOptions(options) { - const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion); - const sourceType = normalizeSourceType(options.sourceType); - const ranges = options.range === true; - const locations = options.loc === true; - - if (sourceType === "module" && ecmaVersion < 6) { - throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options."); - } - return Object.assign({}, options, { ecmaVersion, sourceType, ranges, locations }); -} - -/** - * Get the latest ECMAScript version supported by Espree. - * @returns {number} The latest ECMAScript version. - */ -function getLatestEcmaVersion() { - return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1]; -} - -/** - * Get the list of ECMAScript versions supported by Espree. - * @returns {number[]} An array containing the supported ECMAScript versions. - */ -function getSupportedEcmaVersions() { - return [...SUPPORTED_VERSIONS]; -} - -/* eslint-disable no-param-reassign*/ - - -const STATE = Symbol("espree's internal state"); -const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode"); - - -/** - * Converts an Acorn comment to a Esprima comment. - * @param {boolean} block True if it's a block comment, false if not. - * @param {string} text The text of the comment. - * @param {int} start The index at which the comment starts. - * @param {int} end The index at which the comment ends. - * @param {Location} startLoc The location at which the comment starts. - * @param {Location} endLoc The location at which the comment ends. - * @returns {Object} The comment object. - * @private - */ -function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) { - const comment = { - type: block ? "Block" : "Line", - value: text - }; - - if (typeof start === "number") { - comment.start = start; - comment.end = end; - comment.range = [start, end]; - } - - if (typeof startLoc === "object") { - comment.loc = { - start: startLoc, - end: endLoc - }; - } - - return comment; -} - -var espree = () => Parser => { - const tokTypes = Object.assign({}, Parser.acorn.tokTypes); - - if (Parser.acornJsx) { - Object.assign(tokTypes, Parser.acornJsx.tokTypes); - } - - return class Espree extends Parser { - constructor(opts, code) { - if (typeof opts !== "object" || opts === null) { - opts = {}; - } - if (typeof code !== "string" && !(code instanceof String)) { - code = String(code); - } - - const options = normalizeOptions(opts); - const ecmaFeatures = options.ecmaFeatures || {}; - const tokenTranslator = - options.tokens === true - ? new TokenTranslator(tokTypes, code) - : null; - - // Initialize acorn parser. - super({ - - // TODO: use {...options} when spread is supported(Node.js >= 8.3.0). - ecmaVersion: options.ecmaVersion, - sourceType: options.sourceType, - ranges: options.ranges, - locations: options.locations, - - // Truthy value is true for backward compatibility. - allowReturnOutsideFunction: Boolean(ecmaFeatures.globalReturn), - - // Collect tokens - onToken: token => { - if (tokenTranslator) { - - // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state. - tokenTranslator.onToken(token, this[STATE]); - } - if (token.type !== tokTypes.eof) { - this[STATE].lastToken = token; - } - }, - - // Collect comments - onComment: (block, text, start, end, startLoc, endLoc) => { - if (this[STATE].comments) { - const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc); - - this[STATE].comments.push(comment); - } - } - }, code); - - // Initialize internal state. - this[STATE] = { - tokens: tokenTranslator ? [] : null, - comments: options.comment === true ? [] : null, - impliedStrict: ecmaFeatures.impliedStrict === true && this.options.ecmaVersion >= 5, - ecmaVersion: this.options.ecmaVersion, - jsxAttrValueToken: false, - lastToken: null - }; - } - - tokenize() { - do { - this.next(); - } while (this.type !== tokTypes.eof); - - // Consume the final eof token - this.next(); - - const extra = this[STATE]; - const tokens = extra.tokens; - - if (extra.comments) { - tokens.comments = extra.comments; - } - - return tokens; - } - - finishNode(...args) { - const result = super.finishNode(...args); - - return this[ESPRIMA_FINISH_NODE](result); - } - - finishNodeAt(...args) { - const result = super.finishNodeAt(...args); - - return this[ESPRIMA_FINISH_NODE](result); - } - - parse() { - const extra = this[STATE]; - const program = super.parse(); - - program.sourceType = this.options.sourceType; - - if (extra.comments) { - program.comments = extra.comments; - } - if (extra.tokens) { - program.tokens = extra.tokens; - } - - /* - * Adjust opening and closing position of program to match Esprima. - * Acorn always starts programs at range 0 whereas Esprima starts at the - * first AST node's start (the only real difference is when there's leading - * whitespace or leading comments). Acorn also counts trailing whitespace - * as part of the program whereas Esprima only counts up to the last token. - */ - if (program.range) { - program.range[0] = program.body.length ? program.body[0].range[0] : program.range[0]; - program.range[1] = extra.lastToken ? extra.lastToken.range[1] : program.range[1]; - } - if (program.loc) { - program.loc.start = program.body.length ? program.body[0].loc.start : program.loc.start; - program.loc.end = extra.lastToken ? extra.lastToken.loc.end : program.loc.end; - } - - return program; - } - - parseTopLevel(node) { - if (this[STATE].impliedStrict) { - this.strict = true; - } - return super.parseTopLevel(node); - } - - /** - * Overwrites the default raise method to throw Esprima-style errors. - * @param {int} pos The position of the error. - * @param {string} message The error message. - * @throws {SyntaxError} A syntax error. - * @returns {void} - */ - raise(pos, message) { - const loc = Parser.acorn.getLineInfo(this.input, pos); - const err = new SyntaxError(message); - - err.index = pos; - err.lineNumber = loc.line; - err.column = loc.column + 1; // acorn uses 0-based columns - throw err; - } - - /** - * Overwrites the default raise method to throw Esprima-style errors. - * @param {int} pos The position of the error. - * @param {string} message The error message. - * @throws {SyntaxError} A syntax error. - * @returns {void} - */ - raiseRecoverable(pos, message) { - this.raise(pos, message); - } - - /** - * Overwrites the default unexpected method to throw Esprima-style errors. - * @param {int} pos The position of the error. - * @throws {SyntaxError} A syntax error. - * @returns {void} - */ - unexpected(pos) { - let message = "Unexpected token"; - - if (pos !== null && pos !== void 0) { - this.pos = pos; - - if (this.options.locations) { - while (this.pos < this.lineStart) { - this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1; - --this.curLine; - } - } - - this.nextToken(); - } - - if (this.end > this.start) { - message += ` ${this.input.slice(this.start, this.end)}`; - } - - this.raise(this.start, message); - } - - /* - * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX - * uses regular tt.string without any distinction between this and regular JS - * strings. As such, we intercept an attempt to read a JSX string and set a flag - * on extra so that when tokens are converted, the next token will be switched - * to JSXText via onToken. - */ - jsx_readString(quote) { // eslint-disable-line camelcase - const result = super.jsx_readString(quote); - - if (this.type === tokTypes.string) { - this[STATE].jsxAttrValueToken = true; - } - return result; - } - - /** - * Performs last-minute Esprima-specific compatibility checks and fixes. - * @param {ASTNode} result The node to check. - * @returns {ASTNode} The finished node. - */ - [ESPRIMA_FINISH_NODE](result) { - - // Acorn doesn't count the opening and closing backticks as part of templates - // so we have to adjust ranges/locations appropriately. - if (result.type === "TemplateElement") { - - // additional adjustment needed if ${ is the last token - const terminalDollarBraceL = this.input.slice(result.end, result.end + 2) === "${"; - - if (result.range) { - result.range[0]--; - result.range[1] += (terminalDollarBraceL ? 2 : 1); - } - - if (result.loc) { - result.loc.start.column--; - result.loc.end.column += (terminalDollarBraceL ? 2 : 1); - } - } - - if (result.type.includes("Function") && !result.generator) { - result.generator = false; - } - - return result; - } - }; -}; - -const version$1 = "main"; - -/** - * @fileoverview Main Espree file that converts Acorn into Esprima output. - * - * This file contains code from the following MIT-licensed projects: - * 1. Acorn - * 2. Babylon - * 3. Babel-ESLint - * - * This file also contains code from Esprima, which is BSD licensed. - * - * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS) - * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS) - * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -// To initialize lazily. -const parsers = { - _regular: null, - _jsx: null, - - get regular() { - if (this._regular === null) { - this._regular = acorn__namespace.Parser.extend(espree()); - } - return this._regular; - }, - - get jsx() { - if (this._jsx === null) { - this._jsx = acorn__namespace.Parser.extend(jsx__default['default'](), espree()); - } - return this._jsx; - }, - - get(options) { - const useJsx = Boolean( - options && - options.ecmaFeatures && - options.ecmaFeatures.jsx - ); - - return useJsx ? this.jsx : this.regular; - } -}; - -//------------------------------------------------------------------------------ -// Tokenizer -//------------------------------------------------------------------------------ - -/** - * Tokenizes the given code. - * @param {string} code The code to tokenize. - * @param {Object} options Options defining how to tokenize. - * @returns {Token[]} An array of tokens. - * @throws {SyntaxError} If the input code is invalid. - * @private - */ -function tokenize(code, options) { - const Parser = parsers.get(options); - - // Ensure to collect tokens. - if (!options || options.tokens !== true) { - options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign - } - - return new Parser(options, code).tokenize(); -} - -//------------------------------------------------------------------------------ -// Parser -//------------------------------------------------------------------------------ - -/** - * Parses the given code. - * @param {string} code The code to tokenize. - * @param {Object} options Options defining how to tokenize. - * @returns {ASTNode} The "Program" AST node. - * @throws {SyntaxError} If the input code is invalid. - */ -function parse(code, options) { - const Parser = parsers.get(options); - - return new Parser(options, code).parse(); -} - -//------------------------------------------------------------------------------ -// Public -//------------------------------------------------------------------------------ - -const version = version$1; - - -// Deep copy. -/* istanbul ignore next */ -const Syntax = (function() { - let name, - types = {}; - - if (typeof Object.create === "function") { - types = Object.create(null); - } - - for (name in astNodeTypes) { - if (Object.hasOwnProperty.call(astNodeTypes, name)) { - types[name] = astNodeTypes[name]; - } - } - - if (typeof Object.freeze === "function") { - Object.freeze(types); - } - - return types; -}()); - -/* istanbul ignore next */ -const VisitorKeys = (function() { - return visitorKeys__default['default'].KEYS; -}()); - -const latestEcmaVersion = getLatestEcmaVersion(); - -const supportedEcmaVersions = getSupportedEcmaVersions(); - -exports.Syntax = Syntax; -exports.VisitorKeys = VisitorKeys; -exports.latestEcmaVersion = latestEcmaVersion; -exports.parse = parse; -exports.supportedEcmaVersions = supportedEcmaVersions; -exports.tokenize = tokenize; -exports.version = version; -//# sourceMappingURL=espree.cjs.map diff --git a/dist/espree.cjs.map b/dist/espree.cjs.map deleted file mode 100644 index 3c25eb09..00000000 --- a/dist/espree.cjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"espree.cjs","sources":["../lib/ast-node-types.js","../lib/token-translator.js","../lib/options.js","../lib/espree.js","../lib/version.js","../espree.js"],"sourcesContent":["/**\n * @fileoverview The AST node types produced by the parser.\n * @author Nicholas C. Zakas\n */\n\n//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\n// None!\n\n//------------------------------------------------------------------------------\n// Public\n//------------------------------------------------------------------------------\n\nexport default {\n AssignmentExpression: \"AssignmentExpression\",\n AssignmentPattern: \"AssignmentPattern\",\n ArrayExpression: \"ArrayExpression\",\n ArrayPattern: \"ArrayPattern\",\n ArrowFunctionExpression: \"ArrowFunctionExpression\",\n AwaitExpression: \"AwaitExpression\",\n BlockStatement: \"BlockStatement\",\n BinaryExpression: \"BinaryExpression\",\n BreakStatement: \"BreakStatement\",\n CallExpression: \"CallExpression\",\n CatchClause: \"CatchClause\",\n ClassBody: \"ClassBody\",\n ClassDeclaration: \"ClassDeclaration\",\n ClassExpression: \"ClassExpression\",\n ConditionalExpression: \"ConditionalExpression\",\n ContinueStatement: \"ContinueStatement\",\n DoWhileStatement: \"DoWhileStatement\",\n DebuggerStatement: \"DebuggerStatement\",\n EmptyStatement: \"EmptyStatement\",\n ExpressionStatement: \"ExpressionStatement\",\n ForStatement: \"ForStatement\",\n ForInStatement: \"ForInStatement\",\n ForOfStatement: \"ForOfStatement\",\n FunctionDeclaration: \"FunctionDeclaration\",\n FunctionExpression: \"FunctionExpression\",\n Identifier: \"Identifier\",\n IfStatement: \"IfStatement\",\n Literal: \"Literal\",\n LabeledStatement: \"LabeledStatement\",\n LogicalExpression: \"LogicalExpression\",\n MemberExpression: \"MemberExpression\",\n MetaProperty: \"MetaProperty\",\n MethodDefinition: \"MethodDefinition\",\n NewExpression: \"NewExpression\",\n ObjectExpression: \"ObjectExpression\",\n ObjectPattern: \"ObjectPattern\",\n Program: \"Program\",\n Property: \"Property\",\n RestElement: \"RestElement\",\n ReturnStatement: \"ReturnStatement\",\n SequenceExpression: \"SequenceExpression\",\n SpreadElement: \"SpreadElement\",\n Super: \"Super\",\n SwitchCase: \"SwitchCase\",\n SwitchStatement: \"SwitchStatement\",\n TaggedTemplateExpression: \"TaggedTemplateExpression\",\n TemplateElement: \"TemplateElement\",\n TemplateLiteral: \"TemplateLiteral\",\n ThisExpression: \"ThisExpression\",\n ThrowStatement: \"ThrowStatement\",\n TryStatement: \"TryStatement\",\n UnaryExpression: \"UnaryExpression\",\n UpdateExpression: \"UpdateExpression\",\n VariableDeclaration: \"VariableDeclaration\",\n VariableDeclarator: \"VariableDeclarator\",\n WhileStatement: \"WhileStatement\",\n WithStatement: \"WithStatement\",\n YieldExpression: \"YieldExpression\",\n JSXIdentifier: \"JSXIdentifier\",\n JSXNamespacedName: \"JSXNamespacedName\",\n JSXMemberExpression: \"JSXMemberExpression\",\n JSXEmptyExpression: \"JSXEmptyExpression\",\n JSXExpressionContainer: \"JSXExpressionContainer\",\n JSXElement: \"JSXElement\",\n JSXClosingElement: \"JSXClosingElement\",\n JSXOpeningElement: \"JSXOpeningElement\",\n JSXAttribute: \"JSXAttribute\",\n JSXSpreadAttribute: \"JSXSpreadAttribute\",\n JSXText: \"JSXText\",\n ExportDefaultDeclaration: \"ExportDefaultDeclaration\",\n ExportNamedDeclaration: \"ExportNamedDeclaration\",\n ExportAllDeclaration: \"ExportAllDeclaration\",\n ExportSpecifier: \"ExportSpecifier\",\n ImportDeclaration: \"ImportDeclaration\",\n ImportSpecifier: \"ImportSpecifier\",\n ImportDefaultSpecifier: \"ImportDefaultSpecifier\",\n ImportNamespaceSpecifier: \"ImportNamespaceSpecifier\"\n};\n","/**\n * @fileoverview Translates tokens between Acorn format and Esprima format.\n * @author Nicholas C. Zakas\n */\n/* eslint no-underscore-dangle: 0 */\n\n//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\n// none!\n\n//------------------------------------------------------------------------------\n// Private\n//------------------------------------------------------------------------------\n\n\n// Esprima Token Types\nconst Token = {\n Boolean: \"Boolean\",\n EOF: \"\",\n Identifier: \"Identifier\",\n PrivateIdentifier: \"PrivateIdentifier\",\n Keyword: \"Keyword\",\n Null: \"Null\",\n Numeric: \"Numeric\",\n Punctuator: \"Punctuator\",\n String: \"String\",\n RegularExpression: \"RegularExpression\",\n Template: \"Template\",\n JSXIdentifier: \"JSXIdentifier\",\n JSXText: \"JSXText\"\n};\n\n/**\n * Converts part of a template into an Esprima token.\n * @param {AcornToken[]} tokens The Acorn tokens representing the template.\n * @param {string} code The source code.\n * @returns {EsprimaToken} The Esprima equivalent of the template token.\n * @private\n */\nfunction convertTemplatePart(tokens, code) {\n const firstToken = tokens[0],\n lastTemplateToken = tokens[tokens.length - 1];\n\n const token = {\n type: Token.Template,\n value: code.slice(firstToken.start, lastTemplateToken.end)\n };\n\n if (firstToken.loc) {\n token.loc = {\n start: firstToken.loc.start,\n end: lastTemplateToken.loc.end\n };\n }\n\n if (firstToken.range) {\n token.start = firstToken.range[0];\n token.end = lastTemplateToken.range[1];\n token.range = [token.start, token.end];\n }\n\n return token;\n}\n\n/**\n * Contains logic to translate Acorn tokens into Esprima tokens.\n * @param {Object} acornTokTypes The Acorn token types.\n * @param {string} code The source code Acorn is parsing. This is necessary\n * to correct the \"value\" property of some tokens.\n * @constructor\n */\nfunction TokenTranslator(acornTokTypes, code) {\n\n // token types\n this._acornTokTypes = acornTokTypes;\n\n // token buffer for templates\n this._tokens = [];\n\n // track the last curly brace\n this._curlyBrace = null;\n\n // the source code\n this._code = code;\n\n}\n\nTokenTranslator.prototype = {\n constructor: TokenTranslator,\n\n /**\n * Translates a single Esprima token to a single Acorn token. This may be\n * inaccurate due to how templates are handled differently in Esprima and\n * Acorn, but should be accurate for all other tokens.\n * @param {AcornToken} token The Acorn token to translate.\n * @param {Object} extra Espree extra object.\n * @returns {EsprimaToken} The Esprima version of the token.\n */\n translate(token, extra) {\n\n const type = token.type,\n tt = this._acornTokTypes;\n\n if (type === tt.name) {\n token.type = Token.Identifier;\n\n // TODO: See if this is an Acorn bug\n if (token.value === \"static\") {\n token.type = Token.Keyword;\n }\n\n if (extra.ecmaVersion > 5 && (token.value === \"yield\" || token.value === \"let\")) {\n token.type = Token.Keyword;\n }\n\n } else if (type === tt.privateId) {\n token.type = Token.PrivateIdentifier;\n\n } else if (type === tt.semi || type === tt.comma ||\n type === tt.parenL || type === tt.parenR ||\n type === tt.braceL || type === tt.braceR ||\n type === tt.dot || type === tt.bracketL ||\n type === tt.colon || type === tt.question ||\n type === tt.bracketR || type === tt.ellipsis ||\n type === tt.arrow || type === tt.jsxTagStart ||\n type === tt.incDec || type === tt.starstar ||\n type === tt.jsxTagEnd || type === tt.prefix ||\n type === tt.questionDot ||\n (type.binop && !type.keyword) ||\n type.isAssign) {\n\n token.type = Token.Punctuator;\n token.value = this._code.slice(token.start, token.end);\n } else if (type === tt.jsxName) {\n token.type = Token.JSXIdentifier;\n } else if (type.label === \"jsxText\" || type === tt.jsxAttrValueToken) {\n token.type = Token.JSXText;\n } else if (type.keyword) {\n if (type.keyword === \"true\" || type.keyword === \"false\") {\n token.type = Token.Boolean;\n } else if (type.keyword === \"null\") {\n token.type = Token.Null;\n } else {\n token.type = Token.Keyword;\n }\n } else if (type === tt.num) {\n token.type = Token.Numeric;\n token.value = this._code.slice(token.start, token.end);\n } else if (type === tt.string) {\n\n if (extra.jsxAttrValueToken) {\n extra.jsxAttrValueToken = false;\n token.type = Token.JSXText;\n } else {\n token.type = Token.String;\n }\n\n token.value = this._code.slice(token.start, token.end);\n } else if (type === tt.regexp) {\n token.type = Token.RegularExpression;\n const value = token.value;\n\n token.regex = {\n flags: value.flags,\n pattern: value.pattern\n };\n token.value = `/${value.pattern}/${value.flags}`;\n }\n\n return token;\n },\n\n /**\n * Function to call during Acorn's onToken handler.\n * @param {AcornToken} token The Acorn token.\n * @param {Object} extra The Espree extra object.\n * @returns {void}\n */\n onToken(token, extra) {\n\n const that = this,\n tt = this._acornTokTypes,\n tokens = extra.tokens,\n templateTokens = this._tokens;\n\n /**\n * Flushes the buffered template tokens and resets the template\n * tracking.\n * @returns {void}\n * @private\n */\n function translateTemplateTokens() {\n tokens.push(convertTemplatePart(that._tokens, that._code));\n that._tokens = [];\n }\n\n if (token.type === tt.eof) {\n\n // might be one last curlyBrace\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n }\n\n return;\n }\n\n if (token.type === tt.backQuote) {\n\n // if there's already a curly, it's not part of the template\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n this._curlyBrace = null;\n }\n\n templateTokens.push(token);\n\n // it's the end\n if (templateTokens.length > 1) {\n translateTemplateTokens();\n }\n\n return;\n }\n if (token.type === tt.dollarBraceL) {\n templateTokens.push(token);\n translateTemplateTokens();\n return;\n }\n if (token.type === tt.braceR) {\n\n // if there's already a curly, it's not part of the template\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n }\n\n // store new curly for later\n this._curlyBrace = token;\n return;\n }\n if (token.type === tt.template || token.type === tt.invalidTemplate) {\n if (this._curlyBrace) {\n templateTokens.push(this._curlyBrace);\n this._curlyBrace = null;\n }\n\n templateTokens.push(token);\n return;\n }\n\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n this._curlyBrace = null;\n }\n\n tokens.push(this.translate(token, extra));\n }\n};\n\n//------------------------------------------------------------------------------\n// Public\n//------------------------------------------------------------------------------\n\nexport default TokenTranslator;\n","/**\n * @fileoverview A collection of methods for processing Espree's options.\n * @author Kai Cataldo\n */\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\nconst DEFAULT_ECMA_VERSION = 5;\nconst SUPPORTED_VERSIONS = [\n 3,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13\n];\n\n/**\n * Normalize ECMAScript version from the initial config\n * @param {number} ecmaVersion ECMAScript version from the initial config\n * @throws {Error} throws an error if the ecmaVersion is invalid.\n * @returns {number} normalized ECMAScript version\n */\nfunction normalizeEcmaVersion(ecmaVersion = DEFAULT_ECMA_VERSION) {\n if (typeof ecmaVersion !== \"number\") {\n throw new Error(`ecmaVersion must be a number. Received value of type ${typeof ecmaVersion} instead.`);\n }\n\n let version = ecmaVersion;\n\n // Calculate ECMAScript edition number from official year version starting with\n // ES2015, which corresponds with ES6 (or a difference of 2009).\n if (version >= 2015) {\n version -= 2009;\n }\n\n if (!SUPPORTED_VERSIONS.includes(version)) {\n throw new Error(\"Invalid ecmaVersion.\");\n }\n\n return version;\n}\n\n/**\n * Normalize sourceType from the initial config\n * @param {string} sourceType to normalize\n * @throws {Error} throw an error if sourceType is invalid\n * @returns {string} normalized sourceType\n */\nfunction normalizeSourceType(sourceType = \"script\") {\n if (sourceType === \"script\" || sourceType === \"module\") {\n return sourceType;\n }\n throw new Error(\"Invalid sourceType.\");\n}\n\n/**\n * Normalize parserOptions\n * @param {Object} options the parser options to normalize\n * @throws {Error} throw an error if found invalid option.\n * @returns {Object} normalized options\n */\nexport function normalizeOptions(options) {\n const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);\n const sourceType = normalizeSourceType(options.sourceType);\n const ranges = options.range === true;\n const locations = options.loc === true;\n\n if (sourceType === \"module\" && ecmaVersion < 6) {\n throw new Error(\"sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.\");\n }\n return Object.assign({}, options, { ecmaVersion, sourceType, ranges, locations });\n}\n\n/**\n * Get the latest ECMAScript version supported by Espree.\n * @returns {number} The latest ECMAScript version.\n */\nexport function getLatestEcmaVersion() {\n return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1];\n}\n\n/**\n * Get the list of ECMAScript versions supported by Espree.\n * @returns {number[]} An array containing the supported ECMAScript versions.\n */\nexport function getSupportedEcmaVersions() {\n return [...SUPPORTED_VERSIONS];\n}\n","/* eslint-disable no-param-reassign*/\nimport TokenTranslator from \"./token-translator.js\";\nimport { normalizeOptions } from \"./options.js\";\n\n\nconst STATE = Symbol(\"espree's internal state\");\nconst ESPRIMA_FINISH_NODE = Symbol(\"espree's esprimaFinishNode\");\n\n\n/**\n * Converts an Acorn comment to a Esprima comment.\n * @param {boolean} block True if it's a block comment, false if not.\n * @param {string} text The text of the comment.\n * @param {int} start The index at which the comment starts.\n * @param {int} end The index at which the comment ends.\n * @param {Location} startLoc The location at which the comment starts.\n * @param {Location} endLoc The location at which the comment ends.\n * @returns {Object} The comment object.\n * @private\n */\nfunction convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) {\n const comment = {\n type: block ? \"Block\" : \"Line\",\n value: text\n };\n\n if (typeof start === \"number\") {\n comment.start = start;\n comment.end = end;\n comment.range = [start, end];\n }\n\n if (typeof startLoc === \"object\") {\n comment.loc = {\n start: startLoc,\n end: endLoc\n };\n }\n\n return comment;\n}\n\nexport default () => Parser => {\n const tokTypes = Object.assign({}, Parser.acorn.tokTypes);\n\n if (Parser.acornJsx) {\n Object.assign(tokTypes, Parser.acornJsx.tokTypes);\n }\n\n return class Espree extends Parser {\n constructor(opts, code) {\n if (typeof opts !== \"object\" || opts === null) {\n opts = {};\n }\n if (typeof code !== \"string\" && !(code instanceof String)) {\n code = String(code);\n }\n\n const options = normalizeOptions(opts);\n const ecmaFeatures = options.ecmaFeatures || {};\n const tokenTranslator =\n options.tokens === true\n ? new TokenTranslator(tokTypes, code)\n : null;\n\n // Initialize acorn parser.\n super({\n\n // TODO: use {...options} when spread is supported(Node.js >= 8.3.0).\n ecmaVersion: options.ecmaVersion,\n sourceType: options.sourceType,\n ranges: options.ranges,\n locations: options.locations,\n\n // Truthy value is true for backward compatibility.\n allowReturnOutsideFunction: Boolean(ecmaFeatures.globalReturn),\n\n // Collect tokens\n onToken: token => {\n if (tokenTranslator) {\n\n // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.\n tokenTranslator.onToken(token, this[STATE]);\n }\n if (token.type !== tokTypes.eof) {\n this[STATE].lastToken = token;\n }\n },\n\n // Collect comments\n onComment: (block, text, start, end, startLoc, endLoc) => {\n if (this[STATE].comments) {\n const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc);\n\n this[STATE].comments.push(comment);\n }\n }\n }, code);\n\n // Initialize internal state.\n this[STATE] = {\n tokens: tokenTranslator ? [] : null,\n comments: options.comment === true ? [] : null,\n impliedStrict: ecmaFeatures.impliedStrict === true && this.options.ecmaVersion >= 5,\n ecmaVersion: this.options.ecmaVersion,\n jsxAttrValueToken: false,\n lastToken: null\n };\n }\n\n tokenize() {\n do {\n this.next();\n } while (this.type !== tokTypes.eof);\n\n // Consume the final eof token\n this.next();\n\n const extra = this[STATE];\n const tokens = extra.tokens;\n\n if (extra.comments) {\n tokens.comments = extra.comments;\n }\n\n return tokens;\n }\n\n finishNode(...args) {\n const result = super.finishNode(...args);\n\n return this[ESPRIMA_FINISH_NODE](result);\n }\n\n finishNodeAt(...args) {\n const result = super.finishNodeAt(...args);\n\n return this[ESPRIMA_FINISH_NODE](result);\n }\n\n parse() {\n const extra = this[STATE];\n const program = super.parse();\n\n program.sourceType = this.options.sourceType;\n\n if (extra.comments) {\n program.comments = extra.comments;\n }\n if (extra.tokens) {\n program.tokens = extra.tokens;\n }\n\n /*\n * Adjust opening and closing position of program to match Esprima.\n * Acorn always starts programs at range 0 whereas Esprima starts at the\n * first AST node's start (the only real difference is when there's leading\n * whitespace or leading comments). Acorn also counts trailing whitespace\n * as part of the program whereas Esprima only counts up to the last token.\n */\n if (program.range) {\n program.range[0] = program.body.length ? program.body[0].range[0] : program.range[0];\n program.range[1] = extra.lastToken ? extra.lastToken.range[1] : program.range[1];\n }\n if (program.loc) {\n program.loc.start = program.body.length ? program.body[0].loc.start : program.loc.start;\n program.loc.end = extra.lastToken ? extra.lastToken.loc.end : program.loc.end;\n }\n\n return program;\n }\n\n parseTopLevel(node) {\n if (this[STATE].impliedStrict) {\n this.strict = true;\n }\n return super.parseTopLevel(node);\n }\n\n /**\n * Overwrites the default raise method to throw Esprima-style errors.\n * @param {int} pos The position of the error.\n * @param {string} message The error message.\n * @throws {SyntaxError} A syntax error.\n * @returns {void}\n */\n raise(pos, message) {\n const loc = Parser.acorn.getLineInfo(this.input, pos);\n const err = new SyntaxError(message);\n\n err.index = pos;\n err.lineNumber = loc.line;\n err.column = loc.column + 1; // acorn uses 0-based columns\n throw err;\n }\n\n /**\n * Overwrites the default raise method to throw Esprima-style errors.\n * @param {int} pos The position of the error.\n * @param {string} message The error message.\n * @throws {SyntaxError} A syntax error.\n * @returns {void}\n */\n raiseRecoverable(pos, message) {\n this.raise(pos, message);\n }\n\n /**\n * Overwrites the default unexpected method to throw Esprima-style errors.\n * @param {int} pos The position of the error.\n * @throws {SyntaxError} A syntax error.\n * @returns {void}\n */\n unexpected(pos) {\n let message = \"Unexpected token\";\n\n if (pos !== null && pos !== void 0) {\n this.pos = pos;\n\n if (this.options.locations) {\n while (this.pos < this.lineStart) {\n this.lineStart = this.input.lastIndexOf(\"\\n\", this.lineStart - 2) + 1;\n --this.curLine;\n }\n }\n\n this.nextToken();\n }\n\n if (this.end > this.start) {\n message += ` ${this.input.slice(this.start, this.end)}`;\n }\n\n this.raise(this.start, message);\n }\n\n /*\n * Esprima-FB represents JSX strings as tokens called \"JSXText\", but Acorn-JSX\n * uses regular tt.string without any distinction between this and regular JS\n * strings. As such, we intercept an attempt to read a JSX string and set a flag\n * on extra so that when tokens are converted, the next token will be switched\n * to JSXText via onToken.\n */\n jsx_readString(quote) { // eslint-disable-line camelcase\n const result = super.jsx_readString(quote);\n\n if (this.type === tokTypes.string) {\n this[STATE].jsxAttrValueToken = true;\n }\n return result;\n }\n\n /**\n * Performs last-minute Esprima-specific compatibility checks and fixes.\n * @param {ASTNode} result The node to check.\n * @returns {ASTNode} The finished node.\n */\n [ESPRIMA_FINISH_NODE](result) {\n\n // Acorn doesn't count the opening and closing backticks as part of templates\n // so we have to adjust ranges/locations appropriately.\n if (result.type === \"TemplateElement\") {\n\n // additional adjustment needed if ${ is the last token\n const terminalDollarBraceL = this.input.slice(result.end, result.end + 2) === \"${\";\n\n if (result.range) {\n result.range[0]--;\n result.range[1] += (terminalDollarBraceL ? 2 : 1);\n }\n\n if (result.loc) {\n result.loc.start.column--;\n result.loc.end.column += (terminalDollarBraceL ? 2 : 1);\n }\n }\n\n if (result.type.includes(\"Function\") && !result.generator) {\n result.generator = false;\n }\n\n return result;\n }\n };\n};\n","const version = \"main\";\n\nexport default version;\n","/**\n * @fileoverview Main Espree file that converts Acorn into Esprima output.\n *\n * This file contains code from the following MIT-licensed projects:\n * 1. Acorn\n * 2. Babylon\n * 3. Babel-ESLint\n *\n * This file also contains code from Esprima, which is BSD licensed.\n *\n * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)\n * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)\n * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie \n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n/* eslint no-undefined:0, no-use-before-define: 0 */\n\nimport * as acorn from \"acorn\";\nimport jsx from \"acorn-jsx\";\nimport astNodeTypes from \"./lib/ast-node-types.js\";\nimport espree from \"./lib/espree.js\";\nimport espreeVersion from \"./lib/version.js\";\nimport visitorKeys from \"eslint-visitor-keys\";\nimport { getLatestEcmaVersion, getSupportedEcmaVersions } from \"./lib/options.js\";\n\n\n// To initialize lazily.\nconst parsers = {\n _regular: null,\n _jsx: null,\n\n get regular() {\n if (this._regular === null) {\n this._regular = acorn.Parser.extend(espree());\n }\n return this._regular;\n },\n\n get jsx() {\n if (this._jsx === null) {\n this._jsx = acorn.Parser.extend(jsx(), espree());\n }\n return this._jsx;\n },\n\n get(options) {\n const useJsx = Boolean(\n options &&\n options.ecmaFeatures &&\n options.ecmaFeatures.jsx\n );\n\n return useJsx ? this.jsx : this.regular;\n }\n};\n\n//------------------------------------------------------------------------------\n// Tokenizer\n//------------------------------------------------------------------------------\n\n/**\n * Tokenizes the given code.\n * @param {string} code The code to tokenize.\n * @param {Object} options Options defining how to tokenize.\n * @returns {Token[]} An array of tokens.\n * @throws {SyntaxError} If the input code is invalid.\n * @private\n */\nexport function tokenize(code, options) {\n const Parser = parsers.get(options);\n\n // Ensure to collect tokens.\n if (!options || options.tokens !== true) {\n options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign\n }\n\n return new Parser(options, code).tokenize();\n}\n\n//------------------------------------------------------------------------------\n// Parser\n//------------------------------------------------------------------------------\n\n/**\n * Parses the given code.\n * @param {string} code The code to tokenize.\n * @param {Object} options Options defining how to tokenize.\n * @returns {ASTNode} The \"Program\" AST node.\n * @throws {SyntaxError} If the input code is invalid.\n */\nexport function parse(code, options) {\n const Parser = parsers.get(options);\n\n return new Parser(options, code).parse();\n}\n\n//------------------------------------------------------------------------------\n// Public\n//------------------------------------------------------------------------------\n\nexport const version = espreeVersion;\n\n\n// Deep copy.\n/* istanbul ignore next */\nexport const Syntax = (function() {\n let name,\n types = {};\n\n if (typeof Object.create === \"function\") {\n types = Object.create(null);\n }\n\n for (name in astNodeTypes) {\n if (Object.hasOwnProperty.call(astNodeTypes, name)) {\n types[name] = astNodeTypes[name];\n }\n }\n\n if (typeof Object.freeze === \"function\") {\n Object.freeze(types);\n }\n\n return types;\n}());\n\n/* istanbul ignore next */\nexport const VisitorKeys = (function() {\n return visitorKeys.KEYS;\n}());\n\nexport const latestEcmaVersion = getLatestEcmaVersion();\n\nexport const supportedEcmaVersions = getSupportedEcmaVersions();\n"],"names":["version","acorn","jsx","espreeVersion","visitorKeys"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAe;AACf,IAAI,oBAAoB,EAAE,sBAAsB;AAChD,IAAI,iBAAiB,EAAE,mBAAmB;AAC1C,IAAI,eAAe,EAAE,iBAAiB;AACtC,IAAI,YAAY,EAAE,cAAc;AAChC,IAAI,uBAAuB,EAAE,yBAAyB;AACtD,IAAI,eAAe,EAAE,iBAAiB;AACtC,IAAI,cAAc,EAAE,gBAAgB;AACpC,IAAI,gBAA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46c728a24ea112f5f7 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Fri, 7 May 2021 12:18:04 +0900 Subject: [PATCH 07/11] add npm prepare script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 083c614b..55aa7d5c 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "generate-alpharelease": "eslint-generate-prerelease alpha", "generate-betarelease": "eslint-generate-prerelease beta", "generate-rcrelease": "eslint-generate-prerelease rc", - "publish-release": "eslint-publish-release" + "publish-release": "eslint-publish-release", + "prepare": "npm run -s build" } } From efc6258c7161f621cc11cff14d4f1cbf77b4d9c2 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Fri, 7 May 2021 15:16:12 +0900 Subject: [PATCH 08/11] Update CONTRIBUTING.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 薛定谔的猫 --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 174e83ea..0705b5cd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ Our full contribution guidelines can be found at: 1. Update `acorn` package the upstream. 1. `npm install acorn@latest` -1. If a new `ecmaVersion` value is added, update `SUPPORTED_VERSIONS` constant in `lib/options.js` and tests in `tests\lib\supported-ecmaversions.js`. +1. If a new `ecmaVersion` value is added, update `SUPPORTED_VERSIONS` constant in `lib/options.js` and tests in `tests/lib/supported-ecmaversions.js`. 1. If new token types are added, update `lib/token-translator.js` file to translate the tokens. 1. Add tests in `tests/fixtures/ecma-version//`. - Add a directory named the new syntax name. From 0ec15806368746cd1058b69636657dc64ba6e232 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Fri, 7 May 2021 15:21:36 +0900 Subject: [PATCH 09/11] update CONTRIBUTING.md --- CONTRIBUTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0705b5cd..ad3692d7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,9 +7,8 @@ Please sign the [jQuery Foundation Contributor License Agreement](https://contri Our full contribution guidelines can be found at: -# How to update espree to support new syntax +# How to upgrade `acorn` to support new syntax -1. Update `acorn` package the upstream. 1. `npm install acorn@latest` 1. If a new `ecmaVersion` value is added, update `SUPPORTED_VERSIONS` constant in `lib/options.js` and tests in `tests/lib/supported-ecmaversions.js`. 1. If new token types are added, update `lib/token-translator.js` file to translate the tokens. From 0c620cd4a75c636346c0f9dc5329d60d48f9116f Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Sat, 8 May 2021 15:17:23 +0900 Subject: [PATCH 10/11] fix for JSON incompatible values --- tests/lib/tester-test.js | 139 ++++++++++++++++++++++ tests/lib/tester.js | 179 +++++++++++++++++++++++------ tools/update-ecma-version-tests.js | 28 +---- tools/update-tests.js | 19 +-- 4 files changed, 288 insertions(+), 77 deletions(-) create mode 100644 tests/lib/tester-test.js diff --git a/tests/lib/tester-test.js b/tests/lib/tester-test.js new file mode 100644 index 00000000..420c3ed8 --- /dev/null +++ b/tests/lib/tester-test.js @@ -0,0 +1,139 @@ +import assert from "assert"; +import tester from "./tester.js"; + +const { getRaw, getAstCode } = tester; + +describe("Tester", () => { + describe("getRaw", () => { + it("should remove `start` and `end` properties", () => { + assert.deepStrictEqual( + getRaw({ start: 0, end: 1, node: { start: 2, end: 3, value: 4 } }), + { node: { value: 4 } } + ); + }); + + it("should keep NaN", () => { + assert.deepStrictEqual( + getRaw({ value: NaN }), + { value: NaN } + ); + }); + + it("should keep Infinity", () => { + assert.deepStrictEqual( + getRaw({ value: Infinity }), + { value: Infinity } + ); + }); + + it("should keep -Infinity", () => { + assert.deepStrictEqual( + getRaw({ value: -Infinity }), + { value: -Infinity } + ); + }); + + it("should keep bigint values", () => { + assert.deepStrictEqual( + getRaw({ value: BigInt("123") }), + { value: BigInt("123") } + ); + }); + + it("should keep RegExp objects", () => { + assert.deepStrictEqual( + // eslint-disable-next-line require-unicode-regexp + getRaw({ value: /foo/ }), + // eslint-disable-next-line require-unicode-regexp + { value: /foo/ } + ); + assert.deepStrictEqual( + getRaw({ value: /foo/u }), + { value: /foo/u } + ); + + // check about escape sequences of `JSON.stringify`. + assert.deepStrictEqual( + getRaw({ value: /"foo"/u }), + { value: /"foo"/u } + ); + assert.deepStrictEqual( + getRaw({ value: /\d\/\d/u }), + { value: /\d\/\d/u } + ); + }); + }); + + describe("getAstCode", () => { + + /** + * Evaluate the generated code of `getAstCode` function with given code. + * @param {ASTNode} ast The AST node to test. + * @returns {ASTNode} The result of the evaluation of the generated code. + */ + function test(ast) { + const code = getAstCode(ast); + + // eslint-disable-next-line no-new-func + return Function(`return ${code};`)(); + } + + it("should remove `start` and `end` properties", () => { + assert.deepStrictEqual( + test({ start: 0, end: 1, node: { start: 2, end: 3, value: 4 } }), + { node: { value: 4 } } + ); + }); + + it("should keep NaN", () => { + assert.deepStrictEqual( + test({ value: NaN }), + { value: NaN } + ); + }); + + it("should keep Infinity", () => { + assert.deepStrictEqual( + test({ value: Infinity }), + { value: Infinity } + ); + }); + + it("should keep -Infinity", () => { + assert.deepStrictEqual( + test({ value: -Infinity }), + { value: -Infinity } + ); + }); + + it("should keep bigint values", () => { + assert.deepStrictEqual( + test({ value: BigInt("123") }), + { value: BigInt("123") } + ); + }); + + it("should keep RegExp objects", () => { + assert.deepStrictEqual( + // eslint-disable-next-line require-unicode-regexp + test({ value: /foo/ }), + // eslint-disable-next-line require-unicode-regexp + { value: /foo/ } + ); + assert.deepStrictEqual( + test({ value: /foo/u }), + { value: /foo/u } + ); + + // check about escape sequences of `JSON.stringify`. + assert.deepStrictEqual( + test({ value: /"foo"/u }), + { value: /"foo"/u } + ); + assert.deepStrictEqual( + test({ value: /\d\/\d/u }), + { value: /\d\/\d/u } + ); + }); + }); +}); diff --git a/tests/lib/tester.js b/tests/lib/tester.js index 83aa179f..4bbddd98 100644 --- a/tests/lib/tester.js +++ b/tests/lib/tester.js @@ -15,6 +15,115 @@ import * as espree from "../../espree.js"; // Private //------------------------------------------------------------------------------ +// Prefix to replace values. +// For example, a bigint value `1n` will be replaced by a string `"5f9c9d32_1n"`. +// Those prefixes merely are improbable values in test fixtures. +const Prefix = { + bigint: "5f9c9d32_", + number: "53b0a1b2_", + RegExp: "ca5db4fe_" +}; +const ReplacedStringLiteralPattern = new RegExp( + `"(${Object.values(Prefix).join("|")})([^\\n]*)"`, + "gu" +); + +/** + * Replace the values JSON cannot handle by strings. + * The `replaceToRestoreNonJSONValues` function restores the replaced values. + * @param {string} key The key to replace. + * @param {any} value The value to replace. + * @returns {any} If `value` parameter is a value JSON cannot handle, this + * function returns a string value. If `key` parameter is `"start"` or `"end"`, + * returns `undefined`. Otherwise, returns `value` parameter as is. + * @private + */ +function replaceToSaveNonJSONValues(key, value) { + + // Remove `start` and `end` properties because of non-standard. + if ((key === "start" || key === "end") && typeof value === "number") { + return undefined; // eslint-disable-line no-undefined + } + + // Save the values JSON cannot handle. + // The `value` property of `Literal` node can have those values. + switch (typeof value) { + case "bigint": + return `${Prefix.bigint}${value}n`; + case "number": + return Number.isFinite(value) ? value : `${Prefix.number}${value}`; + case "object": + return !(value instanceof RegExp) ? value : `${Prefix.RegExp}${value}`; + case "undefined": + throw new Error(`AST cannot have undefined as a property value.\nProperty name is '${key}'`); + default: + return value; + } +} + +/** + * Replace the values that the `replaceToSaveNonJSONValues` function replaced by the original values. + * @param {string} _key The key to replace. + * @param {any} value The value to replace. + * @returns {any} If `value` parameter is a replaced value, returns the restored + * value. Otherwise, returns `value` parameter as is. + * @private + */ +function replaceToRestoreNonJSONValues(_key, value) { + + // Restore the values JSON cannot handle. + if (typeof value === "string") { + if (value.startsWith(Prefix.number)) { + return Number(value.slice(Prefix.number.length)); + } + if (value.startsWith(Prefix.bigint)) { + return BigInt(value.slice(Prefix.bigint.length, -1)); + } + if (value.startsWith(Prefix.RegExp)) { + const regexpString = value.slice(Prefix.RegExp.length); + const i = regexpString.lastIndexOf("/"); + const pattern = regexpString.slice(1, i); + const flags = regexpString.slice(i + 1); + + return new RegExp(pattern, flags); + } + } + + return value; +} + +/** + * Convert the string literals that the `replaceToSaveNonJSONValues` function + * replaced to the JavaScript code of the original value. + * @param {string} jsCodeText The JavaScript code text to convert. + * @returns {string} The converted JavaScript code text. + * @private + */ +function restoreNonJSONValueLiterals(jsCodeText) { + return jsCodeText + .replace(/\u2028/gu, "\\u2028") // Maybe editors cannot handle U+2028 and U+2029 correctly. + .replace(/\u2029/gu, "\\u2029") + .replace(ReplacedStringLiteralPattern, (_, prefix, value) => { + if (prefix === Prefix.number) { + return value; // NaN, Infinity, or -Infinity + } + if (prefix === Prefix.bigint) { + return value; // bigint literals + } + if (prefix === Prefix.RegExp) { + + // TODO: Generate fallback code for the case that runtime didn't support syntax natively. + // Currently, Node.js of the minimum supported version supports all RegExp features. + // But new `d` flag is at Stage 3 and maybe it will need fallback code. + + // Parse it as a string literal for restoring escape sequences that `JSON.stringify` created. + return JSON.parse(`"${value}"`); + } + + throw new Error(`unreachable; unknown prefix ${prefix}`); + }); +} + /** * Gets a raw version of the AST that is suitable for comparison. This is necessary * due to the different order of properties across parsers. @@ -24,25 +133,39 @@ import * as espree from "../../espree.js"; */ function getRaw(ast) { return JSON.parse( - JSON.stringify(ast, (key, value) => { - if ((key === "start" || key === "end") && typeof value === "number") { - return undefined; // eslint-disable-line no-undefined - } + JSON.stringify(ast, replaceToSaveNonJSONValues), + replaceToRestoreNonJSONValues + ); +} - // JSON cannot handle BigInt. - if (typeof value === "bigint") { - return `$$BIGINT$$${value}`; - } +/** + * Gets a JavaScript code that generates a given AST node object. + * @param {ASTNode} ast The AST to convert. + * @returns {string} The JavaScript code that generates `ast` object. + */ +function getAstCode(ast) { + return restoreNonJSONValueLiterals( + JSON.stringify(ast, replaceToSaveNonJSONValues, 4) + ); +} - return value; - }), - (_key, value) => { - if (typeof value === "string" && value.startsWith("$$BIGINT$$")) { - return BigInt(value.slice("$$BIGINT$$".length)); - } - return value; +/** + * Parse and normalzie a JavaScript code. + * @param {string} jsCodeText The JavaScript code to parse. + * @param {Object} parserOptions The parser options to parse. + * @param {Object} [options] The options. + * @param {boolean} [options.rethrowSyntaxError = false] The flag to rethrow syntax errors. + * @returns {Object} The normalized AST. + */ +function getExpectedResult(jsCodeText, parserOptions, { rethrowSyntaxError = false } = {}) { + try { + return getRaw(espree.parse(jsCodeText, parserOptions)); + } catch (ex) { + if (rethrowSyntaxError) { + throw ex; } - ); + return { ...getRaw(ex), message: ex.message }; + } } //------------------------------------------------------------------------------ @@ -51,25 +174,13 @@ function getRaw(ast) { export default { getRaw, + getAstCode, + getExpectedResult, assertMatches(code, config, expected) { - let result; - - try { - result = espree.parse(code, config); - result = getRaw(result); - } catch (ex) { - - // if the result is an error, create an error object so deepEqual works - if (expected.message || expected.description) { - result = getRaw(ex); - result.message = ex.message; - } else { - throw ex; - } - - } - - assert.deepStrictEqual(result, getRaw(expected)); + assert.deepStrictEqual( + getExpectedResult(code, config, { rethrowSyntaxError: !expected.message }), + getRaw(expected) + ); } }; diff --git a/tools/update-ecma-version-tests.js b/tools/update-ecma-version-tests.js index 6ef96efd..2b002298 100644 --- a/tools/update-ecma-version-tests.js +++ b/tools/update-ecma-version-tests.js @@ -17,30 +17,12 @@ import path from "path"; import { fileURLToPath } from "url"; import util from "util"; import shelljs from "shelljs"; -import * as espree from "../espree.js"; import tester from "../tests/lib/tester.js"; //------------------------------------------------------------------------------ // Helpers //------------------------------------------------------------------------------ -/** - * Get the parse result. - * @param {string} code The source code to get. - * @param {Object} config The espree options. - * @returns {string} The parse result. - */ -function getExpectedResult(code, config) { - try { - return tester.getRaw(espree.parse(code, config)); - } catch (ex) { - const raw = tester.getRaw(ex); - - raw.message = ex.message; - return raw; - } -} - /** * Find the test cases from a given directory. * Tests are the name of files that end with `.src.js`. @@ -60,11 +42,7 @@ function findTests(directory) { * @returns {void} */ function outputResult(result, testResultFilename) { - let code = `export default ${JSON.stringify(result, (key, value) => ((typeof value === "bigint") ? `bigint<${value}n>` : value), 4)};`; - - code = code.replace(/"bigint<(\d+n)>"/gu, "$1"); - - code.to(testResultFilename); + `export default ${tester.getAstCode(result)};`.to(testResultFilename); } /** @@ -111,10 +89,10 @@ function main() { }; const scriptResult = moduleOnly ? null - : getExpectedResult(code, { ...parserOptions, sourceType: "script" }); + : tester.getExpectedResult(code, { ...parserOptions, sourceType: "script" }); const moduleResult = scriptOnly ? null - : getExpectedResult(code, { ...parserOptions, sourceType: "module" }); + : tester.getExpectedResult(code, { ...parserOptions, sourceType: "module" }); const resultsAreSame = util.isDeepStrictEqual( { ...scriptResult, sourceType: null }, { ...moduleResult, sourceType: null } diff --git a/tools/update-tests.js b/tools/update-tests.js index 3d54ef6c..2957255f 100644 --- a/tools/update-tests.js +++ b/tools/update-tests.js @@ -13,7 +13,6 @@ //------------------------------------------------------------------------------ import shelljs from "shelljs"; -import * as espree from "../espree.js"; import tester from "../tests/lib/tester.js"; import path from "path"; import { fileURLToPath } from "url"; @@ -24,16 +23,6 @@ import { fileURLToPath } from "url"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -function getExpectedResult(code, config) { - try { - return tester.getRaw(espree.parse(code, config)); - } catch (ex) { - var raw = tester.getRaw(ex); - raw.message = ex.message; - return raw; - } -} - function getTestFilenames(directory) { return shelljs.find(directory).filter(function(filename) { return filename.indexOf(".src.js") > -1; @@ -51,13 +40,7 @@ function getLibraryFilenames(directory) { } function outputResult(result, testResultFilename) { - let code = `export default ${JSON.stringify(result, (key, value) => { - return (typeof value === "bigint") ? `bigint<${value}n>` : value; - }, 4)};`; - - code = code.replace(/"bigint<(\d+n)>"/g, "$1"); - - code.to(testResultFilename); + `export default ${tester.getAstCode(result)};`.to(testResultFilename); } //------------------------------------------------------------------------------ From c2f84d698bcefd5354f4fe4347e4b77c5f10cb7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E8=B0=94=E7=9A=84=E7=8C=AB?= Date: Wed, 2 Jun 2021 12:07:03 +0800 Subject: [PATCH 11/11] Apply suggestions from code review --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index caf917ed..568b83ac 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,6 @@ "generate-alpharelease": "eslint-generate-prerelease alpha", "generate-betarelease": "eslint-generate-prerelease beta", "generate-rcrelease": "eslint-generate-prerelease rc", - "publish-release": "eslint-publish-release", - "prepare": "npm run -s build" + "publish-release": "eslint-publish-release" } }