diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts b/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts index 56286b8510cb..4650ff5905fa 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts @@ -94,7 +94,6 @@ export default createRule({ accessedSymbol.flags, sourceCode.getText(name), ); - return ( fromScope === undefined || symbolsAreEqual(accessedSymbol, fromScope) ); @@ -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, diff --git a/packages/eslint-plugin/tests/rules/no-unnecessary-qualifier.test.ts b/packages/eslint-plugin/tests/rules/no-unnecessary-qualifier.test.ts index e31a8a99ecde..5f118f55ff69 100644 --- a/packages/eslint-plugin/tests/rules/no-unnecessary-qualifier.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unnecessary-qualifier.test.ts @@ -29,6 +29,12 @@ namespace Y { } `, ` +namespace A {} +namespace A.B { + export type Z = 1; +} + `, + ` enum A { X, Y, @@ -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; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy