diff --git a/packages/eslint-plugin/src/rules/no-shadow.ts b/packages/eslint-plugin/src/rules/no-shadow.ts index fb4b83b9da9f..e6ceb4f3b918 100644 --- a/packages/eslint-plugin/src/rules/no-shadow.ts +++ b/packages/eslint-plugin/src/rules/no-shadow.ts @@ -279,9 +279,8 @@ export default createRule({ scope, firstDefinition.parent.source.value, ) && - secondDefinition.node.type === AST_NODE_TYPES.TSInterfaceDeclaration && - secondDefinition.node.parent.type === - AST_NODE_TYPES.ExportNamedDeclaration + (secondDefinition.node.type === AST_NODE_TYPES.TSInterfaceDeclaration || + secondDefinition.node.type === AST_NODE_TYPES.TSTypeAliasDeclaration) ); } diff --git a/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts b/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts index e4c420092c93..22e04824b877 100644 --- a/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts +++ b/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts @@ -415,48 +415,6 @@ declare module 'baz' { }, { code: ` -import type { Foo } from 'bar'; - -declare module 'bar' { - export type Foo = string; -} - `, - errors: [ - { - data: { - name: 'Foo', - shadowedColumn: 15, - shadowedLine: 2, - }, - messageId: 'noShadow', - type: AST_NODE_TYPES.Identifier, - }, - ], - }, - { - code: ` -import type { Foo } from 'bar'; - -declare module 'bar' { - interface Foo { - x: string; - } -} - `, - errors: [ - { - data: { - name: 'Foo', - shadowedColumn: 15, - shadowedLine: 2, - }, - messageId: 'noShadow', - type: AST_NODE_TYPES.Identifier, - }, - ], - }, - { - code: ` import { type Foo } from 'bar'; declare module 'baz' { @@ -479,48 +437,6 @@ declare module 'baz' { }, { code: ` -import { type Foo } from 'bar'; - -declare module 'bar' { - export type Foo = string; -} - `, - errors: [ - { - data: { - name: 'Foo', - shadowedColumn: 15, - shadowedLine: 2, - }, - messageId: 'noShadow', - type: AST_NODE_TYPES.Identifier, - }, - ], - }, - { - code: ` -import { type Foo } from 'bar'; - -declare module 'bar' { - interface Foo { - x: string; - } -} - `, - errors: [ - { - data: { - name: 'Foo', - shadowedColumn: 15, - shadowedLine: 2, - }, - messageId: 'noShadow', - type: AST_NODE_TYPES.Identifier, - }, - ], - }, - { - code: ` let x = foo((x, y) => {}); let y; `, @@ -1479,5 +1395,65 @@ type A = 1; `, options: [{ hoist: 'functions' }], }, + { + code: ` +import type { Foo } from 'bar'; + +declare module 'bar' { + export type Foo = string; +} + `, + }, + { + code: ` +import type { Foo } from 'bar'; + +declare module 'bar' { + interface Foo { + x: string; + } +} + `, + }, + { + code: ` +import { type Foo } from 'bar'; + +declare module 'bar' { + export type Foo = string; +} + `, + }, + { + code: ` +import { type Foo } from 'bar'; + +declare module 'bar' { + export interface Foo { + x: string; + } +} + `, + }, + { + code: ` +import { type Foo } from 'bar'; + +declare module 'bar' { + type Foo = string; +} + `, + }, + { + code: ` +import { type Foo } from 'bar'; + +declare module 'bar' { + interface Foo { + x: string; + } +} + `, + }, ], });