From becd1f8581c0013399dfe71be6c265e96cedb57a Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Mon, 28 Nov 2022 11:16:50 +0900 Subject: [PATCH] feat: support Auto Accessor syntax (#5926) Co-authored-by: Brad Zacher --- .prettierignore | 3 + packages/ast-spec/src/ast-node-types.ts | 2 + .../kind-type/snapshots/1-TSESTree-AST.shot | 48 ---- .../snapshots/2-TSESTree-Tokens.shot | 86 ------- .../assertion/snapshots/1-TSESTree-AST.shot | 102 -------- .../snapshots/2-TSESTree-Tokens.shot | 136 ----------- .../assertion/snapshots/3-Babel-AST.shot | 102 -------- .../assertion/snapshots/4-Babel-Tokens.shot | 136 ----------- .../async/snapshots/1-TSESTree-AST.shot | 40 ---- .../async/snapshots/2-TSESTree-Tokens.shot | 76 ------ .../_error_/modifier-declare/fixture.ts | 3 + .../snapshots/1-TSESTree-Error.shot | 3 + .../snapshots/2-Babel-Error.shot | 3 + .../snapshots/3-Alignment-Error.shot | 3 + .../fixture.ts | 3 + .../snapshots/1-TSESTree-Error.shot | 3 + .../snapshots/2-Babel-Error.shot | 3 + .../snapshots/3-Alignment-Error.shot | 3 + .../fixtures/key-computed-complex/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 82 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 96 ++++++++ .../snapshots/3-Babel-AST.shot | 80 +++++++ .../snapshots/4-Babel-Tokens.shot | 96 ++++++++ .../snapshots/5-AST-Alignment-AST.shot | 88 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixtures/key-computed-number/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 82 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 116 +++++++++ .../snapshots/3-Babel-AST.shot | 80 +++++++ .../snapshots/4-Babel-Tokens.shot | 116 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 88 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 2 +- .../fixtures/key-computed-string/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 82 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 116 +++++++++ .../snapshots/3-Babel-AST.shot | 80 +++++++ .../snapshots/4-Babel-Tokens.shot | 116 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 88 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixtures/key-number/fixture.ts | 0 .../key-number/snapshots/1-TSESTree-AST.shot | 15 ++ .../snapshots/2-TSESTree-Tokens.shot | 3 + .../key-number/snapshots/3-Babel-AST.shot | 15 ++ .../key-number/snapshots/4-Babel-Tokens.shot | 3 + .../snapshots/5-AST-Alignment-AST.shot | 2 +- .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixtures/key-private/fixture.ts | 3 + .../key-private/snapshots/1-TSESTree-AST.shot | 81 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 96 ++++++++ .../key-private/snapshots/3-Babel-AST.shot | 79 +++++++ .../key-private/snapshots/4-Babel-Tokens.shot | 96 ++++++++ .../snapshots/5-AST-Alignment-AST.shot | 87 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 103 ++++++++ .../fixtures/key-string/fixture.ts | 3 + .../key-string/snapshots/1-TSESTree-AST.shot | 82 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 96 ++++++++ .../key-string/snapshots/3-Babel-AST.shot | 80 +++++++ .../key-string/snapshots/4-Babel-Tokens.shot | 96 ++++++++ .../snapshots/5-AST-Alignment-AST.shot | 88 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../modifier-abstract-with-value/config.ts | 3 + .../modifier-abstract-with-value/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 90 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 136 +++++++++++ .../snapshots/3-Babel-Error.shot | 3 + .../fixtures/modifier-abstract/config.ts | 3 + .../fixtures/modifier-abstract/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 90 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 116 +++++++++ .../snapshots/3-Babel-Error.shot | 3 + .../fixtures/modifier-override/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 90 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 126 ++++++++++ .../snapshots/3-Babel-AST.shot | 89 +++++++ .../snapshots/4-Babel-Tokens.shot | 126 ++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 96 ++++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixtures/modifier-private/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 82 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 106 +++++++++ .../snapshots/3-Babel-AST.shot | 80 +++++++ .../snapshots/4-Babel-Tokens.shot | 106 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 88 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 112 +++++++++ .../fixtures/modifier-protected/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 82 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 106 +++++++++ .../snapshots/3-Babel-AST.shot | 80 +++++++ .../snapshots/4-Babel-Tokens.shot | 106 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 88 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 112 +++++++++ .../fixtures/modifier-public/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 82 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 106 +++++++++ .../snapshots/3-Babel-AST.shot | 80 +++++++ .../snapshots/4-Babel-Tokens.shot | 106 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 88 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 112 +++++++++ .../fixtures/modifier-readonly/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 82 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 106 +++++++++ .../snapshots/3-Babel-AST.shot | 80 +++++++ .../snapshots/4-Babel-Tokens.shot | 106 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 88 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixtures/modifier-static/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 81 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 106 +++++++++ .../snapshots/3-Babel-AST.shot | 79 +++++++ .../snapshots/4-Babel-Tokens.shot | 106 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 87 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../no-annotation-no-value/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 71 ++++++ .../snapshots/2-TSESTree-Tokens.shot | 76 ++++++ .../snapshots/3-Babel-AST.shot | 69 ++++++ .../snapshots/4-Babel-Tokens.shot | 76 ++++++ .../snapshots/5-AST-Alignment-AST.shot | 77 ++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../no-annotation-with-value/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 81 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 96 ++++++++ .../snapshots/3-Babel-AST.shot | 79 +++++++ .../snapshots/4-Babel-Tokens.shot | 96 ++++++++ .../snapshots/5-AST-Alignment-AST.shot | 87 +++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../with-annotation-no-value/config.ts | 3 + .../with-annotation-no-value/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 89 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 96 ++++++++ .../snapshots/3-Babel-Error.shot | 3 + .../with-annotation-with-value/config.ts | 3 + .../with-annotation-with-value/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 99 ++++++++ .../snapshots/2-TSESTree-Tokens.shot | 116 +++++++++ .../snapshots/3-Babel-Error.shot | 3 + .../src/element/AccessorProperty/spec.ts | 19 ++ .../TSAbstractAccessorProperty/spec.ts | 22 ++ packages/ast-spec/src/element/spec.ts | 2 + packages/ast-spec/src/unions/ClassElement.ts | 4 + packages/ast-spec/src/unions/Node.ts | 4 + .../tests/fixtures-with-differences-ast.shot | 13 ++ .../fixtures-with-differences-errors.shot | 2 + .../fixtures-with-differences-tokens.shot | 4 + .../tests/fixtures-without-babel-support.shot | 10 + packages/ast-spec/tests/fixtures.test.ts | 200 ++++++++++------ packages/ast-spec/tests/util/parsers/babel.ts | 1 + .../tests/util/parsers/parser-types.ts | 17 +- packages/ast-spec/tsconfig.json | 11 +- packages/ast-spec/typings/global.d.ts | 14 ++ .../src/referencer/ClassVisitor.ts | 34 ++- .../declaration/abstract-accessor-property.ts | 5 + .../abstract-accessor-property.ts.shot | 88 +++++++ .../accessor-property-type-annotation.ts | 4 + .../accessor-property-type-annotation.ts.shot | 88 +++++++ .../class/declaration/accessor-property.ts | 7 + .../declaration/accessor-property.ts.shot | 152 ++++++++++++ packages/typescript-estree/src/convert.ts | 26 ++- .../src/ts-estree/estree-to-ts-node-types.ts | 2 + packages/visitor-keys/src/visitor-keys.ts | 221 +++++++++++++----- 160 files changed, 8205 insertions(+), 869 deletions(-) delete mode 100644 packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-AST.shot delete mode 100644 packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-TSESTree-Tokens.shot delete mode 100644 packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/1-TSESTree-AST.shot delete mode 100644 packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/2-TSESTree-Tokens.shot delete mode 100644 packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/3-Babel-AST.shot delete mode 100644 packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/4-Babel-Tokens.shot delete mode 100644 packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-AST.shot delete mode 100644 packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/1-TSESTree-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/2-Babel-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/3-Alignment-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/1-TSESTree-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/2-Babel-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/3-Alignment-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/5-AST-Alignment-AST.shot rename packages/ast-spec/src/{declaration/ExportNamedDeclaration/fixtures/_error_/assertion => element/AccessorProperty/fixtures/key-computed-number}/snapshots/6-AST-Alignment-Tokens.shot (52%) create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/4-Babel-Tokens.shot rename packages/ast-spec/src/{declaration/ExportNamedDeclaration/fixtures/_error_/assertion => element/AccessorProperty/fixtures/key-number}/snapshots/5-AST-Alignment-AST.shot (52%) create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/config.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/3-Babel-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/config.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/3-Babel-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/config.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/3-Babel-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/config.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/fixture.ts create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/3-Babel-Error.shot create mode 100644 packages/ast-spec/src/element/AccessorProperty/spec.ts create mode 100644 packages/ast-spec/src/element/TSAbstractAccessorProperty/spec.ts create mode 100644 packages/ast-spec/tests/fixtures-without-babel-support.shot create mode 100644 packages/ast-spec/typings/global.d.ts create mode 100644 packages/scope-manager/tests/fixtures/class/declaration/abstract-accessor-property.ts create mode 100644 packages/scope-manager/tests/fixtures/class/declaration/abstract-accessor-property.ts.shot create mode 100644 packages/scope-manager/tests/fixtures/class/declaration/accessor-property-type-annotation.ts create mode 100644 packages/scope-manager/tests/fixtures/class/declaration/accessor-property-type-annotation.ts.shot create mode 100644 packages/scope-manager/tests/fixtures/class/declaration/accessor-property.ts create mode 100644 packages/scope-manager/tests/fixtures/class/declaration/accessor-property.ts.shot diff --git a/.prettierignore b/.prettierignore index 637f32f77bf..edaa57ceac4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -12,6 +12,9 @@ packages/eslint-plugin/src/configs/*.json CONTRIBUTORS.md packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts +# prettier doesn't yet support auto-accessors +packages/ast-spec/src/element/AccessorProperty/fixtures + # Ignore CHANGELOG.md files to avoid issues with automated release job CHANGELOG.md diff --git a/packages/ast-spec/src/ast-node-types.ts b/packages/ast-spec/src/ast-node-types.ts index dbed6723fed..7a637489eb0 100644 --- a/packages/ast-spec/src/ast-node-types.ts +++ b/packages/ast-spec/src/ast-node-types.ts @@ -1,4 +1,5 @@ export enum AST_NODE_TYPES { + AccessorProperty = 'AccessorProperty', ArrayExpression = 'ArrayExpression', ArrayPattern = 'ArrayPattern', ArrowFunctionExpression = 'ArrowFunctionExpression', @@ -90,6 +91,7 @@ export enum AST_NODE_TYPES { /** * TS-prefixed nodes */ + TSAbstractAccessorProperty = 'TSAbstractAccessorProperty', TSAbstractKeyword = 'TSAbstractKeyword', TSAbstractMethodDefinition = 'TSAbstractMethodDefinition', TSAbstractPropertyDefinition = 'TSAbstractPropertyDefinition', diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-AST.shot deleted file mode 100644 index 4e1ab2405d4..00000000000 --- a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-AST.shot +++ /dev/null @@ -1,48 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ExportAllDeclaration kind-type TSESTree - AST 1`] = ` -Program { - type: "Program", - body: Array [ - ExportAllDeclaration { - type: "ExportAllDeclaration", - assertions: Array [], - exported: Identifier { - type: "Identifier", - name: "x", - - range: [17, 18], - loc: { - start: { column: 17, line: 1 }, - end: { column: 18, line: 1 }, - }, - }, - exportKind: "type", - source: Literal { - type: "Literal", - raw: "'a'", - value: "a", - - range: [24, 27], - loc: { - start: { column: 24, line: 1 }, - end: { column: 27, line: 1 }, - }, - }, - - range: [0, 28], - loc: { - start: { column: 0, line: 1 }, - end: { column: 28, line: 1 }, - }, - }, - ], - sourceType: "module", - - range: [0, 29], - loc: { - start: { column: 0, line: 1 }, - end: { column: 0, line: 2 }, - }, -} -`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-TSESTree-Tokens.shot deleted file mode 100644 index f5bfa8f5615..00000000000 --- a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-TSESTree-Tokens.shot +++ /dev/null @@ -1,86 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ExportAllDeclaration kind-type TSESTree - Tokens 1`] = ` -Array [ - Keyword { - type: "Keyword", - value: "export", - - range: [0, 6], - loc: { - start: { column: 0, line: 1 }, - end: { column: 6, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [7, 11], - loc: { - start: { column: 7, line: 1 }, - end: { column: 11, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "*", - - range: [12, 13], - loc: { - start: { column: 12, line: 1 }, - end: { column: 13, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "as", - - range: [14, 16], - loc: { - start: { column: 14, line: 1 }, - end: { column: 16, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "x", - - range: [17, 18], - loc: { - start: { column: 17, line: 1 }, - end: { column: 18, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "from", - - range: [19, 23], - loc: { - start: { column: 19, line: 1 }, - end: { column: 23, line: 1 }, - }, - }, - String { - type: "String", - value: "'a'", - - range: [24, 27], - loc: { - start: { column: 24, line: 1 }, - end: { column: 27, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [27, 28], - loc: { - start: { column: 27, line: 1 }, - end: { column: 28, line: 1 }, - }, - }, -] -`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/1-TSESTree-AST.shot deleted file mode 100644 index 9136ca295cb..00000000000 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/1-TSESTree-AST.shot +++ /dev/null @@ -1,102 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ExportNamedDeclaration assertion TSESTree - AST 1`] = ` -Program { - type: "Program", - body: Array [ - ExportNamedDeclaration { - type: "ExportNamedDeclaration", - assertions: Array [ - ImportAttribute { - type: "ImportAttribute", - key: Identifier { - type: "Identifier", - name: "type", - - range: [35, 39], - loc: { - start: { column: 35, line: 1 }, - end: { column: 39, line: 1 }, - }, - }, - value: Literal { - type: "Literal", - raw: "'json'", - value: "json", - - range: [41, 47], - loc: { - start: { column: 41, line: 1 }, - end: { column: 47, line: 1 }, - }, - }, - - range: [35, 47], - loc: { - start: { column: 35, line: 1 }, - end: { column: 47, line: 1 }, - }, - }, - ], - declaration: null, - exportKind: "value", - source: Literal { - type: "Literal", - raw: "'mod'", - value: "mod", - - range: [20, 25], - loc: { - start: { column: 20, line: 1 }, - end: { column: 25, line: 1 }, - }, - }, - specifiers: Array [ - ExportSpecifier { - type: "ExportSpecifier", - exported: Identifier { - type: "Identifier", - name: "foo", - - range: [9, 12], - loc: { - start: { column: 9, line: 1 }, - end: { column: 12, line: 1 }, - }, - }, - exportKind: "value", - local: Identifier { - type: "Identifier", - name: "foo", - - range: [9, 12], - loc: { - start: { column: 9, line: 1 }, - end: { column: 12, line: 1 }, - }, - }, - - range: [9, 12], - loc: { - start: { column: 9, line: 1 }, - end: { column: 12, line: 1 }, - }, - }, - ], - - range: [0, 50], - loc: { - start: { column: 0, line: 1 }, - end: { column: 50, line: 1 }, - }, - }, - ], - sourceType: "module", - - range: [0, 51], - loc: { - start: { column: 0, line: 1 }, - end: { column: 0, line: 2 }, - }, -} -`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/2-TSESTree-Tokens.shot deleted file mode 100644 index 9a30eb2745c..00000000000 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/2-TSESTree-Tokens.shot +++ /dev/null @@ -1,136 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ExportNamedDeclaration assertion TSESTree - Tokens 1`] = ` -Array [ - Keyword { - type: "Keyword", - value: "export", - - range: [0, 6], - loc: { - start: { column: 0, line: 1 }, - end: { column: 6, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [7, 8], - loc: { - start: { column: 7, line: 1 }, - end: { column: 8, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "foo", - - range: [9, 12], - loc: { - start: { column: 9, line: 1 }, - end: { column: 12, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [13, 14], - loc: { - start: { column: 13, line: 1 }, - end: { column: 14, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "from", - - range: [15, 19], - loc: { - start: { column: 15, line: 1 }, - end: { column: 19, line: 1 }, - }, - }, - String { - type: "String", - value: "'mod'", - - range: [20, 25], - loc: { - start: { column: 20, line: 1 }, - end: { column: 25, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "assert", - - range: [26, 32], - loc: { - start: { column: 26, line: 1 }, - end: { column: 32, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [33, 34], - loc: { - start: { column: 33, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [35, 39], - loc: { - start: { column: 35, line: 1 }, - end: { column: 39, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [39, 40], - loc: { - start: { column: 39, line: 1 }, - end: { column: 40, line: 1 }, - }, - }, - String { - type: "String", - value: "'json'", - - range: [41, 47], - loc: { - start: { column: 41, line: 1 }, - end: { column: 47, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [48, 49], - loc: { - start: { column: 48, line: 1 }, - end: { column: 49, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [49, 50], - loc: { - start: { column: 49, line: 1 }, - end: { column: 50, line: 1 }, - }, - }, -] -`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/3-Babel-AST.shot deleted file mode 100644 index b2ee980389e..00000000000 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/3-Babel-AST.shot +++ /dev/null @@ -1,102 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ExportNamedDeclaration assertion Babel - AST 1`] = ` -Program { - type: "Program", - body: Array [ - ExportNamedDeclaration { - type: "ExportNamedDeclaration", - assertions: Array [ - ImportAttribute { - type: "ImportAttribute", - key: Identifier { - type: "Identifier", - name: "type", - - range: [35, 39], - loc: { - start: { column: 35, line: 1 }, - end: { column: 39, line: 1 }, - }, - }, - value: Literal { - type: "Literal", - raw: "'json'", - value: "json", - - range: [41, 47], - loc: { - start: { column: 41, line: 1 }, - end: { column: 47, line: 1 }, - }, - }, - - range: [35, 47], - loc: { - start: { column: 35, line: 1 }, - end: { column: 47, line: 1 }, - }, - }, - ], - declaration: null, - exportKind: "value", - source: Literal { - type: "Literal", - raw: "'mod'", - value: "mod", - - range: [20, 25], - loc: { - start: { column: 20, line: 1 }, - end: { column: 25, line: 1 }, - }, - }, - specifiers: Array [ - ExportSpecifier { - type: "ExportSpecifier", - exported: Identifier { - type: "Identifier", - name: "foo", - - range: [9, 12], - loc: { - start: { column: 9, line: 1 }, - end: { column: 12, line: 1 }, - }, - }, - exportKind: "value", - local: Identifier { - type: "Identifier", - name: "foo", - - range: [9, 12], - loc: { - start: { column: 9, line: 1 }, - end: { column: 12, line: 1 }, - }, - }, - - range: [9, 12], - loc: { - start: { column: 9, line: 1 }, - end: { column: 12, line: 1 }, - }, - }, - ], - - range: [0, 50], - loc: { - start: { column: 0, line: 1 }, - end: { column: 50, line: 1 }, - }, - }, - ], - sourceType: "module", - - range: [0, 51], - loc: { - start: { column: 0, line: 1 }, - end: { column: 0, line: 2 }, - }, -} -`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/4-Babel-Tokens.shot deleted file mode 100644 index 95aa314bf6b..00000000000 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/4-Babel-Tokens.shot +++ /dev/null @@ -1,136 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ExportNamedDeclaration assertion Babel - Tokens 1`] = ` -Array [ - Keyword { - type: "Keyword", - value: "export", - - range: [0, 6], - loc: { - start: { column: 0, line: 1 }, - end: { column: 6, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [7, 8], - loc: { - start: { column: 7, line: 1 }, - end: { column: 8, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "foo", - - range: [9, 12], - loc: { - start: { column: 9, line: 1 }, - end: { column: 12, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [13, 14], - loc: { - start: { column: 13, line: 1 }, - end: { column: 14, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "from", - - range: [15, 19], - loc: { - start: { column: 15, line: 1 }, - end: { column: 19, line: 1 }, - }, - }, - String { - type: "String", - value: "'mod'", - - range: [20, 25], - loc: { - start: { column: 20, line: 1 }, - end: { column: 25, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "assert", - - range: [26, 32], - loc: { - start: { column: 26, line: 1 }, - end: { column: 32, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [33, 34], - loc: { - start: { column: 33, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [35, 39], - loc: { - start: { column: 35, line: 1 }, - end: { column: 39, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [39, 40], - loc: { - start: { column: 39, line: 1 }, - end: { column: 40, line: 1 }, - }, - }, - String { - type: "String", - value: "'json'", - - range: [41, 47], - loc: { - start: { column: 41, line: 1 }, - end: { column: 47, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [48, 49], - loc: { - start: { column: 48, line: 1 }, - end: { column: 49, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [49, 50], - loc: { - start: { column: 49, line: 1 }, - end: { column: 50, line: 1 }, - }, - }, -] -`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-AST.shot deleted file mode 100644 index d01382249a1..00000000000 --- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-AST.shot +++ /dev/null @@ -1,40 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration TSDeclareFunction async TSESTree - AST 1`] = ` -Program { - type: "Program", - body: Array [ - TSDeclareFunction { - type: "TSDeclareFunction", - async: true, - declare: true, - expression: false, - generator: false, - id: Identifier { - type: "Identifier", - name: "foo", - - range: [23, 26], - loc: { - start: { column: 23, line: 1 }, - end: { column: 26, line: 1 }, - }, - }, - params: Array [], - - range: [0, 29], - loc: { - start: { column: 0, line: 1 }, - end: { column: 29, line: 1 }, - }, - }, - ], - sourceType: "script", - - range: [0, 30], - loc: { - start: { column: 0, line: 1 }, - end: { column: 0, line: 2 }, - }, -} -`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-TSESTree-Tokens.shot deleted file mode 100644 index 57b56f38b08..00000000000 --- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-TSESTree-Tokens.shot +++ /dev/null @@ -1,76 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration TSDeclareFunction async TSESTree - Tokens 1`] = ` -Array [ - Identifier { - type: "Identifier", - value: "declare", - - range: [0, 7], - loc: { - start: { column: 0, line: 1 }, - end: { column: 7, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "async", - - range: [8, 13], - loc: { - start: { column: 8, line: 1 }, - end: { column: 13, line: 1 }, - }, - }, - Keyword { - type: "Keyword", - value: "function", - - range: [14, 22], - loc: { - start: { column: 14, line: 1 }, - end: { column: 22, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "foo", - - range: [23, 26], - loc: { - start: { column: 23, line: 1 }, - end: { column: 26, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "(", - - range: [26, 27], - loc: { - start: { column: 26, line: 1 }, - end: { column: 27, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ")", - - range: [27, 28], - loc: { - start: { column: 27, line: 1 }, - end: { column: 28, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [28, 29], - loc: { - start: { column: 28, line: 1 }, - end: { column: 29, line: 1 }, - }, - }, -] -`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/fixture.ts new file mode 100644 index 00000000000..2a4248c0bf8 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + declare accessor foo: number; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..e9efe0512eb --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty _error_ modifier-declare TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..7d44c5a9712 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty _error_ modifier-declare Babel - Error 1`] = `[SyntaxError: Missing semicolon. (2:22)]`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..a6fbd60e31c --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-declare/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty _error_ modifier-declare Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/fixture.ts new file mode 100644 index 00000000000..3369657d82b --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + override accessor foo = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..e1f58f42d42 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty _error_ modifier-override-with-no-extends TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..071d521919f --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty _error_ modifier-override-with-no-extends Babel - Error 1`] = `[SyntaxError: This member cannot have an 'override' modifier because its containing class does not extend another class. (2:2)]`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..27d6eef74b0 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty _error_ modifier-override-with-no-extends Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/fixture.ts new file mode 100644 index 00000000000..5dc28758b4e --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor 1 = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..00745c8a8d3 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-complex TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [23, 24], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + override: false, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + + range: [14, 29], + loc: { + start: { column: 2, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + ], + + range: [10, 31], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..97c056640e7 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-complex TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [23, 24], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [25, 26], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [28, 29], + loc: { + start: { column: 16, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..e52653f4094 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/3-Babel-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-complex Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: false, + key: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [23, 24], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + + range: [14, 29], + loc: { + start: { column: 2, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + ], + + range: [10, 31], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..651eb331471 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-complex Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [23, 24], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [25, 26], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [28, 29], + loc: { + start: { column: 16, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..b6b30dd18c6 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-complex AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: false, +- declare: false, + key: Literal { + type: 'Literal', + raw: '1', + value: 1, + + range: [23, 24], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, +- override: false, + static: false, + value: Literal { + type: 'Literal', + raw: '2', + value: 2, + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + + range: [14, 29], + loc: { + start: { column: 2, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + ], + + range: [10, 31], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..8375156efe1 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-complex AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/fixture.ts new file mode 100644 index 00000000000..e6eb4123594 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor [1] = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..abb1554d8a2 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-number TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + key: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [24, 25], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + override: false, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [29, 30], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + + range: [14, 31], + loc: { + start: { column: 2, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + ], + + range: [10, 33], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..d12fe10489e --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-number TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [23, 24], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [24, 25], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [25, 26], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [29, 30], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [32, 33], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..69de24d530d --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/3-Babel-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-number Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: true, + key: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [24, 25], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [29, 30], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + + range: [14, 31], + loc: { + start: { column: 2, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + ], + + range: [10, 33], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..e2dd78f3f2f --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-number Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [23, 24], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [24, 25], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [25, 26], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [29, 30], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [32, 33], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..bd3b115af80 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-number AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: true, +- declare: false, + key: Literal { + type: 'Literal', + raw: '1', + value: 1, + + range: [24, 25], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, +- override: false, + static: false, + value: Literal { + type: 'Literal', + raw: '2', + value: 2, + + range: [29, 30], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + + range: [14, 31], + loc: { + start: { column: 2, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + ], + + range: [10, 33], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/6-AST-Alignment-Tokens.shot similarity index 52% rename from packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/6-AST-Alignment-Tokens.shot rename to packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/6-AST-Alignment-Tokens.shot index dade8ee29e7..2243b91ca2e 100644 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-number/snapshots/6-AST-Alignment-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ExportNamedDeclaration assertion AST Alignment - Token 1`] = ` +exports[`AST Fixtures element AccessorProperty key-computed-number AST Alignment - Token 1`] = ` "Snapshot Diff: Compared values have no visual difference." `; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/fixture.ts new file mode 100644 index 00000000000..feb7a8c14ce --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor ['prop'] = 'value'; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..24de40f9aae --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-string TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + key: Literal { + type: "Literal", + raw: "'prop'", + value: "prop", + + range: [24, 30], + loc: { + start: { column: 12, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + override: false, + static: false, + value: Literal { + type: "Literal", + raw: "'value'", + value: "value", + + range: [34, 41], + loc: { + start: { column: 22, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + + range: [14, 42], + loc: { + start: { column: 2, line: 2 }, + end: { column: 30, line: 2 }, + }, + }, + ], + + range: [10, 44], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 44], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 45], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..9b1fd979379 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-string TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [23, 24], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + String { + type: "String", + value: "'prop'", + + range: [24, 30], + loc: { + start: { column: 12, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [32, 33], + loc: { + start: { column: 20, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + String { + type: "String", + value: "'value'", + + range: [34, 41], + loc: { + start: { column: 22, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [41, 42], + loc: { + start: { column: 29, line: 2 }, + end: { column: 30, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [43, 44], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..d8b18a55910 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/3-Babel-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-string Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: true, + key: Literal { + type: "Literal", + raw: "'prop'", + value: "prop", + + range: [24, 30], + loc: { + start: { column: 12, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + static: false, + value: Literal { + type: "Literal", + raw: "'value'", + value: "value", + + range: [34, 41], + loc: { + start: { column: 22, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + + range: [14, 42], + loc: { + start: { column: 2, line: 2 }, + end: { column: 30, line: 2 }, + }, + }, + ], + + range: [10, 44], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 44], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 45], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..29da5db3884 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-string Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [23, 24], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + String { + type: "String", + value: "'prop'", + + range: [24, 30], + loc: { + start: { column: 12, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [32, 33], + loc: { + start: { column: 20, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + String { + type: "String", + value: "'value'", + + range: [34, 41], + loc: { + start: { column: 22, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [41, 42], + loc: { + start: { column: 29, line: 2 }, + end: { column: 30, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [43, 44], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..3ca8eaf26ea --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-string AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: true, +- declare: false, + key: Literal { + type: 'Literal', + raw: '\\\\'prop\\\\'', + value: 'prop', + + range: [24, 30], + loc: { + start: { column: 12, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, +- override: false, + static: false, + value: Literal { + type: 'Literal', + raw: '\\\\'value\\\\'', + value: 'value', + + range: [34, 41], + loc: { + start: { column: 22, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + + range: [14, 42], + loc: { + start: { column: 2, line: 2 }, + end: { column: 30, line: 2 }, + }, + }, + ], + + range: [10, 44], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 44], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 45], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..628cbb97adb --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-string/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-computed-string AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/fixture.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..40d09186f6d --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-number TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [], + sourceType: "script", + + range: [0, 0], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 1 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..ea5732d8dee --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-number TSESTree - Tokens 1`] = `Array []`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..c3c65ccd7f8 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/3-Babel-AST.shot @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-number Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [], + sourceType: "script", + + range: [0, 0], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 1 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..75ca02a990c --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-number Babel - Tokens 1`] = `Array []`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/5-AST-Alignment-AST.shot similarity index 52% rename from packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/5-AST-Alignment-AST.shot rename to packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/5-AST-Alignment-AST.shot index 258519a7adf..55fd7a3d475 100644 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/assertion/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ExportNamedDeclaration assertion AST Alignment - AST 1`] = ` +exports[`AST Fixtures element AccessorProperty key-number AST Alignment - AST 1`] = ` "Snapshot Diff: Compared values have no visual difference." `; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..0ee5b89aab4 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-number/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-number AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/fixture.ts new file mode 100644 index 00000000000..255b0794a5e --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor #foo = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..e30dd5e502f --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-private TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: PrivateIdentifier { + type: "PrivateIdentifier", + name: "foo", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + override: false, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + + range: [14, 32], + loc: { + start: { column: 2, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + ], + + range: [10, 34], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..1a3c3d84ed7 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-private TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "#foo", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [28, 29], + loc: { + start: { column: 16, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 19, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [33, 34], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..e687dfd0d9a --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/3-Babel-AST.shot @@ -0,0 +1,79 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-private Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: false, + key: PrivateIdentifier { + type: "PrivateIdentifier", + name: "foo", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + + range: [14, 32], + loc: { + start: { column: 2, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + ], + + range: [10, 34], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..52963d76a15 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-private Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "foo", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [28, 29], + loc: { + start: { column: 16, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 19, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [33, 34], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..100c519c06c --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,87 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-private AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: false, +- declare: false, + key: PrivateIdentifier { + type: 'PrivateIdentifier', + name: 'foo', + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, +- override: false, + static: false, + value: Literal { + type: 'Literal', + raw: '2', + value: 2, + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + + range: [14, 32], + loc: { + start: { column: 2, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + ], + + range: [10, 34], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..11bd633e049 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-private/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,103 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-private AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'class', + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'accessor', + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, +- Identifier { +- type: 'Identifier', +- value: '#foo', ++ PrivateIdentifier { ++ type: 'PrivateIdentifier', ++ value: 'foo', + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '=', + + range: [28, 29], + loc: { + start: { column: 16, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Numeric { + type: 'Numeric', + value: '2', + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [31, 32], + loc: { + start: { column: 19, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [33, 34], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/fixture.ts new file mode 100644 index 00000000000..808470d5b6a --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor 'prop' = 'value'; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..06a3b3705ed --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-string TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: Literal { + type: "Literal", + raw: "'prop'", + value: "prop", + + range: [23, 29], + loc: { + start: { column: 11, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + override: false, + static: false, + value: Literal { + type: "Literal", + raw: "'value'", + value: "value", + + range: [32, 39], + loc: { + start: { column: 20, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + + range: [14, 40], + loc: { + start: { column: 2, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + ], + + range: [10, 42], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 42], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 43], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..0fe6262dd93 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-string TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + String { + type: "String", + value: "'prop'", + + range: [23, 29], + loc: { + start: { column: 11, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + String { + type: "String", + value: "'value'", + + range: [32, 39], + loc: { + start: { column: 20, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [41, 42], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..9af9236878c --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/3-Babel-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-string Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: false, + key: Literal { + type: "Literal", + raw: "'prop'", + value: "prop", + + range: [23, 29], + loc: { + start: { column: 11, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + static: false, + value: Literal { + type: "Literal", + raw: "'value'", + value: "value", + + range: [32, 39], + loc: { + start: { column: 20, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + + range: [14, 40], + loc: { + start: { column: 2, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + ], + + range: [10, 42], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 42], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 43], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..110b7cb9949 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-string Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + String { + type: "String", + value: "'prop'", + + range: [23, 29], + loc: { + start: { column: 11, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [30, 31], + loc: { + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + String { + type: "String", + value: "'value'", + + range: [32, 39], + loc: { + start: { column: 20, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [41, 42], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..f831283bcb4 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-string AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: false, +- declare: false, + key: Literal { + type: 'Literal', + raw: '\\\\'prop\\\\'', + value: 'prop', + + range: [23, 29], + loc: { + start: { column: 11, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, +- override: false, + static: false, + value: Literal { + type: 'Literal', + raw: '\\\\'value\\\\'', + value: 'value', + + range: [32, 39], + loc: { + start: { column: 20, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + + range: [14, 40], + loc: { + start: { column: 2, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + ], + + range: [10, 42], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 42], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 43], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..af1e8eed8c6 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-string/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty key-string AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/config.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/config.ts new file mode 100644 index 00000000000..61e0e137a0e --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/config.ts @@ -0,0 +1,3 @@ +export default { + expectBabelToNotSupport: 'https://github.com/babel/babel/issues/15205', +} satisfies ASTFixtureConfig; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/fixture.ts new file mode 100644 index 00000000000..26b6ab5a4e0 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + abstract accessor foo: number = 1; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..1c8247fb96d --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-abstract-with-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: Array [ + TSAbstractAccessorProperty { + type: "TSAbstractAccessorProperty", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [41, 44], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + override: false, + static: false, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [46, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 31, line: 2 }, + }, + }, + + range: [44, 52], + loc: { + start: { column: 23, line: 2 }, + end: { column: 31, line: 2 }, + }, + }, + value: null, + + range: [23, 57], + loc: { + start: { column: 2, line: 2 }, + end: { column: 36, line: 2 }, + }, + }, + ], + + range: [19, 59], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + superClass: null, + + range: [0, 59], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 60], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b993bfecdea --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-abstract-with-value TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "abstract", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [9, 14], + loc: { + start: { column: 9, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "abstract", + + range: [23, 31], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [32, 40], + loc: { + start: { column: 11, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [41, 44], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [44, 45], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [46, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 31, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [53, 54], + loc: { + start: { column: 32, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [55, 56], + loc: { + start: { column: 34, line: 2 }, + end: { column: 35, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [56, 57], + loc: { + start: { column: 35, line: 2 }, + end: { column: 36, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [58, 59], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/3-Babel-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/3-Babel-Error.shot new file mode 100644 index 00000000000..c49a847cd3a --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/snapshots/3-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-abstract-with-value Babel - Error 1`] = `[SyntaxError: Missing semicolon. (2:23)]`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/config.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/config.ts new file mode 100644 index 00000000000..61e0e137a0e --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/config.ts @@ -0,0 +1,3 @@ +export default { + expectBabelToNotSupport: 'https://github.com/babel/babel/issues/15205', +} satisfies ASTFixtureConfig; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/fixture.ts new file mode 100644 index 00000000000..61608bfc72d --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + abstract accessor foo: number; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..420e13ca4bf --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-abstract TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: Array [ + TSAbstractAccessorProperty { + type: "TSAbstractAccessorProperty", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [41, 44], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + override: false, + static: false, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [46, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 31, line: 2 }, + }, + }, + + range: [44, 52], + loc: { + start: { column: 23, line: 2 }, + end: { column: 31, line: 2 }, + }, + }, + value: null, + + range: [23, 53], + loc: { + start: { column: 2, line: 2 }, + end: { column: 32, line: 2 }, + }, + }, + ], + + range: [19, 55], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + superClass: null, + + range: [0, 55], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 56], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..732caf89fce --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-abstract TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "abstract", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [9, 14], + loc: { + start: { column: 9, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "abstract", + + range: [23, 31], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [32, 40], + loc: { + start: { column: 11, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [41, 44], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [44, 45], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [46, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 31, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [52, 53], + loc: { + start: { column: 31, line: 2 }, + end: { column: 32, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [54, 55], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/3-Babel-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/3-Babel-Error.shot new file mode 100644 index 00000000000..6f975b3a497 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract/snapshots/3-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-abstract Babel - Error 1`] = `[SyntaxError: Missing semicolon. (2:23)]`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/fixture.ts new file mode 100644 index 00000000000..70dd6b95f61 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/fixture.ts @@ -0,0 +1,3 @@ +class Foo extends Bar { + override accessor foo = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..b0e78060a09 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-override TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [44, 47], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + override: true, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [50, 51], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + + range: [26, 52], + loc: { + start: { column: 2, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + ], + + range: [22, 54], + loc: { + start: { column: 22, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: "Identifier", + name: "Bar", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 54], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 55], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..24c22b85146 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,126 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-override TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [10, 17], + loc: { + start: { column: 10, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Bar", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "override", + + range: [26, 34], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [35, 43], + loc: { + start: { column: 11, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [44, 47], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [48, 49], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [50, 51], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [51, 52], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [53, 54], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..49d82178de5 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/3-Babel-AST.shot @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-override Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [44, 47], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + override: true, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [50, 51], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + + range: [26, 52], + loc: { + start: { column: 2, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + ], + + range: [22, 54], + loc: { + start: { column: 22, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: "Identifier", + name: "Bar", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 54], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 55], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..dd9763a4fcd --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,126 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-override Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [10, 17], + loc: { + start: { column: 10, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Bar", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "override", + + range: [26, 34], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [35, 43], + loc: { + start: { column: 11, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [44, 47], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [48, 49], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [50, 51], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [51, 52], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [53, 54], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..7949a056f9a --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-override AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: false, +- declare: false, + key: Identifier { + type: 'Identifier', + name: 'foo', + + range: [44, 47], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + override: true, + static: false, + value: Literal { + type: 'Literal', + raw: '2', + value: 2, + + range: [50, 51], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + + range: [26, 52], + loc: { + start: { column: 2, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + ], + + range: [22, 54], + loc: { + start: { column: 22, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: 'Identifier', + name: 'Bar', + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 54], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 55], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..4585c5481d0 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-override/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-override AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/fixture.ts new file mode 100644 index 00000000000..ceacabc649f --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + private accessor foo = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..0f0fa0f2a10 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-private TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + accessibility: "private", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [31, 34], + loc: { + start: { column: 19, line: 2 }, + end: { column: 22, line: 2 }, + }, + }, + override: false, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + + range: [14, 39], + loc: { + start: { column: 2, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + ], + + range: [10, 41], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 42], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..17510235b46 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-private TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "private", + + range: [14, 21], + loc: { + start: { column: 2, line: 2 }, + end: { column: 9, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [22, 30], + loc: { + start: { column: 10, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [31, 34], + loc: { + start: { column: 19, line: 2 }, + end: { column: 22, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [35, 36], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [38, 39], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [40, 41], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..b11a056920d --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/3-Babel-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-private Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + accessibility: "private", + computed: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [31, 34], + loc: { + start: { column: 19, line: 2 }, + end: { column: 22, line: 2 }, + }, + }, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + + range: [14, 39], + loc: { + start: { column: 2, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + ], + + range: [10, 41], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 42], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..75520e7741d --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-private Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "private", + + range: [14, 21], + loc: { + start: { column: 2, line: 2 }, + end: { column: 9, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [22, 30], + loc: { + start: { column: 10, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [31, 34], + loc: { + start: { column: 19, line: 2 }, + end: { column: 22, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [35, 36], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [38, 39], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [40, 41], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..fd302779cf1 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-private AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + accessibility: 'private', + computed: false, +- declare: false, + key: Identifier { + type: 'Identifier', + name: 'foo', + + range: [31, 34], + loc: { + start: { column: 19, line: 2 }, + end: { column: 22, line: 2 }, + }, + }, +- override: false, + static: false, + value: Literal { + type: 'Literal', + raw: '2', + value: 2, + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + + range: [14, 39], + loc: { + start: { column: 2, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + ], + + range: [10, 41], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 42], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..35301570665 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-private/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,112 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-private AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'class', + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'private', + + range: [14, 21], + loc: { + start: { column: 2, line: 2 }, + end: { column: 9, line: 2 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'accessor', + + range: [22, 30], + loc: { + start: { column: 10, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'foo', + + range: [31, 34], + loc: { + start: { column: 19, line: 2 }, + end: { column: 22, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '=', + + range: [35, 36], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Numeric { + type: 'Numeric', + value: '2', + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [38, 39], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [40, 41], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/fixture.ts new file mode 100644 index 00000000000..dac8cd734c5 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + protected accessor foo = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..d862c8f8648 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-protected TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + accessibility: "protected", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [33, 36], + loc: { + start: { column: 21, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + override: false, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + + range: [14, 41], + loc: { + start: { column: 2, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + ], + + range: [10, 43], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 43], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 44], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..88ab4ac1f40 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-protected TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "protected", + + range: [14, 23], + loc: { + start: { column: 2, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [24, 32], + loc: { + start: { column: 12, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [33, 36], + loc: { + start: { column: 21, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [40, 41], + loc: { + start: { column: 28, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [42, 43], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..dbabfaa6a93 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/3-Babel-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-protected Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + accessibility: "protected", + computed: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [33, 36], + loc: { + start: { column: 21, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + + range: [14, 41], + loc: { + start: { column: 2, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + ], + + range: [10, 43], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 43], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 44], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..c730984ef44 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-protected Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "protected", + + range: [14, 23], + loc: { + start: { column: 2, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [24, 32], + loc: { + start: { column: 12, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [33, 36], + loc: { + start: { column: 21, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [40, 41], + loc: { + start: { column: 28, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [42, 43], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..c26ec2b5985 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-protected AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + accessibility: 'protected', + computed: false, +- declare: false, + key: Identifier { + type: 'Identifier', + name: 'foo', + + range: [33, 36], + loc: { + start: { column: 21, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, +- override: false, + static: false, + value: Literal { + type: 'Literal', + raw: '2', + value: 2, + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + + range: [14, 41], + loc: { + start: { column: 2, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + ], + + range: [10, 43], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 43], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 44], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..cbbcda53541 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-protected/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,112 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-protected AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'class', + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'protected', + + range: [14, 23], + loc: { + start: { column: 2, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'accessor', + + range: [24, 32], + loc: { + start: { column: 12, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'foo', + + range: [33, 36], + loc: { + start: { column: 21, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '=', + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Numeric { + type: 'Numeric', + value: '2', + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [40, 41], + loc: { + start: { column: 28, line: 2 }, + end: { column: 29, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [42, 43], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/fixture.ts new file mode 100644 index 00000000000..bbcbc59c710 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + public accessor foo = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..6a1c4d1b7ec --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-public TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + accessibility: "public", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + override: false, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + + range: [14, 38], + loc: { + start: { column: 2, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + ], + + range: [10, 40], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..31de17a79dd --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-public TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "public", + + range: [14, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [21, 29], + loc: { + start: { column: 9, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [34, 35], + loc: { + start: { column: 22, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [39, 40], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..ed50b70a5c7 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/3-Babel-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-public Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + accessibility: "public", + computed: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + + range: [14, 38], + loc: { + start: { column: 2, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + ], + + range: [10, 40], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..e0257ccc735 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-public Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "public", + + range: [14, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [21, 29], + loc: { + start: { column: 9, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [34, 35], + loc: { + start: { column: 22, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [39, 40], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..9eb4ac8ef9b --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-public AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + accessibility: 'public', + computed: false, +- declare: false, + key: Identifier { + type: 'Identifier', + name: 'foo', + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, +- override: false, + static: false, + value: Literal { + type: 'Literal', + raw: '2', + value: 2, + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + + range: [14, 38], + loc: { + start: { column: 2, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + ], + + range: [10, 40], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..7228be97ad2 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-public/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,112 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-public AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'class', + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'public', + + range: [14, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'accessor', + + range: [21, 29], + loc: { + start: { column: 9, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'foo', + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '=', + + range: [34, 35], + loc: { + start: { column: 22, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Numeric { + type: 'Numeric', + value: '2', + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [39, 40], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/fixture.ts new file mode 100644 index 00000000000..532df27a9ee --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + readonly accessor foo = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..41928f7e572 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-readonly TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [32, 35], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + override: false, + readonly: true, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [38, 39], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + + range: [14, 40], + loc: { + start: { column: 2, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + ], + + range: [10, 42], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 42], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 43], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..802229ba8ae --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-readonly TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [23, 31], + loc: { + start: { column: 11, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [32, 35], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [38, 39], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [41, 42], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..369cfde552a --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/3-Babel-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-readonly Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [32, 35], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + readonly: true, + static: false, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [38, 39], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + + range: [14, 40], + loc: { + start: { column: 2, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + ], + + range: [10, 42], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 42], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 43], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..673f38fe66c --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-readonly Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [23, 31], + loc: { + start: { column: 11, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [32, 35], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [38, 39], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [39, 40], + loc: { + start: { column: 27, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [41, 42], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..7f48bba2e58 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-readonly AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: false, +- declare: false, + key: Identifier { + type: 'Identifier', + name: 'foo', + + range: [32, 35], + loc: { + start: { column: 20, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, +- override: false, + readonly: true, + static: false, + value: Literal { + type: 'Literal', + raw: '2', + value: 2, + + range: [38, 39], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + + range: [14, 40], + loc: { + start: { column: 2, line: 2 }, + end: { column: 28, line: 2 }, + }, + }, + ], + + range: [10, 42], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 42], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 43], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..ba78cbeda59 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-readonly/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-readonly AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/fixture.ts new file mode 100644 index 00000000000..0c8cd7ca6a4 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + static accessor foo = 2; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..6733de847c8 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-static TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + override: false, + static: true, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + + range: [14, 38], + loc: { + start: { column: 2, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + ], + + range: [10, 40], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..245c071ee55 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-static TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "static", + + range: [14, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [21, 29], + loc: { + start: { column: 9, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [34, 35], + loc: { + start: { column: 22, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [39, 40], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..917914d80fb --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/3-Babel-AST.shot @@ -0,0 +1,79 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-static Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: false, + key: Identifier { + type: "Identifier", + name: "foo", + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + static: true, + value: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + + range: [14, 38], + loc: { + start: { column: 2, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + ], + + range: [10, 40], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..64b2cf04408 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-static Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "static", + + range: [14, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [21, 29], + loc: { + start: { column: 9, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [34, 35], + loc: { + start: { column: 22, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [37, 38], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [39, 40], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..c5c6c8589ee --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,87 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-static AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: false, +- declare: false, + key: Identifier { + type: 'Identifier', + name: 'foo', + + range: [30, 33], + loc: { + start: { column: 18, line: 2 }, + end: { column: 21, line: 2 }, + }, + }, +- override: false, + static: true, + value: Literal { + type: 'Literal', + raw: '2', + value: 2, + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + + range: [14, 38], + loc: { + start: { column: 2, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + ], + + range: [10, 40], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..72680d23ee5 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-static/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty modifier-static AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/fixture.ts new file mode 100644 index 00000000000..18afaa86480 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor prop; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..a5341fd2f70 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-no-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + override: false, + static: false, + value: null, + + range: [14, 28], + loc: { + start: { column: 2, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + ], + + range: [10, 30], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b28c76ee39c --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-no-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [29, 30], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..7cf14ad2c92 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/3-Babel-AST.shot @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-no-value Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + static: false, + value: null, + + range: [14, 28], + loc: { + start: { column: 2, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + ], + + range: [10, 30], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..46747c3659a --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-no-value Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [29, 30], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..b08e790e91d --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,77 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-no-value AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: false, +- declare: false, + key: Identifier { + type: 'Identifier', + name: 'prop', + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, +- override: false, + static: false, + value: null, + + range: [14, 28], + loc: { + start: { column: 2, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + ], + + range: [10, 30], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..3a66da8c8d9 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-no-value/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-no-value AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/fixture.ts new file mode 100644 index 00000000000..4ac51cccf92 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor prop = 'str'; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..0cc63f22486 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-with-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + override: false, + static: false, + value: Literal { + type: "Literal", + raw: "'str'", + value: "str", + + range: [30, 35], + loc: { + start: { column: 18, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + + range: [14, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + ], + + range: [10, 38], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 38], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 39], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..e98ce8a1ccf --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-with-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [28, 29], + loc: { + start: { column: 16, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + String { + type: "String", + value: "'str'", + + range: [30, 35], + loc: { + start: { column: 18, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [35, 36], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [37, 38], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..7c1c8d024f9 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/3-Babel-AST.shot @@ -0,0 +1,79 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-with-value Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + ClassAccessorProperty { + type: "ClassAccessorProperty", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + static: false, + value: Literal { + type: "Literal", + raw: "'str'", + value: "str", + + range: [30, 35], + loc: { + start: { column: 18, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + + range: [14, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + ], + + range: [10, 38], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 38], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 39], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..fbe3b7015a8 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-with-value Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [28, 29], + loc: { + start: { column: 16, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + String { + type: "String", + value: "'str'", + + range: [30, 35], + loc: { + start: { column: 18, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [35, 36], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [37, 38], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..2d4b943581c --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,87 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-with-value AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ +- AccessorProperty { +- type: 'AccessorProperty', ++ ClassAccessorProperty { ++ type: 'ClassAccessorProperty', + computed: false, +- declare: false, + key: Identifier { + type: 'Identifier', + name: 'prop', + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, +- override: false, + static: false, + value: Literal { + type: 'Literal', + raw: '\\\\'str\\\\'', + value: 'str', + + range: [30, 35], + loc: { + start: { column: 18, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + + range: [14, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + ], + + range: [10, 38], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 38], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 39], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..01d2c94e685 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/no-annotation-with-value/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty no-annotation-with-value AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/config.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/config.ts new file mode 100644 index 00000000000..61e0e137a0e --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/config.ts @@ -0,0 +1,3 @@ +export default { + expectBabelToNotSupport: 'https://github.com/babel/babel/issues/15205', +} satisfies ASTFixtureConfig; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/fixture.ts new file mode 100644 index 00000000000..1ec3f55869e --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor prop: string; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..be65f1b2fcd --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty with-annotation-no-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + override: false, + static: false, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSStringKeyword { + type: "TSStringKeyword", + + range: [29, 35], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + + range: [27, 35], + loc: { + start: { column: 15, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + value: null, + + range: [14, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + ], + + range: [10, 38], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 38], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 39], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..3787e2a78f8 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty with-annotation-no-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [29, 35], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [35, 36], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [37, 38], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/3-Babel-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/3-Babel-Error.shot new file mode 100644 index 00000000000..95932fa9389 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-no-value/snapshots/3-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty with-annotation-no-value Babel - Error 1`] = `[SyntaxError: Missing semicolon. (2:15)]`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/config.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/config.ts new file mode 100644 index 00000000000..61e0e137a0e --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/config.ts @@ -0,0 +1,3 @@ +export default { + expectBabelToNotSupport: 'https://github.com/babel/babel/issues/15205', +} satisfies ASTFixtureConfig; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/fixture.ts new file mode 100644 index 00000000000..0fde6c3138c --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor prop: string = 'str'; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..9e9448b46f1 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,99 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty with-annotation-with-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + AccessorProperty { + type: "AccessorProperty", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + override: false, + static: false, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSStringKeyword { + type: "TSStringKeyword", + + range: [29, 35], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + + range: [27, 35], + loc: { + start: { column: 15, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + value: Literal { + type: "Literal", + raw: "'str'", + value: "str", + + range: [38, 43], + loc: { + start: { column: 26, line: 2 }, + end: { column: 31, line: 2 }, + }, + }, + + range: [14, 44], + loc: { + start: { column: 2, line: 2 }, + end: { column: 32, line: 2 }, + }, + }, + ], + + range: [10, 46], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 46], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 47], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..2ee9140971c --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty with-annotation-with-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "accessor", + + range: [14, 22], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [23, 27], + loc: { + start: { column: 11, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [27, 28], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [29, 35], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + String { + type: "String", + value: "'str'", + + range: [38, 43], + loc: { + start: { column: 26, line: 2 }, + end: { column: 31, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [43, 44], + loc: { + start: { column: 31, line: 2 }, + end: { column: 32, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [45, 46], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/3-Babel-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/3-Babel-Error.shot new file mode 100644 index 00000000000..58104f64f7b --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/with-annotation-with-value/snapshots/3-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures element AccessorProperty with-annotation-with-value Babel - Error 1`] = `[SyntaxError: Missing semicolon. (2:15)]`; diff --git a/packages/ast-spec/src/element/AccessorProperty/spec.ts b/packages/ast-spec/src/element/AccessorProperty/spec.ts new file mode 100644 index 00000000000..739481e9c23 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/spec.ts @@ -0,0 +1,19 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { + PropertyDefinitionComputedNameBase, + PropertyDefinitionNonComputedNameBase, +} from '../../base/PropertyDefinitionBase'; + +export interface AccessorPropertyComputedName + extends PropertyDefinitionComputedNameBase { + type: AST_NODE_TYPES.AccessorProperty; +} + +export interface AccessorPropertyNonComputedName + extends PropertyDefinitionNonComputedNameBase { + type: AST_NODE_TYPES.AccessorProperty; +} + +export type AccessorProperty = + | AccessorPropertyComputedName + | AccessorPropertyNonComputedName; diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/spec.ts b/packages/ast-spec/src/element/TSAbstractAccessorProperty/spec.ts new file mode 100644 index 00000000000..6ca44e44183 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/spec.ts @@ -0,0 +1,22 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { + PropertyDefinitionComputedNameBase, + PropertyDefinitionNonComputedNameBase, +} from '../../base/PropertyDefinitionBase'; + +export interface TSAbstractAccessorPropertyComputedName + extends PropertyDefinitionComputedNameBase { + type: AST_NODE_TYPES.TSAbstractAccessorProperty; + value: null; +} + +export interface TSAbstractAccessorPropertyNonComputedName + // this does not extend ClassPropertyDefinitionNonComputedNameBase because abstract private names are not allowed + extends PropertyDefinitionNonComputedNameBase { + type: AST_NODE_TYPES.TSAbstractAccessorProperty; + value: null; +} + +export type TSAbstractAccessorProperty = + | TSAbstractAccessorPropertyComputedName + | TSAbstractAccessorPropertyNonComputedName; diff --git a/packages/ast-spec/src/element/spec.ts b/packages/ast-spec/src/element/spec.ts index 77ed3f2f283..eeecc41028c 100644 --- a/packages/ast-spec/src/element/spec.ts +++ b/packages/ast-spec/src/element/spec.ts @@ -1,8 +1,10 @@ +export * from './AccessorProperty/spec'; export * from './PropertyDefinition/spec'; export * from './MethodDefinition/spec'; export * from './Property/spec'; export * from './SpreadElement/spec'; export * from './StaticBlock/spec'; +export * from './TSAbstractAccessorProperty/spec'; export * from './TSAbstractPropertyDefinition/spec'; export * from './TSAbstractMethodDefinition/spec'; export * from './TSCallSignatureDeclaration/spec'; diff --git a/packages/ast-spec/src/unions/ClassElement.ts b/packages/ast-spec/src/unions/ClassElement.ts index 27d4ec4d752..21fba7babcf 100644 --- a/packages/ast-spec/src/unions/ClassElement.ts +++ b/packages/ast-spec/src/unions/ClassElement.ts @@ -1,14 +1,18 @@ +import type { AccessorProperty } from '../element/AccessorProperty/spec'; import type { MethodDefinition } from '../element/MethodDefinition/spec'; import type { PropertyDefinition } from '../element/PropertyDefinition/spec'; import type { StaticBlock } from '../element/StaticBlock/spec'; +import type { TSAbstractAccessorProperty } from '../element/TSAbstractAccessorProperty/spec'; import type { TSAbstractMethodDefinition } from '../element/TSAbstractMethodDefinition/spec'; import type { TSAbstractPropertyDefinition } from '../element/TSAbstractPropertyDefinition/spec'; import type { TSIndexSignature } from '../element/TSIndexSignature/spec'; export type ClassElement = + | AccessorProperty | MethodDefinition | PropertyDefinition | StaticBlock + | TSAbstractAccessorProperty | TSAbstractMethodDefinition | TSAbstractPropertyDefinition | TSIndexSignature; diff --git a/packages/ast-spec/src/unions/Node.ts b/packages/ast-spec/src/unions/Node.ts index 3656a3d677a..b0952e0e186 100644 --- a/packages/ast-spec/src/unions/Node.ts +++ b/packages/ast-spec/src/unions/Node.ts @@ -12,11 +12,13 @@ import type { TSModuleDeclaration } from '../declaration/TSModuleDeclaration/spe import type { TSNamespaceExportDeclaration } from '../declaration/TSNamespaceExportDeclaration/spec'; import type { TSTypeAliasDeclaration } from '../declaration/TSTypeAliasDeclaration/spec'; import type { VariableDeclaration } from '../declaration/VariableDeclaration/spec'; +import type { AccessorProperty } from '../element/AccessorProperty/spec'; import type { MethodDefinition } from '../element/MethodDefinition/spec'; import type { Property } from '../element/Property/spec'; import type { PropertyDefinition } from '../element/PropertyDefinition/spec'; import type { SpreadElement } from '../element/SpreadElement/spec'; import type { StaticBlock } from '../element/StaticBlock/spec'; +import type { TSAbstractAccessorProperty } from '../element/TSAbstractAccessorProperty/spec'; import type { TSAbstractMethodDefinition } from '../element/TSAbstractMethodDefinition/spec'; import type { TSAbstractPropertyDefinition } from '../element/TSAbstractPropertyDefinition/spec'; import type { TSCallSignatureDeclaration } from '../element/TSCallSignatureDeclaration/spec'; @@ -170,6 +172,7 @@ import type { Literal } from './Literal'; */ export type Node = + | AccessorProperty | ArrayExpression | ArrayPattern | ArrowFunctionExpression @@ -251,6 +254,7 @@ export type Node = | ThisExpression | ThrowStatement | TryStatement + | TSAbstractAccessorProperty | TSAbstractKeyword | TSAbstractMethodDefinition | TSAbstractPropertyDefinition diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot index beff8134d6e..e6ea1804e84 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -24,6 +24,19 @@ Set { "declaration/TSInterfaceDeclaration/fixtures/type-param-one/fixture.ts", "declaration/TSTypeAliasDeclaration/fixtures/type-param-many/fixture.ts", "declaration/TSTypeAliasDeclaration/fixtures/type-param-one/fixture.ts", + "element/AccessorProperty/fixtures/key-computed-complex/fixture.ts", + "element/AccessorProperty/fixtures/key-computed-number/fixture.ts", + "element/AccessorProperty/fixtures/key-computed-string/fixture.ts", + "element/AccessorProperty/fixtures/key-private/fixture.ts", + "element/AccessorProperty/fixtures/key-string/fixture.ts", + "element/AccessorProperty/fixtures/modifier-override/fixture.ts", + "element/AccessorProperty/fixtures/modifier-private/fixture.ts", + "element/AccessorProperty/fixtures/modifier-protected/fixture.ts", + "element/AccessorProperty/fixtures/modifier-public/fixture.ts", + "element/AccessorProperty/fixtures/modifier-readonly/fixture.ts", + "element/AccessorProperty/fixtures/modifier-static/fixture.ts", + "element/AccessorProperty/fixtures/no-annotation-no-value/fixture.ts", + "element/AccessorProperty/fixtures/no-annotation-with-value/fixture.ts", "expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts", } `; diff --git a/packages/ast-spec/tests/fixtures-with-differences-errors.shot b/packages/ast-spec/tests/fixtures-with-differences-errors.shot index 7946dc0daab..68799952497 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-errors.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-errors.shot @@ -21,6 +21,8 @@ Object { "declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/fixture.ts", "declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/fixture.ts", "declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/fixture.ts", + "element/AccessorProperty/fixtures/_error_/modifier-declare/fixture.ts", + "element/AccessorProperty/fixtures/_error_/modifier-override-with-no-extends/fixture.ts", }, "TSESTree errored but Babel didn't": Set { "declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/fixture.ts", diff --git a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot index ee92fc9b050..c9796a38459 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot @@ -22,5 +22,9 @@ Set { "declaration/VariableDeclaration/fixtures/let-with-value/fixture.ts", "declaration/VariableDeclaration/fixtures/let-without-value/fixture.ts", "declaration/VariableDeclaration/fixtures/multiple-declarations/fixture.ts", + "element/AccessorProperty/fixtures/key-private/fixture.ts", + "element/AccessorProperty/fixtures/modifier-private/fixture.ts", + "element/AccessorProperty/fixtures/modifier-protected/fixture.ts", + "element/AccessorProperty/fixtures/modifier-public/fixture.ts", } `; diff --git a/packages/ast-spec/tests/fixtures-without-babel-support.shot b/packages/ast-spec/tests/fixtures-without-babel-support.shot new file mode 100644 index 00000000000..a4022f6319b --- /dev/null +++ b/packages/ast-spec/tests/fixtures-without-babel-support.shot @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures List fixtures we expect babel to not support 1`] = ` +Map { + "element/AccessorProperty/fixtures/modifier-abstract-with-value/fixture.ts" => "https://github.com/babel/babel/issues/15205", + "element/AccessorProperty/fixtures/modifier-abstract/fixture.ts" => "https://github.com/babel/babel/issues/15205", + "element/AccessorProperty/fixtures/with-annotation-no-value/fixture.ts" => "https://github.com/babel/babel/issues/15205", + "element/AccessorProperty/fixtures/with-annotation-with-value/fixture.ts" => "https://github.com/babel/babel/issues/15205", +} +`; diff --git a/packages/ast-spec/tests/fixtures.test.ts b/packages/ast-spec/tests/fixtures.test.ts index 3fff2ead3f2..df70fe613eb 100644 --- a/packages/ast-spec/tests/fixtures.test.ts +++ b/packages/ast-spec/tests/fixtures.test.ts @@ -25,6 +25,7 @@ const ONLY = [].join(path.sep); const fixturesWithASTDifferences = new Set(); const fixturesWithTokenDifferences = new Set(); +const fixturesConfiguredToExpectBabelToNotSupport = new Map(); enum ErrorLabel { TSESTree = "TSESTree errored but Babel didn't", Babel = "Babel errored but TSESTree didn't", @@ -36,46 +37,67 @@ const fixturesWithErrorDifferences = { [ErrorLabel.Babel]: new Set(), } as const; -const validFixtures = glob.sync(`${SRC_DIR}/**/fixtures/*/*.{ts,tsx}`); -const errorFixtures = glob.sync(`${SRC_DIR}/**/fixtures/_error_/*/*.{ts,tsx}`); +const VALID_FIXTURES: readonly string[] = glob.sync( + `${SRC_DIR}/**/fixtures/*/fixture.{ts,tsx}`, +); +const ERROR_FIXTURES: readonly string[] = glob.sync( + `${SRC_DIR}/**/fixtures/_error_/*/fixture.{ts,tsx}`, +); -const fixtures: readonly Fixture[] = [...validFixtures, ...errorFixtures].map( +const FIXTURES: readonly Fixture[] = [...VALID_FIXTURES, ...ERROR_FIXTURES].map( absolute => { const relativeToSrc = path.relative(SRC_DIR, absolute); const { dir, ext } = path.parse(relativeToSrc); const segments = dir.split(path.sep).filter(s => s !== 'fixtures'); const name = segments.pop()!; - const snapshotPath = path.join(SRC_DIR, dir, 'snapshots'); + const fixtureDir = path.join(SRC_DIR, dir); + const configPath = path.join(fixtureDir, 'config' /* .ts */); + const snapshotPath = path.join(fixtureDir, 'snapshots'); return { absolute, - name, + config: ((): ASTFixtureConfig => { + try { + return require(configPath).default; + } catch { + return {}; + } + })(), ext, isError: absolute.includes('/_error_/'), isJSX: ext.endsWith('x'), + name, relative: path.relative(SRC_DIR, absolute), segments, - snapshotPath, snapshotFiles: { success: { tsestree: { - ast: path.join(snapshotPath, '1-TSESTree-AST.shot'), - tokens: path.join(snapshotPath, '2-TSESTree-Tokens.shot'), + ast: (i: number) => + path.join(snapshotPath, `${i}-TSESTree-AST.shot`), + tokens: (i: number) => + path.join(snapshotPath, `${i}-TSESTree-Tokens.shot`), }, babel: { - ast: path.join(snapshotPath, '3-Babel-AST.shot'), - tokens: path.join(snapshotPath, '4-Babel-Tokens.shot'), + ast: (i: number) => path.join(snapshotPath, `${i}-Babel-AST.shot`), + tokens: (i: number) => + path.join(snapshotPath, `${i}-Babel-Tokens.shot`), }, alignment: { - ast: path.join(snapshotPath, '5-AST-Alignment-AST.shot'), - tokens: path.join(snapshotPath, '6-AST-Alignment-Tokens.shot'), + ast: (i: number) => + path.join(snapshotPath, `${i}-AST-Alignment-AST.shot`), + tokens: (i: number) => + path.join(snapshotPath, `${i}-AST-Alignment-Tokens.shot`), }, }, error: { - tsestree: path.join(snapshotPath, '1-TSESTree-Error.shot'), - babel: path.join(snapshotPath, '2-Babel-Error.shot'), - alignment: path.join(snapshotPath, '3-Alignment-Error.shot'), + tsestree: (i: number) => + path.join(snapshotPath, `${i}-TSESTree-Error.shot`), + babel: (i: number) => + path.join(snapshotPath, `${i}-Babel-Error.shot`), + alignment: (i: number) => + path.join(snapshotPath, `${i}-Alignment-Error.shot`), }, }, + snapshotPath, }; }, ); @@ -130,6 +152,8 @@ function nestDescribe(fixture: Fixture, segments = fixture.segments): void { errorLabel = ErrorLabel.None; } + let snapshotCounter = 1; + if (fixture.isError) { if ( errorLabel === ErrorLabel.TSESTree || @@ -140,17 +164,17 @@ function nestDescribe(fixture: Fixture, segments = fixture.segments): void { it('TSESTree - Error', () => { expect(tsestreeParsed.error).toMatchSpecificSnapshot( - fixture.snapshotFiles.error.tsestree, + fixture.snapshotFiles.error.tsestree(snapshotCounter++), ); }); it('Babel - Error', () => { expect(babelParsed.error).toMatchSpecificSnapshot( - fixture.snapshotFiles.error.babel, + fixture.snapshotFiles.error.babel(snapshotCounter++), ); }); it('Error Alignment', () => { expect(errorLabel).toMatchSpecificSnapshot( - fixture.snapshotFiles.error.alignment, + fixture.snapshotFiles.error.alignment(snapshotCounter++), ); }); it('Should parse with errors', () => { @@ -162,63 +186,80 @@ function nestDescribe(fixture: Fixture, segments = fixture.segments): void { it('TSESTree - AST', () => { expectSuccessResponse(tsestreeParsed); expect(tsestreeParsed.ast).toMatchSpecificSnapshot( - fixture.snapshotFiles.success.tsestree.ast, + fixture.snapshotFiles.success.tsestree.ast(snapshotCounter++), ); }); it('TSESTree - Tokens', () => { expectSuccessResponse(tsestreeParsed); expect(tsestreeParsed.tokens).toMatchSpecificSnapshot( - fixture.snapshotFiles.success.tsestree.tokens, + fixture.snapshotFiles.success.tsestree.tokens(snapshotCounter++), ); }); - it('Babel - AST', () => { - expectSuccessResponse(babelParsed); - expect(babelParsed.ast).toMatchSpecificSnapshot( - fixture.snapshotFiles.success.babel.ast, + if (fixture.config.expectBabelToNotSupport != null) { + fixturesConfiguredToExpectBabelToNotSupport.set( + fixture.relative, + fixture.config.expectBabelToNotSupport, ); - }); - it('Babel - Tokens', () => { - expectSuccessResponse(babelParsed); - expect(babelParsed.tokens).toMatchSpecificSnapshot( - fixture.snapshotFiles.success.babel.tokens, - ); - }); - it('AST Alignment - AST', () => { - expectSuccessResponse(tsestreeParsed); - expectSuccessResponse(babelParsed); - const diffResult = snapshotDiff( - 'TSESTree', - tsestreeParsed.ast, - 'Babel', - babelParsed.ast, - ); - expect(diffResult).toMatchSpecificSnapshot( - fixture.snapshotFiles.success.alignment.ast, - ); + // eslint-disable-next-line jest/no-identical-title -- intentional duplication that won't ever happen due to exclusionary conditions + it('Babel - Error', () => { + expect(babelParsed.error).toMatchSpecificSnapshot( + fixture.snapshotFiles.error.babel(snapshotCounter++), + ); + }); + // eslint-disable-next-line jest/no-disabled-tests -- intentional skip for CLI documentation purposes + it.skip('Babel - Skipped as this fixture is configured to expect babel to error', () => {}); + // eslint-disable-next-line jest/no-disabled-tests -- intentional skip for CLI documentation purposes + it.skip('AST Alignment - Skipped as this fixture is configured to expect babel to error', () => {}); + } else { + it('Babel - AST', () => { + expectSuccessResponse(babelParsed); + expect(babelParsed.ast).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.babel.ast(snapshotCounter++), + ); + }); + it('Babel - Tokens', () => { + expectSuccessResponse(babelParsed); + expect(babelParsed.tokens).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.babel.tokens(snapshotCounter++), + ); + }); + it('AST Alignment - AST', () => { + expectSuccessResponse(tsestreeParsed); + expectSuccessResponse(babelParsed); + const diffResult = snapshotDiff( + 'TSESTree', + tsestreeParsed.ast, + 'Babel', + babelParsed.ast, + ); + expect(diffResult).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.alignment.ast(snapshotCounter++), + ); - if (diffHasChanges(diffResult)) { - fixturesWithASTDifferences.add(fixture.relative); - } - }); - it('AST Alignment - Token', () => { - expectSuccessResponse(tsestreeParsed); - expectSuccessResponse(babelParsed); - const diffResult = snapshotDiff( - 'TSESTree', - tsestreeParsed.tokens, - 'Babel', - babelParsed.tokens, - ); - expect(diffResult).toMatchSpecificSnapshot( - fixture.snapshotFiles.success.alignment.tokens, - ); + if (diffHasChanges(diffResult)) { + fixturesWithASTDifferences.add(fixture.relative); + } + }); + it('AST Alignment - Token', () => { + expectSuccessResponse(tsestreeParsed); + expectSuccessResponse(babelParsed); + const diffResult = snapshotDiff( + 'TSESTree', + tsestreeParsed.tokens, + 'Babel', + babelParsed.tokens, + ); + expect(diffResult).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.alignment.tokens(snapshotCounter++), + ); - if (diffHasChanges(diffResult)) { - fixturesWithTokenDifferences.add(fixture.relative); - } - }); + if (diffHasChanges(diffResult)) { + fixturesWithTokenDifferences.add(fixture.relative); + } + }); + } it('Should parse with no errors', () => { // log the error for debug purposes in case there wasn't supposed to be an error @@ -228,7 +269,9 @@ function nestDescribe(fixture: Fixture, segments = fixture.segments): void { case ErrorLabel.Babel: expectErrorResponse(babelParsed); - console.error('Babel:\n', babelParsed.error); + if (fixture.config.expectBabelToNotSupport == null) { + console.error('Babel:\n', babelParsed.error); + } break; case ErrorLabel.TSESTree: @@ -244,15 +287,33 @@ function nestDescribe(fixture: Fixture, segments = fixture.segments): void { break; } + // NOTE - the comments below exist so that they show up in the stack trace jest shows + // when the test fails. Yes, sadly, they're duplicated, but it's necessary to + // provide the best and most understandable DevX that we can here. + // Jest will print a code frame with the fail line as well as 2 lines before and after + + // if this fails and you WERE expecting a parser error, then your fixture should be in the `_error_` subfolder + // if this fails and you WEREN'T expecting a parser error - then something is broken. + expect(errorLabel).not.toBe(ErrorLabel.TSESTree); + // if this fails and you WERE expecting a parser error, then your fixture should be in the `_error_` subfolder // if this fails and you WEREN'T expecting a parser error - then something is broken. - expect(errorLabel).toBe(ErrorLabel.None); + expect(errorLabel).not.toBe(ErrorLabel.Both); + + if (fixture.config.expectBabelToNotSupport != null) { + // if this fails and you WERE expecting a parser error, then Babel parsed without error and you should remove the `expectBabelToNotSupport` config. + expect(errorLabel).toBe(ErrorLabel.Babel); + } else { + // if this fails and you WERE expecting a parser error, then your fixture should be in the `_error_` subfolder + // if this fails and you WEREN'T expecting a parser error - then something is broken. + expect(errorLabel).not.toBe(ErrorLabel.Babel); + } }); } }; if ([...fixture.segments, fixture.name].join(path.sep) === ONLY) { - // eslint-disable-next-line jest/no-focused-tests + // eslint-disable-next-line jest/no-focused-tests -- intentional focused test that only happens during development describe.only(fixture.name, test); } else { describe(fixture.name, test); @@ -261,7 +322,7 @@ function nestDescribe(fixture: Fixture, segments = fixture.segments): void { } describe('AST Fixtures', () => { - fixtures.forEach(f => nestDescribe(f)); + FIXTURES.forEach(f => nestDescribe(f)); // once we've run all the tests, snapshot the list of fixtures that have differences for easy reference it('List fixtures with AST differences', () => { @@ -279,4 +340,9 @@ describe('AST Fixtures', () => { path.resolve(__dirname, 'fixtures-with-differences-errors.shot'), ); }); + it('List fixtures we expect babel to not support', () => { + expect(fixturesConfiguredToExpectBabelToNotSupport).toMatchSpecificSnapshot( + path.resolve(__dirname, 'fixtures-without-babel-support.shot'), + ); + }); }); diff --git a/packages/ast-spec/tests/util/parsers/babel.ts b/packages/ast-spec/tests/util/parsers/babel.ts index e0d4268bbcc..5e874be85af 100644 --- a/packages/ast-spec/tests/util/parsers/babel.ts +++ b/packages/ast-spec/tests/util/parsers/babel.ts @@ -5,6 +5,7 @@ import type { Fixture, ParserResponse } from './parser-types'; import { ParserResponseType } from './parser-types'; const PLUGINS: ParserPlugin[] = [ + 'decoratorAutoAccessors', // TODO - enable classFeatures instead of classProperties when we support it // 'classFeatures', 'classProperties', diff --git a/packages/ast-spec/tests/util/parsers/parser-types.ts b/packages/ast-spec/tests/util/parsers/parser-types.ts index 1278d43a99e..4538d8ed4a9 100644 --- a/packages/ast-spec/tests/util/parsers/parser-types.ts +++ b/packages/ast-spec/tests/util/parsers/parser-types.ts @@ -1,17 +1,19 @@ +type SnapshotPathFn = (i: number) => string; + interface SuccessSnapshotPaths { - readonly ast: string; - readonly tokens: string; + readonly ast: SnapshotPathFn; + readonly tokens: SnapshotPathFn; } export interface Fixture { readonly absolute: string; - readonly name: string; + readonly config: ASTFixtureConfig; readonly ext: string; readonly isError: boolean; readonly isJSX: boolean; + readonly name: string; readonly relative: string; readonly segments: string[]; - readonly snapshotPath: string; readonly snapshotFiles: { readonly success: { readonly tsestree: SuccessSnapshotPaths; @@ -19,11 +21,12 @@ export interface Fixture { readonly alignment: SuccessSnapshotPaths; }; readonly error: { - readonly tsestree: string; - readonly babel: string; - readonly alignment: string; + readonly tsestree: SnapshotPathFn; + readonly babel: SnapshotPathFn; + readonly alignment: SnapshotPathFn; }; }; + readonly snapshotPath: string; } export enum ParserResponseType { diff --git a/packages/ast-spec/tsconfig.json b/packages/ast-spec/tsconfig.json index fd3827cd5ba..35ae2aa3a17 100644 --- a/packages/ast-spec/tsconfig.json +++ b/packages/ast-spec/tsconfig.json @@ -4,7 +4,14 @@ "composite": false, "rootDir": "." }, - "include": ["src", "typings", "tests", "tools", "./rollup.config.ts"], - "exclude": ["**/fixtures/**"], + "include": [ + "src", + "typings", + "tests", + "tools", + "./rollup.config.ts", + "**/fixtures/**/config.ts" + ], + "exclude": ["**/fixtures/**/fixture.ts"], "references": [{ "path": "../typescript-estree/tsconfig.build.json" }] } diff --git a/packages/ast-spec/typings/global.d.ts b/packages/ast-spec/typings/global.d.ts new file mode 100644 index 00000000000..4464c06fbcf --- /dev/null +++ b/packages/ast-spec/typings/global.d.ts @@ -0,0 +1,14 @@ +/** + * We define this as a global type to make it easier to consume from fixtures. + * It saves us having to import the type into `src` files from a test utils folder. + * This is a convenient property because it saves us from a lot of `../`! + */ +interface ASTFixtureConfig { + /** + * Specifies that we expect that babel doesn't yet support the code in this fixture, so we expect that it will error. + * This should not be used if we expect babel to throw for this feature due to a valid parser error! + * + * The value should be a description of why there isn't support - for example a github issue URL. + */ + readonly expectBabelToNotSupport?: string; +} diff --git a/packages/scope-manager/src/referencer/ClassVisitor.ts b/packages/scope-manager/src/referencer/ClassVisitor.ts index 3aced282e44..5f84e37404f 100644 --- a/packages/scope-manager/src/referencer/ClassVisitor.ts +++ b/packages/scope-manager/src/referencer/ClassVisitor.ts @@ -83,9 +83,13 @@ class ClassVisitor extends Visitor { } protected visitPropertyDefinition( - node: TSESTree.TSAbstractPropertyDefinition | TSESTree.PropertyDefinition, + node: + | TSESTree.AccessorProperty + | TSESTree.PropertyDefinition + | TSESTree.TSAbstractAccessorProperty + | TSESTree.TSAbstractPropertyDefinition, ): void { - this.visitProperty(node); + this.visitPropertyBase(node); /** * class A { * @meta // <--- check this @@ -229,9 +233,11 @@ class ClassVisitor extends Visitor { this.#referencer.close(node); } - protected visitProperty( + protected visitPropertyBase( node: + | TSESTree.AccessorProperty | TSESTree.PropertyDefinition + | TSESTree.TSAbstractAccessorProperty | TSESTree.TSAbstractPropertyDefinition | TSESTree.TSAbstractMethodDefinition, ): void { @@ -240,7 +246,10 @@ class ClassVisitor extends Visitor { } if (node.value) { - if (node.type === AST_NODE_TYPES.PropertyDefinition) { + if ( + node.type === AST_NODE_TYPES.PropertyDefinition || + node.type === AST_NODE_TYPES.AccessorProperty + ) { this.#referencer.scopeManager.nestClassFieldInitializerScope( node.value, ); @@ -248,7 +257,10 @@ class ClassVisitor extends Visitor { this.#referencer.visit(node.value); - if (node.type === AST_NODE_TYPES.PropertyDefinition) { + if ( + node.type === AST_NODE_TYPES.PropertyDefinition || + node.type === AST_NODE_TYPES.AccessorProperty + ) { this.#referencer.close(node.value); } } @@ -328,6 +340,10 @@ class ClassVisitor extends Visitor { // Visit selectors // ///////////////////// + protected AccessorProperty(node: TSESTree.AccessorProperty): void { + this.visitPropertyDefinition(node); + } + protected ClassBody(node: TSESTree.ClassBody): void { // this is here on purpose so that this visitor explicitly declares visitors // for all nodes it cares about (see the instance visit method above) @@ -342,6 +358,12 @@ class ClassVisitor extends Visitor { this.visitMethod(node); } + protected TSAbstractAccessorProperty( + node: TSESTree.TSAbstractAccessorProperty, + ): void { + this.visitPropertyDefinition(node); + } + protected TSAbstractPropertyDefinition( node: TSESTree.TSAbstractPropertyDefinition, ): void { @@ -351,7 +373,7 @@ class ClassVisitor extends Visitor { protected TSAbstractMethodDefinition( node: TSESTree.TSAbstractMethodDefinition, ): void { - this.visitProperty(node); + this.visitPropertyBase(node); } protected Identifier(node: TSESTree.Identifier): void { diff --git a/packages/scope-manager/tests/fixtures/class/declaration/abstract-accessor-property.ts b/packages/scope-manager/tests/fixtures/class/declaration/abstract-accessor-property.ts new file mode 100644 index 00000000000..b84caed0b39 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/abstract-accessor-property.ts @@ -0,0 +1,5 @@ +type T = 1; + +abstract class Foo { + abstract prop: T; +} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/abstract-accessor-property.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/abstract-accessor-property.ts.shot new file mode 100644 index 00000000000..c895afba904 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/abstract-accessor-property.ts.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration abstract-accessor-property 1`] = ` +ScopeManager { + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isRead: true, + isTypeReference: true, + isValueReference: false, + isWrite: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "const" => ImplicitGlobalConstTypeVariable, + "T" => Variable$2, + "Foo" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2, + Variable$3, + ], + }, + ClassScope$2 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/accessor-property-type-annotation.ts b/packages/scope-manager/tests/fixtures/class/declaration/accessor-property-type-annotation.ts new file mode 100644 index 00000000000..824821d682e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/accessor-property-type-annotation.ts @@ -0,0 +1,4 @@ +type T = 1; +class A { + prop: T; +} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/accessor-property-type-annotation.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/accessor-property-type-annotation.ts.shot new file mode 100644 index 00000000000..fb8248edefe --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/accessor-property-type-annotation.ts.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration accessor-property-type-annotation 1`] = ` +ScopeManager { + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isRead: true, + isTypeReference: true, + isValueReference: false, + isWrite: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"A">, + node: ClassDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "const" => ImplicitGlobalConstTypeVariable, + "T" => Variable$2, + "A" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2, + Variable$3, + ], + }, + ClassScope$2 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "A" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/accessor-property.ts b/packages/scope-manager/tests/fixtures/class/declaration/accessor-property.ts new file mode 100644 index 00000000000..e75d9def3e9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/accessor-property.ts @@ -0,0 +1,7 @@ +const x = 1; +class A { + prop1 = 1; + prop2 = x; +} + +const unresolved = prop1; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/accessor-property.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/accessor-property.ts.shot new file mode 100644 index 00000000000..88914131b5c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/accessor-property.ts.shot @@ -0,0 +1,152 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration accessor-property 1`] = ` +ScopeManager { + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isRead: false, + isTypeReference: false, + isValueReference: true, + isWrite: true, + resolved: Variable$2, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isRead: true, + isTypeReference: false, + isValueReference: true, + isWrite: false, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$3, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"A">, + node: ClassDeclaration$3, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"unresolved">, + node: VariableDeclarator$4, + }, + ], + name: "unresolved", + references: Array [ + Reference$3 { + identifier: Identifier<"unresolved">, + init: true, + isRead: false, + isTypeReference: false, + isValueReference: true, + isWrite: true, + resolved: Variable$5, + writeExpr: Identifier<"prop1">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$3, + Reference$4 { + identifier: Identifier<"prop1">, + isRead: true, + isTypeReference: false, + isValueReference: true, + isWrite: false, + resolved: null, + }, + ], + set: Map { + "const" => ImplicitGlobalConstTypeVariable, + "x" => Variable$2, + "A" => Variable$3, + "unresolved" => Variable$5, + }, + type: "global", + upper: null, + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2, + Variable$3, + Variable$5, + ], + }, + ClassScope$2 { + block: ClassDeclaration$3, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + ClassFieldInitializerScope$3 { + block: Literal$6, + isStrict: true, + references: Array [], + set: Map {}, + type: "class-field-initializer", + upper: ClassScope$2, + variables: Array [], + }, + ClassFieldInitializerScope$4 { + block: Identifier<"x">, + isStrict: true, + references: Array [ + Reference$2, + ], + set: Map {}, + type: "class-field-initializer", + upper: ClassScope$2, + variables: Array [], + }, + ], +} +`; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index ca53cc45a44..b21a42614da 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1167,12 +1167,30 @@ export class Converter { case SyntaxKind.PropertyDeclaration: { const isAbstract = hasModifier(SyntaxKind.AbstractKeyword, node); + const isAccessor = hasModifier(SyntaxKind.AccessorKeyword, node); + + // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- TODO - add ignore IIFE option + const type = (() => { + if (isAccessor) { + if (isAbstract) { + return AST_NODE_TYPES.TSAbstractAccessorProperty; + } + return AST_NODE_TYPES.AccessorProperty; + } + + if (isAbstract) { + return AST_NODE_TYPES.TSAbstractPropertyDefinition; + } + return AST_NODE_TYPES.PropertyDefinition; + })(); + const result = this.createNode< - TSESTree.TSAbstractPropertyDefinition | TSESTree.PropertyDefinition + | TSESTree.TSAbstractAccessorProperty + | TSESTree.TSAbstractPropertyDefinition + | TSESTree.PropertyDefinition + | TSESTree.AccessorProperty >(node, { - type: isAbstract - ? AST_NODE_TYPES.TSAbstractPropertyDefinition - : AST_NODE_TYPES.PropertyDefinition, + type, key: this.convertChild(node.name), value: isAbstract ? null : this.convertChild(node.initializer), computed: isComputedProperty(node.name), diff --git a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts index 12ff9392cb0..c080a83559b 100644 --- a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts +++ b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts @@ -4,6 +4,7 @@ import type * as ts from 'typescript'; import type { TSNode } from './ts-nodes'; export interface EstreeToTsNodeTypes { + [AST_NODE_TYPES.AccessorProperty]: ts.PropertyDeclaration; [AST_NODE_TYPES.ArrayExpression]: ts.ArrayLiteralExpression; [AST_NODE_TYPES.ArrayPattern]: | ts.ArrayLiteralExpression @@ -156,6 +157,7 @@ export interface EstreeToTsNodeTypes { | ts.Identifier; [AST_NODE_TYPES.ThrowStatement]: ts.ThrowStatement; [AST_NODE_TYPES.TryStatement]: ts.TryStatement; + [AST_NODE_TYPES.TSAbstractAccessorProperty]: ts.PropertyDeclaration; [AST_NODE_TYPES.TSAbstractPropertyDefinition]: ts.PropertyDeclaration; [AST_NODE_TYPES.TSAbstractMethodDefinition]: | ts.GetAccessorDeclaration diff --git a/packages/visitor-keys/src/visitor-keys.ts b/packages/visitor-keys/src/visitor-keys.ts index cb3e614df53..80a8b8c9c78 100644 --- a/packages/visitor-keys/src/visitor-keys.ts +++ b/packages/visitor-keys/src/visitor-keys.ts @@ -10,91 +10,197 @@ type GetNodeTypeKeys = Exclude< 'type' | 'loc' | 'range' | 'parent' >; +type KeysDefinedInESLintVisitorKeysCore = + | AST_NODE_TYPES.AssignmentExpression + | AST_NODE_TYPES.AssignmentPattern + | AST_NODE_TYPES.ArrayExpression + | AST_NODE_TYPES.ArrayPattern + | AST_NODE_TYPES.ArrowFunctionExpression + | AST_NODE_TYPES.AwaitExpression + | AST_NODE_TYPES.BlockStatement + | AST_NODE_TYPES.BinaryExpression + | AST_NODE_TYPES.BreakStatement + | AST_NODE_TYPES.CallExpression + | AST_NODE_TYPES.CatchClause + | AST_NODE_TYPES.ChainExpression + | AST_NODE_TYPES.ClassBody + | AST_NODE_TYPES.ClassDeclaration + | AST_NODE_TYPES.ClassExpression + | AST_NODE_TYPES.ConditionalExpression + | AST_NODE_TYPES.ContinueStatement + | AST_NODE_TYPES.DebuggerStatement + | AST_NODE_TYPES.DoWhileStatement + | AST_NODE_TYPES.EmptyStatement + | AST_NODE_TYPES.ExportAllDeclaration + | AST_NODE_TYPES.ExportDefaultDeclaration + | AST_NODE_TYPES.ExportNamedDeclaration + | AST_NODE_TYPES.ExportSpecifier + | AST_NODE_TYPES.ExpressionStatement + // | AST_NODE_TYPES.ExperimentalRestProperty + // | AST_NODE_TYPES.ExperimentalSpreadProperty + | AST_NODE_TYPES.ForStatement + | AST_NODE_TYPES.ForInStatement + | AST_NODE_TYPES.ForOfStatement + | AST_NODE_TYPES.FunctionDeclaration + | AST_NODE_TYPES.FunctionExpression + | AST_NODE_TYPES.Identifier + | AST_NODE_TYPES.IfStatement + | AST_NODE_TYPES.ImportDeclaration + | AST_NODE_TYPES.ImportDefaultSpecifier + | AST_NODE_TYPES.ImportExpression + | AST_NODE_TYPES.ImportNamespaceSpecifier + | AST_NODE_TYPES.ImportSpecifier + | AST_NODE_TYPES.JSXAttribute + | AST_NODE_TYPES.JSXClosingElement + | AST_NODE_TYPES.JSXElement + | AST_NODE_TYPES.JSXEmptyExpression + | AST_NODE_TYPES.JSXExpressionContainer + | AST_NODE_TYPES.JSXIdentifier + | AST_NODE_TYPES.JSXMemberExpression + | AST_NODE_TYPES.JSXNamespacedName + | AST_NODE_TYPES.JSXOpeningElement + | AST_NODE_TYPES.JSXSpreadAttribute + | AST_NODE_TYPES.JSXText + | AST_NODE_TYPES.JSXFragment + | AST_NODE_TYPES.JSXClosingFragment + | AST_NODE_TYPES.JSXOpeningFragment + | AST_NODE_TYPES.Literal + | AST_NODE_TYPES.LabeledStatement + | AST_NODE_TYPES.LogicalExpression + | AST_NODE_TYPES.MemberExpression + | AST_NODE_TYPES.MetaProperty + | AST_NODE_TYPES.MethodDefinition + | AST_NODE_TYPES.NewExpression + | AST_NODE_TYPES.ObjectExpression + | AST_NODE_TYPES.ObjectPattern + | AST_NODE_TYPES.PrivateIdentifier + | AST_NODE_TYPES.Program + | AST_NODE_TYPES.Property + | AST_NODE_TYPES.PropertyDefinition + | AST_NODE_TYPES.RestElement + | AST_NODE_TYPES.ReturnStatement + | AST_NODE_TYPES.SequenceExpression + | AST_NODE_TYPES.SpreadElement + | AST_NODE_TYPES.StaticBlock + | AST_NODE_TYPES.Super + | AST_NODE_TYPES.SwitchStatement + | AST_NODE_TYPES.SwitchCase + | AST_NODE_TYPES.TaggedTemplateExpression + | AST_NODE_TYPES.TemplateElement + | AST_NODE_TYPES.TemplateLiteral + | AST_NODE_TYPES.ThisExpression + | AST_NODE_TYPES.ThrowStatement + | AST_NODE_TYPES.TryStatement + | AST_NODE_TYPES.UnaryExpression + | AST_NODE_TYPES.UpdateExpression + | AST_NODE_TYPES.VariableDeclaration + | AST_NODE_TYPES.VariableDeclarator + | AST_NODE_TYPES.WhileStatement + | AST_NODE_TYPES.WithStatement + | AST_NODE_TYPES.YieldExpression; + // strictly type the arrays of keys provided to make sure we keep this config in sync with the type defs type AdditionalKeys = { - readonly [T in AST_NODE_TYPES]?: readonly GetNodeTypeKeys[]; + readonly // require keys for all nodes NOT defined in `eslint-visitor-keys` + [T in Exclude< + AST_NODE_TYPES, + KeysDefinedInESLintVisitorKeysCore + >]: readonly GetNodeTypeKeys[]; +} & { + readonly // optionally allow keys for all nodes defined in `eslint-visitor-keys` + [T in KeysDefinedInESLintVisitorKeysCore]?: readonly GetNodeTypeKeys[]; }; -const additionalKeys: AdditionalKeys = { - // Stage 3 Import Assertions - ImportAttribute: ['key', 'value'], +/** + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * + * The key arrays should be sorted in the order in which you would want to visit + * the child keys - don't just sort them alphabetically. + */ + +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- TODO - add ignore IIFE option +const SharedVisitorKeys = (() => { + const FunctionType = ['typeParameters', 'params', 'returnType'] as const; + const AnonymousFunction = [...FunctionType, 'body'] as const; + const AbstractPropertyDefinition = [ + 'decorators', + 'key', + 'typeAnnotation', + ] as const; + + return { + AnonymousFunction, + Function: ['id', ...AnonymousFunction], + FunctionType, + + ClassDeclaration: [ + 'decorators', + 'id', + 'typeParameters', + 'superClass', + 'superTypeParameters', + 'implements', + 'body', + ], + + AbstractPropertyDefinition: ['decorators', 'key', 'typeAnnotation'], + PropertyDefinition: [...AbstractPropertyDefinition, 'value'], + TypeAssertion: ['expression', 'typeAnnotation'], + } as const; +})(); - // Additional Properties. +const additionalKeys: AdditionalKeys = { + AccessorProperty: SharedVisitorKeys.PropertyDefinition, ArrayPattern: ['decorators', 'elements', 'typeAnnotation'], - ArrowFunctionExpression: ['typeParameters', 'params', 'returnType', 'body'], + ArrowFunctionExpression: SharedVisitorKeys.AnonymousFunction, AssignmentPattern: ['decorators', 'left', 'right', 'typeAnnotation'], CallExpression: ['callee', 'typeParameters', 'arguments'], - ClassDeclaration: [ - 'decorators', - 'id', - 'typeParameters', - 'superClass', - 'superTypeParameters', - 'implements', - 'body', - ], - ClassExpression: [ - 'decorators', - 'id', - 'typeParameters', - 'superClass', - 'superTypeParameters', - 'implements', - 'body', - ], + ClassDeclaration: SharedVisitorKeys.ClassDeclaration, + ClassExpression: SharedVisitorKeys.ClassDeclaration, + Decorator: ['expression'], ExportAllDeclaration: ['exported', 'source', 'assertions'], ExportNamedDeclaration: ['declaration', 'specifiers', 'source', 'assertions'], - FunctionDeclaration: ['id', 'typeParameters', 'params', 'returnType', 'body'], - FunctionExpression: ['id', 'typeParameters', 'params', 'returnType', 'body'], + FunctionDeclaration: SharedVisitorKeys.Function, + FunctionExpression: SharedVisitorKeys.Function, Identifier: ['decorators', 'typeAnnotation'], + ImportAttribute: ['key', 'value'], ImportDeclaration: ['specifiers', 'source', 'assertions'], ImportExpression: ['source', 'attributes'], + JSXClosingFragment: [], + JSXOpeningElement: ['name', 'typeParameters', 'attributes'], + JSXOpeningFragment: [], + JSXSpreadChild: ['expression'], MethodDefinition: ['decorators', 'key', 'value', 'typeParameters'], NewExpression: ['callee', 'typeParameters', 'arguments'], ObjectPattern: ['decorators', 'properties', 'typeAnnotation'], - PropertyDefinition: ['decorators', 'key', 'typeAnnotation', 'value'], + PropertyDefinition: SharedVisitorKeys.PropertyDefinition, RestElement: ['decorators', 'argument', 'typeAnnotation'], - TaggedTemplateExpression: ['tag', 'typeParameters', 'quasi'], StaticBlock: ['body'], - - // JSX - JSXOpeningElement: ['name', 'typeParameters', 'attributes'], - JSXClosingFragment: [], - JSXOpeningFragment: [], - JSXSpreadChild: ['expression'], - - // Additional Nodes. - Decorator: ['expression'], - - // TS-prefixed nodes + TaggedTemplateExpression: ['tag', 'typeParameters', 'quasi'], + TSAbstractAccessorProperty: SharedVisitorKeys.AbstractPropertyDefinition, TSAbstractKeyword: [], TSAbstractMethodDefinition: ['key', 'value'], - TSAbstractPropertyDefinition: ['decorators', 'key', 'typeAnnotation'], + TSAbstractPropertyDefinition: SharedVisitorKeys.AbstractPropertyDefinition, TSAnyKeyword: [], TSArrayType: ['elementType'], - TSAsExpression: ['expression', 'typeAnnotation'], + TSAsExpression: SharedVisitorKeys.TypeAssertion, TSAsyncKeyword: [], TSBigIntKeyword: [], TSBooleanKeyword: [], - TSCallSignatureDeclaration: ['typeParameters', 'params', 'returnType'], + TSCallSignatureDeclaration: SharedVisitorKeys.FunctionType, TSClassImplements: ['expression', 'typeParameters'], TSConditionalType: ['checkType', 'extendsType', 'trueType', 'falseType'], - TSConstructorType: ['typeParameters', 'params', 'returnType'], - TSConstructSignatureDeclaration: ['typeParameters', 'params', 'returnType'], - TSDeclareFunction: ['id', 'typeParameters', 'params', 'returnType', 'body'], + TSConstructorType: SharedVisitorKeys.FunctionType, + TSConstructSignatureDeclaration: SharedVisitorKeys.FunctionType, + TSDeclareFunction: SharedVisitorKeys.Function, TSDeclareKeyword: [], - TSEmptyBodyFunctionExpression: [ - 'id', - 'typeParameters', - 'params', - 'returnType', - ], + TSEmptyBodyFunctionExpression: ['id', ...SharedVisitorKeys.FunctionType], TSEnumDeclaration: ['id', 'members'], TSEnumMember: ['id', 'initializer'], TSExportAssignment: ['expression'], TSExportKeyword: [], TSExternalModuleReference: ['expression'], - TSFunctionType: ['typeParameters', 'params', 'returnType'], + TSFunctionType: SharedVisitorKeys.FunctionType, TSImportEqualsDeclaration: ['id', 'moduleReference'], TSImportType: ['parameter', 'qualifier', 'typeParameters'], TSIndexedAccessType: ['indexType', 'objectType'], @@ -127,7 +233,12 @@ const additionalKeys: AdditionalKeys = { TSQualifiedName: ['left', 'right'], TSReadonlyKeyword: [], TSRestType: ['typeAnnotation'], - TSSatisfiesExpression: ['typeAnnotation', 'expression'], + TSSatisfiesExpression: [ + // this is intentionally different to SharedVisitorKeys.TypeAssertion because + // the type annotation comes first in the source code + 'typeAnnotation', + 'expression', + ], TSStaticKeyword: [], TSStringKeyword: [], TSSymbolKeyword: [], @@ -136,7 +247,7 @@ const additionalKeys: AdditionalKeys = { TSTupleType: ['elementTypes'], TSTypeAliasDeclaration: ['id', 'typeParameters', 'typeAnnotation'], TSTypeAnnotation: ['typeAnnotation'], - TSTypeAssertion: ['typeAnnotation', 'expression'], + TSTypeAssertion: SharedVisitorKeys.TypeAssertion, TSTypeLiteral: ['members'], TSTypeOperator: ['typeAnnotation'], TSTypeParameter: ['name', 'constraint', 'default'], @@ -149,7 +260,7 @@ const additionalKeys: AdditionalKeys = { TSUnionType: ['types'], TSUnknownKeyword: [], TSVoidKeyword: [], -} as const; +}; const visitorKeys: VisitorKeys = eslintVisitorKeys.unionWith(additionalKeys);