diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/fixture.ts new file mode 100644 index 000000000000..fe9d09f5c8b5 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor '\u{63}onstructor' +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..1efee502ef1a --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > AccessorProperty > _error_ > key-constructor-string-escaped > TSESTree - Error`] +TSError + 1 | class Foo { +> 2 | accessor '\u{63}onstructor' + | ^^^^^^^^^^^^^^^^^^ Classes may not have a field named 'constructor'. + 3 | } + 4 | diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..b36c85229b5d --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > AccessorProperty > _error_ > key-constructor-string-escaped > Babel - Error`] +BabelError + 1 | class Foo { +> 2 | accessor '\u{63}onstructor' + | ^ Classes may not have a field named 'constructor'. (2:11) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..1b975851c82a --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > AccessorProperty > _error_ > key-constructor-string-escaped > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/fixture.ts new file mode 100644 index 000000000000..15b65f9026f1 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor 'constructor' +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..99225f26fe0f --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > AccessorProperty > _error_ > key-constructor-string > TSESTree - Error`] +TSError + 1 | class Foo { +> 2 | accessor 'constructor' + | ^^^^^^^^^^^^^ Classes may not have a field named 'constructor'. + 3 | } + 4 | diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..bb359842fe1e --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > AccessorProperty > _error_ > key-constructor-string > Babel - Error`] +BabelError + 1 | class Foo { +> 2 | accessor 'constructor' + | ^ Classes may not have a field named 'constructor'. (2:11) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..d6b1cda3e19b --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > AccessorProperty > _error_ > key-constructor-string > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/fixture.ts new file mode 100644 index 000000000000..176558f7f971 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor [constructor]; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..0bd9d71a1338 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,79 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: false, + body: ClassBody { + type: "ClassBody", + body: [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "constructor", + optional: false, + + range: [24, 35], + loc: { + start: { column: 12, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [14, 37], + loc: { + start: { column: 2, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + ], + + range: [10, 39], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 39], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..ced41a5029ae --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,92 @@ +[ + 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 }, + }, + }, + Identifier { + type: "Identifier", + value: "constructor", + + range: [24, 35], + loc: { + start: { column: 12, 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: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [38, 39], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..0bd9d71a1338 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot @@ -0,0 +1,79 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: false, + body: ClassBody { + type: "ClassBody", + body: [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "constructor", + optional: false, + + range: [24, 35], + loc: { + start: { column: 12, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [14, 37], + loc: { + start: { column: 2, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + ], + + range: [10, 39], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 39], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..ced41a5029ae --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,92 @@ +[ + 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 }, + }, + }, + Identifier { + type: "Identifier", + value: "constructor", + + range: [24, 35], + loc: { + start: { column: 12, 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: [36, 37], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [38, 39], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/fixture.ts b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/fixture.ts new file mode 100644 index 000000000000..acc5cfe6398a --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + accessor ['constructor']; +} diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..5b9bbadd0d07 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,78 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: false, + body: ClassBody { + type: "ClassBody", + body: [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Literal { + type: "Literal", + raw: "'constructor'", + value: "constructor", + + range: [24, 37], + loc: { + start: { column: 12, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + 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 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: [], + 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 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..30151a9636c9 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,92 @@ +[ + 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: "'constructor'", + + range: [24, 37], + loc: { + start: { column: 12, 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: [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 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..5b9bbadd0d07 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot @@ -0,0 +1,78 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: false, + body: ClassBody { + type: "ClassBody", + body: [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Literal { + type: "Literal", + raw: "'constructor'", + value: "constructor", + + range: [24, 37], + loc: { + start: { column: 12, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + 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 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: [], + 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 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..30151a9636c9 --- /dev/null +++ b/packages/ast-spec/src/element/AccessorProperty/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,92 @@ +[ + 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: "'constructor'", + + range: [24, 37], + loc: { + start: { column: 12, 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: [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 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/fixture.ts b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/fixture.ts new file mode 100644 index 000000000000..581943685ffe --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + constructor +} diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..ed0ae4b78658 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > PropertyDefinition > _error_ > key-constructor-identifier > TSESTree - Error`] +TSError + 1 | class Foo { + 2 | constructor +> 3 | } + | ^ '(' expected. + 4 | diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..680ca51c5b1a --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > PropertyDefinition > _error_ > key-constructor-identifier > Babel - Error`] +BabelError + 1 | class Foo { +> 2 | constructor + | ^ Classes may not have a field named 'constructor'. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..dda789130572 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > PropertyDefinition > _error_ > key-constructor-identifier > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/fixture.ts b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/fixture.ts new file mode 100644 index 000000000000..5dc0386f85fe --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + '\u{63}onstructor' +} diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..53cc50de6a35 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > PropertyDefinition > _error_ > key-constructor-string-escaped > TSESTree - Error`] +TSError + 1 | class Foo { +> 2 | '\u{63}onstructor' + | ^^^^^^^^^^^^^^^^^^ Classes may not have a field named 'constructor'. + 3 | } + 4 | diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..130b27dcc413 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > PropertyDefinition > _error_ > key-constructor-string-escaped > Babel - Error`] +BabelError + 1 | class Foo { +> 2 | '\u{63}onstructor' + | ^ Classes may not have a field named 'constructor'. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..b3922ac52bf5 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > PropertyDefinition > _error_ > key-constructor-string-escaped > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/fixture.ts b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/fixture.ts new file mode 100644 index 000000000000..d29a35ffdbb7 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + 'constructor' +} diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..46f1efa8ad71 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > PropertyDefinition > _error_ > key-constructor-string > TSESTree - Error`] +TSError + 1 | class Foo { +> 2 | 'constructor' + | ^^^^^^^^^^^^^ Classes may not have a field named 'constructor'. + 3 | } + 4 | diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..eaac47437927 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > PropertyDefinition > _error_ > key-constructor-string > Babel - Error`] +BabelError + 1 | class Foo { +> 2 | 'constructor' + | ^ Classes may not have a field named 'constructor'. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..86e611b5b35d --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > PropertyDefinition > _error_ > key-constructor-string > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/fixture.ts b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/fixture.ts new file mode 100644 index 000000000000..8846529091d9 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + [constructor]; +} diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..036f1181e9b7 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,79 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: false, + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "constructor", + optional: false, + + range: [15, 26], + loc: { + start: { column: 3, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: 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 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: [], + 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 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..93100d49782c --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,82 @@ +[ + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [14, 15], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "constructor", + + range: [15, 26], + loc: { + start: { column: 3, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [26, 27], + loc: { + start: { column: 14, 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 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..036f1181e9b7 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot @@ -0,0 +1,79 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: false, + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "constructor", + optional: false, + + range: [15, 26], + loc: { + start: { column: 3, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: 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 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: [], + 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 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..93100d49782c --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,82 @@ +[ + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [14, 15], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "constructor", + + range: [15, 26], + loc: { + start: { column: 3, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [26, 27], + loc: { + start: { column: 14, 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 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/fixture.ts b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/fixture.ts new file mode 100644 index 000000000000..955e0ccdd551 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + ['constructor']; +} diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..a35a705153a3 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,78 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: false, + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Literal { + type: "Literal", + raw: "'constructor'", + value: "constructor", + + range: [15, 28], + loc: { + start: { column: 3, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [14, 30], + loc: { + start: { column: 2, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + ], + + range: [10, 32], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..d587dd5c180d --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,82 @@ +[ + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [14, 15], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + String { + type: "String", + value: "'constructor'", + + range: [15, 28], + loc: { + start: { column: 3, 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: [29, 30], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [31, 32], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..a35a705153a3 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot @@ -0,0 +1,78 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: false, + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Literal { + type: "Literal", + raw: "'constructor'", + value: "constructor", + + range: [15, 28], + loc: { + start: { column: 3, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [14, 30], + loc: { + start: { column: 2, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + ], + + range: [10, 32], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..d587dd5c180d --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,82 @@ +[ + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [14, 15], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + String { + type: "String", + value: "'constructor'", + + range: [15, 28], + loc: { + start: { column: 3, 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: [29, 30], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [31, 32], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/fixture.ts b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/fixture.ts new file mode 100644 index 000000000000..2d83385d93bf --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + accessor '\u{63}onstructor' +} diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..e2a98ea43e52 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractAccessorProperty > _error_ > key-constructor-string-escaped > TSESTree - Error`] +TSError + 1 | abstract class Foo { +> 2 | accessor '\u{63}onstructor' + | ^^^^^^^^^^^^^^^^^^ Classes may not have a field named 'constructor'. + 3 | } + 4 | diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..73035ad32ef8 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractAccessorProperty > _error_ > key-constructor-string-escaped > Babel - Error`] +BabelError + 1 | abstract class Foo { +> 2 | accessor '\u{63}onstructor' + | ^ Classes may not have a field named 'constructor'. (2:11) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..f4851859171d --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractAccessorProperty > _error_ > key-constructor-string-escaped > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/fixture.ts b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/fixture.ts new file mode 100644 index 000000000000..84fb8c4caa3f --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + accessor 'constructor' +} diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..97e1650fccca --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractAccessorProperty > _error_ > key-constructor-string > TSESTree - Error`] +TSError + 1 | abstract class Foo { +> 2 | accessor 'constructor' + | ^^^^^^^^^^^^^ Classes may not have a field named 'constructor'. + 3 | } + 4 | diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..9f0cd2ea63f0 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractAccessorProperty > _error_ > key-constructor-string > Babel - Error`] +BabelError + 1 | abstract class Foo { +> 2 | accessor 'constructor' + | ^ Classes may not have a field named 'constructor'. (2:11) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..c6bb852e8a96 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractAccessorProperty > _error_ > key-constructor-string > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/fixture.ts b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/fixture.ts new file mode 100644 index 000000000000..e267f66d845d --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + accessor [constructor]; +} diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..82d28f21758a --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,79 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "constructor", + optional: false, + + range: [33, 44], + loc: { + start: { column: 12, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [23, 46], + loc: { + start: { column: 2, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + ], + + range: [19, 48], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 48], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..4941bcdc220c --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,102 @@ +[ + 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: "accessor", + + range: [23, 31], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [32, 33], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "constructor", + + range: [33, 44], + loc: { + start: { column: 12, 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [45, 46], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [47, 48], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..82d28f21758a --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot @@ -0,0 +1,79 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "constructor", + optional: false, + + range: [33, 44], + loc: { + start: { column: 12, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [23, 46], + loc: { + start: { column: 2, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + ], + + range: [19, 48], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 48], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..4941bcdc220c --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,102 @@ +[ + 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: "accessor", + + range: [23, 31], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [32, 33], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "constructor", + + range: [33, 44], + loc: { + start: { column: 12, 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [45, 46], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [47, 48], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/fixture.ts b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/fixture.ts new file mode 100644 index 000000000000..dd4af2978b06 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + accessor ['constructor']; +} diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..c1ef23b02e88 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,78 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Literal { + type: "Literal", + raw: "'constructor'", + value: "constructor", + + range: [33, 46], + loc: { + start: { column: 12, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [23, 48], + loc: { + start: { column: 2, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + ], + + range: [19, 50], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 50], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 51], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..b3c97ec3fd6c --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,102 @@ +[ + 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: "accessor", + + range: [23, 31], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [32, 33], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + String { + type: "String", + value: "'constructor'", + + range: [33, 46], + loc: { + start: { column: 12, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [46, 47], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [47, 48], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [49, 50], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..c1ef23b02e88 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot @@ -0,0 +1,78 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: [ + AccessorProperty { + type: "AccessorProperty", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Literal { + type: "Literal", + raw: "'constructor'", + value: "constructor", + + range: [33, 46], + loc: { + start: { column: 12, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [23, 48], + loc: { + start: { column: 2, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + ], + + range: [19, 50], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 50], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 51], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..b3c97ec3fd6c --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractAccessorProperty/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,102 @@ +[ + 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: "accessor", + + range: [23, 31], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [32, 33], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + String { + type: "String", + value: "'constructor'", + + range: [33, 46], + loc: { + start: { column: 12, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [46, 47], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [47, 48], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [49, 50], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/fixture.ts b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/fixture.ts new file mode 100644 index 000000000000..a70cc4d0b84e --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + constructor +} diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..d4dac96c3819 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractPropertyDefinition > _error_ > key-constructor-identifier > TSESTree - Error`] +TSError + 1 | abstract class Foo { + 2 | constructor +> 3 | } + | ^ '(' expected. + 4 | diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..40ef5d1ba178 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractPropertyDefinition > _error_ > key-constructor-identifier > Babel - Error`] +BabelError + 1 | abstract class Foo { +> 2 | constructor + | ^ Classes may not have a field named 'constructor'. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..c03db2425706 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-identifier/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractPropertyDefinition > _error_ > key-constructor-identifier > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/fixture.ts b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/fixture.ts new file mode 100644 index 000000000000..3964b6ad536d --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + '\u{63}onstructor' +} diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..832a69aba874 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractPropertyDefinition > _error_ > key-constructor-string-escaped > TSESTree - Error`] +TSError + 1 | abstract class Foo { +> 2 | '\u{63}onstructor' + | ^^^^^^^^^^^^^^^^^^ Classes may not have a field named 'constructor'. + 3 | } + 4 | diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..972fa63aaaf7 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractPropertyDefinition > _error_ > key-constructor-string-escaped > Babel - Error`] +BabelError + 1 | abstract class Foo { +> 2 | '\u{63}onstructor' + | ^ Classes may not have a field named 'constructor'. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..c784e6ef8f7e --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string-escaped/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractPropertyDefinition > _error_ > key-constructor-string-escaped > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/fixture.ts b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/fixture.ts new file mode 100644 index 000000000000..773be1c59705 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + 'constructor' +} diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..e70630a8db65 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractPropertyDefinition > _error_ > key-constructor-string > TSESTree - Error`] +TSError + 1 | abstract class Foo { +> 2 | 'constructor' + | ^^^^^^^^^^^^^ Classes may not have a field named 'constructor'. + 3 | } + 4 | diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..0b562418bd7a --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractPropertyDefinition > _error_ > key-constructor-string > Babel - Error`] +BabelError + 1 | abstract class Foo { +> 2 | 'constructor' + | ^ Classes may not have a field named 'constructor'. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..e72b64ca43be --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/_error_/key-constructor-string/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > element > TSAbstractPropertyDefinition > _error_ > key-constructor-string > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/fixture.ts b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/fixture.ts new file mode 100644 index 000000000000..0035d60f9a3b --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + [constructor]; +} diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..a84556365ffa --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,79 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "constructor", + optional: false, + + range: [24, 35], + loc: { + start: { column: 3, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [23, 37], + loc: { + start: { column: 2, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + ], + + range: [19, 39], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 39], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..f33b1b154313 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,92 @@ +[ + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [23, 24], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "constructor", + + range: [24, 35], + loc: { + start: { column: 3, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [35, 36], + loc: { + start: { column: 14, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [36, 37], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [38, 39], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..a84556365ffa --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/3-Babel-AST.shot @@ -0,0 +1,79 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "constructor", + optional: false, + + range: [24, 35], + loc: { + start: { column: 3, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [23, 37], + loc: { + start: { column: 2, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + ], + + range: [19, 39], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 39], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..f33b1b154313 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-identifier-computed/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,92 @@ +[ + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [23, 24], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "constructor", + + range: [24, 35], + loc: { + start: { column: 3, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [35, 36], + loc: { + start: { column: 14, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [36, 37], + loc: { + start: { column: 15, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [38, 39], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/fixture.ts b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/fixture.ts new file mode 100644 index 000000000000..d7fa2a53c79b --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + ['constructor']; +} diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..880411e5b0a1 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,78 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Literal { + type: "Literal", + raw: "'constructor'", + value: "constructor", + + range: [24, 37], + loc: { + start: { column: 3, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [23, 39], + loc: { + start: { column: 2, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + ], + + range: [19, 41], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + implements: [], + 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 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..a82ebf95ff87 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,92 @@ +[ + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [23, 24], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + String { + type: "String", + value: "'constructor'", + + range: [24, 37], + loc: { + start: { column: 3, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [37, 38], + loc: { + start: { column: 16, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [38, 39], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [40, 41], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..880411e5b0a1 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/3-Babel-AST.shot @@ -0,0 +1,78 @@ +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: true, + declare: false, + decorators: [], + definite: false, + key: Literal { + type: "Literal", + raw: "'constructor'", + value: "constructor", + + range: [24, 37], + loc: { + start: { column: 3, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [23, 39], + loc: { + start: { column: 2, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + ], + + range: [19, 41], + loc: { + start: { column: 19, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "Foo", + optional: false, + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + implements: [], + 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 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..a82ebf95ff87 --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/fixtures/key-constructor-string-computed/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,92 @@ +[ + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [23, 24], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + String { + type: "String", + value: "'constructor'", + + range: [24, 37], + loc: { + start: { column: 3, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [37, 38], + loc: { + start: { column: 16, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [38, 39], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [40, 41], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 0ffc735c3a14..cbeac4bf65cc 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1524,6 +1524,16 @@ export class Converter { ); } + if ( + node.name.kind === SyntaxKind.StringLiteral && + node.name.text === 'constructor' + ) { + this.#throwError( + node.name, + "Classes may not have a field named 'constructor'.", + ); + } + const isAccessor = hasModifier(SyntaxKind.AccessorKeyword, node); const type = (() => { if (isAccessor) {