Skip to content

Commit 86e1364

Browse files
committed
fix: 'isUseImported' checks all imports
1 parent cc0aeaf commit 86e1364

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-use-context.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { compare } from "compare-versions";
66
import type { CamelCase } from "string-ts";
77

88
import { createRule } from "../utils";
9+
import { isMatching } from "ts-pattern";
910

1011
export const RULE_NAME = "no-use-context";
1112

@@ -67,13 +68,11 @@ export default createRule<[], MessageID>({
6768
if (node.source.value !== settings.importSource) {
6869
return;
6970
}
70-
let isUseImported = false;
71+
const isUseImported = node.specifiers
72+
.some(isMatching({ local: { type: T.Identifier, name: "use" } }));
7173
for (const specifier of node.specifiers) {
7274
if (specifier.type !== T.ImportSpecifier) continue;
7375
if (specifier.imported.type !== T.Identifier) continue;
74-
if (specifier.imported.name === "use") {
75-
isUseImported = true;
76-
}
7776
if (specifier.imported.name === "useContext") {
7877
if (specifier.local.name !== "useContext") {
7978
useContextAlias.add(specifier.local.name);

0 commit comments

Comments
 (0)