Skip to content

fix(eslint-plugin): [no-shadow] don't report unnecessarily on valid ways of using module augmentation #10616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/eslint-plugin/src/rules/no-shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,8 @@ export default createRule<Options, MessageIds>({
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)
);
}

Expand Down
144 changes: 60 additions & 84 deletions packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand All @@ -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;
`,
Expand Down Expand Up @@ -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;
}
}
`,
},
],
});
Loading