Skip to content

Commit

Permalink
fix(scope-manager): correct decorators(.length) check in ClassVisitor…
Browse files Browse the repository at this point in the history
… for methods (#7334)

* fix(scope-manager): correct decorators(.length) check in ClassVisitor for methods

* Aha, a missing unit test
  • Loading branch information
JoshuaKGoldberg committed Jul 29, 2023
1 parent 076543e commit abbb6c2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts
Expand Up @@ -536,6 +536,18 @@ ruleTester.run('consistent-type-imports', rule, {
parserOptions: withMetaConfigParserOptions,
},

// https://github.com/typescript-eslint/typescript-eslint/issues/7327
{
code: `
import type { ClassA } from './classA';
export class ClassB {
public constructor(node: ClassA) {}
}
`,
parserOptions: withMetaConfigParserOptions,
},

// https://github.com/typescript-eslint/typescript-eslint/issues/2989
`
import type * as constants from './constants';
Expand Down
2 changes: 1 addition & 1 deletion packages/scope-manager/src/referencer/ClassVisitor.ts
Expand Up @@ -192,7 +192,7 @@ class ClassVisitor extends Visitor {
if (
!withMethodDecorators &&
methodNode.kind === 'constructor' &&
this.#classNode.decorators
this.#classNode.decorators.length
) {
withMethodDecorators = true;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit abbb6c2

Please sign in to comment.