Skip to content

Commit

Permalink
fix(eslint-plugin): [no-unnecessary-qualifier] handle nested namespac…
Browse files Browse the repository at this point in the history
…e id (#7883)
  • Loading branch information
yeonjuan committed Nov 11, 2023
1 parent a8830c6 commit a668f5b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts
Expand Up @@ -94,7 +94,6 @@ export default createRule({
accessedSymbol.flags,
sourceCode.getText(name),
);

return (
fromScope === undefined || symbolsAreEqual(accessedSymbol, fromScope)
);
Expand Down Expand Up @@ -160,7 +159,11 @@ export default createRule({
}

return {
TSModuleDeclaration: enterDeclaration,
'TSModuleDeclaration > TSModuleBlock'(
node: TSESTree.TSModuleBlock,
): void {
enterDeclaration(node.parent as TSESTree.TSModuleDeclaration);
},
TSEnumDeclaration: enterDeclaration,
'ExportNamedDeclaration[declaration.type="TSModuleDeclaration"]':
enterDeclaration,
Expand Down
Expand Up @@ -29,6 +29,12 @@ namespace Y {
}
`,
`
namespace A {}
namespace A.B {
export type Z = 1;
}
`,
`
enum A {
X,
Y,
Expand Down Expand Up @@ -146,6 +152,30 @@ namespace A {
},
{
code: `
namespace A {
export namespace B.C {
export type D = number;
const x: A.B.C.D = 3;
}
}
`,
errors: [
{
messageId,
type: AST_NODE_TYPES.TSQualifiedName,
},
],
output: `
namespace A {
export namespace B.C {
export type D = number;
const x: D = 3;
}
}
`,
},
{
code: `
namespace A {
export namespace B {
export const x = 3;
Expand Down

0 comments on commit a668f5b

Please sign in to comment.