Skip to content

Commit

Permalink
fix: 'isUseImported' checks all imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Rel1cx committed Jan 27, 2025
1 parent cc0aeaf commit 86e1364
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { compare } from "compare-versions";
import type { CamelCase } from "string-ts";

import { createRule } from "../utils";
import { isMatching } from "ts-pattern";

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

Expand Down Expand Up @@ -67,13 +68,11 @@ export default createRule<[], MessageID>({
if (node.source.value !== settings.importSource) {
return;
}
let isUseImported = false;
const isUseImported = node.specifiers
.some(isMatching({ local: { type: T.Identifier, name: "use" } }));
for (const specifier of node.specifiers) {
if (specifier.type !== T.ImportSpecifier) continue;
if (specifier.imported.type !== T.Identifier) continue;
if (specifier.imported.name === "use") {
isUseImported = true;
}
if (specifier.imported.name === "useContext") {
if (specifier.local.name !== "useContext") {
useContextAlias.add(specifier.local.name);
Expand Down

0 comments on commit 86e1364

Please sign in to comment.