From 5e37414f5dfb5c0b81351f2e9dd2395411189fa8 Mon Sep 17 00:00:00 2001 From: fisker Date: Sun, 28 Sep 2025 22:34:33 +0800 Subject: [PATCH 1/8] fix(typescript-estree): forbid abstract method to have implementation --- .../fixture.ts | 3 +++ .../snapshots/1-TSESTree-Error.shot | 9 +++++++++ .../snapshots/2-Babel-Error.shot | 10 ++++++++++ .../snapshots/3-Alignment-Error.shot | 4 ++++ packages/typescript-estree/src/convert.ts | 15 +++++++++++---- packages/typescript-estree/src/node-utils.ts | 9 +++++++++ 6 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/fixture.ts create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/1-TSESTree-Error.shot create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/2-Babel-Error.shot create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/3-Alignment-Error.shot diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/fixture.ts new file mode 100644 index 000000000000..80fe821c5d29 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + abstract method() { } +} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..85fc7977527b --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-method-with-implementation > TSESTree - Error`] +TSError + 1 | abstract class Foo { +> 2 | abstract method() { } + | ^^^^^^ Method ' method' cannot have an implementation because it is marked abstract. + 3 | } + 4 | diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..c345ce0399ec --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-method-with-implementation > Babel - Error`] +BabelError + 1 | abstract class Foo { +> 2 | abstract method() { } + | ^ Method 'method' cannot have an implementation because it is marked abstract. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..fff6cbc7c6ce --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-method-with-implementation > Error Alignment`] +Both errored diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index bec26fede610..5e4f50d1c431 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -14,6 +14,7 @@ import { getDecorators, getModifiers } from './getModifiers'; import { canContainDirective, createError, + declarationNameToString, findNextToken, getBinaryExpressionType, getContainingFunction, @@ -1599,6 +1600,15 @@ export class Converter { } // otherwise, it is a non-type accessor - intentional fallthrough case SyntaxKind.MethodDeclaration: { + const isAbstract = hasModifier(SyntaxKind.AbstractKeyword, node); + + if (isAbstract && node.body) { + this.#throwError( + node.name, + `Method '${declarationNameToString(node.name, this.ast)}' cannot have an implementation because it is marked abstract.`, + ); + } + const method = this.createNode< TSESTree.FunctionExpression | TSESTree.TSEmptyBodyFunctionExpression >(node, { @@ -1654,10 +1664,7 @@ export class Converter { /** * TypeScript class methods can be defined as "abstract" */ - const methodDefinitionType = hasModifier( - SyntaxKind.AbstractKeyword, - node, - ) + const methodDefinitionType = isAbstract ? AST_NODE_TYPES.TSAbstractMethodDefinition : AST_NODE_TYPES.MethodDefinition; diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index 640b493d63bb..34e1bf05a85f 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -919,3 +919,12 @@ export function getNamespaceModifiers( } return modifiers; } + +// `ts.declarationNameToString` +export function declarationNameToString( + name: ts.Node, + ast: ts.SourceFile, +): string { + const text = ast.text.slice(name.pos, name.end); + return text || '(Missing)'; +} From 7fbd6e68f3bdabf9acf24380fafdc13c1348cafb Mon Sep 17 00:00:00 2001 From: fisker Date: Sun, 28 Sep 2025 23:02:00 +0800 Subject: [PATCH 2/8] One more test --- packages/typescript-estree/src/node-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index 34e1bf05a85f..11c7c3c33db2 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -925,6 +925,6 @@ export function declarationNameToString( name: ts.Node, ast: ts.SourceFile, ): string { - const text = ast.text.slice(name.pos, name.end); + const text = ast.text.slice(name.pos, name.end).trimStart(); return text || '(Missing)'; } From f9366212b1a69ac974c2c91b4f252e2245980fa1 Mon Sep 17 00:00:00 2001 From: fisker Date: Sun, 28 Sep 2025 23:07:10 +0800 Subject: [PATCH 3/8] Fix tests? --- .../rules/naming-convention/naming-convention.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts index c43b293c686e..613217e867ac 100644 --- a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts +++ b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts @@ -632,7 +632,7 @@ ruleTester.run('naming-convention', rule, { { code: ` class Ignored { - private static abstract some_name() {} + private static some_name() {} IgnoredDueToModifiers() {} } `, @@ -644,7 +644,7 @@ ruleTester.run('naming-convention', rule, { }, { format: ['UPPER_CASE'], - modifiers: ['abstract', 'static'], + modifiers: ['static'], selector: 'classMethod', }, ], @@ -2118,10 +2118,10 @@ ruleTester.run('naming-convention', rule, { } } abstract class foo { - public abstract Bar() { + public Bar() { return 42; } - public abstract async async_bar() { + public async async_bar() { return 42; } } From a187b903532e06139972cfca46fe79316ce0425f Mon Sep 17 00:00:00 2001 From: fisker Date: Mon, 29 Sep 2025 23:42:37 +0800 Subject: [PATCH 4/8] Fix rule tests --- packages/eslint-plugin/tests/rules/member-ordering.test.ts | 2 +- .../tests/rules/naming-convention/naming-convention.test.ts | 4 ++-- .../eslint-plugin/tests/rules/promise-function-async.test.ts | 5 ----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index d53fe04d6d22..28e0b185cef6 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -4465,7 +4465,7 @@ abstract class Foo { B: string; public C() {} private D() {} - abstract E() {} + E() {} } `, errors: [ diff --git a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts index 613217e867ac..076534645409 100644 --- a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts +++ b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts @@ -1875,7 +1875,7 @@ ruleTester.run('naming-convention', rule, { { code: ` class Ignored { - private static abstract some_name() {} + private static some_name() {} IgnoredDueToModifiers() {} } `, @@ -1886,7 +1886,7 @@ ruleTester.run('naming-convention', rule, { }, { format: ['snake_case'], - modifiers: ['abstract', 'static'], + modifiers: ['static'], selector: 'classMethod', }, ], diff --git a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts index 2b6ddbdb9870..587445eba9b9 100644 --- a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts +++ b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts @@ -156,11 +156,6 @@ function foo(): Promise | boolean { code: ` abstract class Test { abstract test1(): Promise; - - // abstract method with body is always an error but it still parses into valid AST - abstract test2(): Promise { - return Promise.resolve(1); - } } `, }, From 8c9ad396e6d4f1ae9ad6a64932e6b6dd644c1567 Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 30 Sep 2025 00:02:38 +0800 Subject: [PATCH 5/8] Fix test --- .../snapshots/1-TSESTree-Error.shot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/1-TSESTree-Error.shot index 85fc7977527b..a65c609416d4 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/1-TSESTree-Error.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-method-with-implementation/snapshots/1-TSESTree-Error.shot @@ -4,6 +4,6 @@ exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-meth TSError 1 | abstract class Foo { > 2 | abstract method() { } - | ^^^^^^ Method ' method' cannot have an implementation because it is marked abstract. + | ^^^^^^ Method 'method' cannot have an implementation because it is marked abstract. 3 | } 4 | From 101d79030bcd7158a34c71d4836a1d101523a06d Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 30 Sep 2025 00:23:47 +0800 Subject: [PATCH 6/8] Fix test --- .../eslint-plugin/tests/rules/member-ordering.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index 28e0b185cef6..f885b156163c 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -4478,6 +4478,15 @@ abstract class Foo { line: 4, messageId: 'incorrectGroupOrder', }, + { + column: 3, + data: { + name: 'E', + rank: 'private instance method', + }, + line: 7, + messageId: 'incorrectGroupOrder', + }, ], }, { From 5ca86a8ba75e6c450e641360eaf7227264b3086c Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 30 Sep 2025 00:57:46 +0800 Subject: [PATCH 7/8] Accessor --- .../abstract-getter-with-implementation/fixture.ts | 3 +++ .../snapshots/1-TSESTree-Error.shot | 9 +++++++++ .../snapshots/2-Babel-Error.shot | 10 ++++++++++ .../snapshots/3-Alignment-Error.shot | 4 ++++ .../abstract-setter-with-implementation/fixture.ts | 3 +++ .../snapshots/1-TSESTree-Error.shot | 9 +++++++++ .../snapshots/2-Babel-Error.shot | 10 ++++++++++ .../snapshots/3-Alignment-Error.shot | 4 ++++ packages/typescript-estree/src/convert.ts | 5 ++++- 9 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/fixture.ts create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/1-TSESTree-Error.shot create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/2-Babel-Error.shot create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/3-Alignment-Error.shot create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/fixture.ts create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/1-TSESTree-Error.shot create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/2-Babel-Error.shot create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/3-Alignment-Error.shot diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/fixture.ts new file mode 100644 index 000000000000..0ac2bfca1dfd --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + abstract get getter() { } +} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..d7c0c1bcc98a --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-getter-with-implementation > TSESTree - Error`] +TSError + 1 | abstract class Foo { +> 2 | abstract get getter() { } + | ^^^^^^ An abstract accessor cannot have an implementation. + 3 | } + 4 | diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..fe0fe6660cf0 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-getter-with-implementation > Babel - Error`] +BabelError + 1 | abstract class Foo { +> 2 | abstract get getter() { } + | ^ Method 'getter' cannot have an implementation because it is marked abstract. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..748024e02a80 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-getter-with-implementation/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-getter-with-implementation > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/fixture.ts new file mode 100644 index 000000000000..fa7888c34cc9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + abstract set setter(v) { } +} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..febb4fe5dcde --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-setter-with-implementation > TSESTree - Error`] +TSError + 1 | abstract class Foo { +> 2 | abstract set setter(v) { } + | ^^^^^^ An abstract accessor cannot have an implementation. + 3 | } + 4 | diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..c45ee034b7c3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-setter-with-implementation > Babel - Error`] +BabelError + 1 | abstract class Foo { +> 2 | abstract set setter(v) { } + | ^ Method 'setter' cannot have an implementation because it is marked abstract. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..1e222f7febc0 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-setter-with-implementation/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-setter-with-implementation > Error Alignment`] +Both errored diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 5e4f50d1c431..8f03943b36fc 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1605,7 +1605,10 @@ export class Converter { if (isAbstract && node.body) { this.#throwError( node.name, - `Method '${declarationNameToString(node.name, this.ast)}' cannot have an implementation because it is marked abstract.`, + node.kind === SyntaxKind.GetAccessor || + node.kind === SyntaxKind.SetAccessor + ? 'An abstract accessor cannot have an implementation.' + : `Method '${declarationNameToString(node.name, this.ast)}' cannot have an implementation because it is marked abstract.`, ); } From c30d11de248abb6d240f35b20c0a00a0ea74c6cc Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 30 Sep 2025 00:58:12 +0800 Subject: [PATCH 8/8] constructor --- .../fixtures/_error_/abstract-constructor/fixture.ts | 3 +++ .../snapshots/1-TSESTree-Error.shot | 9 +++++++++ .../abstract-constructor/snapshots/2-Babel-Error.shot | 10 ++++++++++ .../snapshots/3-Alignment-Error.shot | 4 ++++ 4 files changed, 26 insertions(+) create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/fixture.ts create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/1-TSESTree-Error.shot create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/2-Babel-Error.shot create mode 100644 packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/3-Alignment-Error.shot diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/fixture.ts new file mode 100644 index 000000000000..bd45e0a8a625 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/fixture.ts @@ -0,0 +1,3 @@ +abstract class Foo { + abstract constructor() { } +} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..8a67121b79c1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,9 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-constructor > TSESTree - Error`] +TSError + 1 | abstract class Foo { +> 2 | abstract constructor() { } + | ^^^^^^^^ 'abstract' modifier can only appear on a class, method, or property declaration. + 3 | } + 4 | diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..b78e289f0c55 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/2-Babel-Error.shot @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-constructor > Babel - Error`] +BabelError + 1 | abstract class Foo { +> 2 | abstract constructor() { } + | ^ Method 'constructor' cannot have an implementation because it is marked abstract. (2:2) + 3 | } + 4 | + diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..dbd705849820 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/abstract-constructor/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > declaration > ClassDeclaration > _error_ > abstract-constructor > Error Alignment`] +Both errored