Skip to content
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

fix(eslint-plugin): [no-unnecessary-qualifier] handle merge namespace with enum #8591

Merged
merged 2 commits into from Mar 17, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts
Expand Up @@ -93,9 +93,8 @@ export default createRule({
accessedSymbol.flags,
context.sourceCode.getText(name),
);
return (
fromScope === undefined || symbolsAreEqual(accessedSymbol, fromScope)
);

return !!fromScope && symbolsAreEqual(accessedSymbol, fromScope);
Copy link
Contributor Author

@yeonjuan yeonjuan Mar 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// If the symbol in scope is different, the qualifier is necessary.

According to the comment at line 89, if a symbol is not in scope, it should not be considered unnecessary. If any counterexample exits, please let me know.

}

function visitNamespaceAccess(
Expand Down
Expand Up @@ -57,6 +57,30 @@ namespace X {
`
namespace X {
const z = X.y;
}
`,
`
enum Foo {
One,
}

namespace Foo {
export function bar() {
return Foo.One;
}
}
`,
`
namespace Foo {
export enum Foo {
One,
}
}

namespace Foo {
export function bar() {
return Foo.One;
}
}
`,
],
Expand Down