From 7252cca8799625c2fe07506fe742b967363835b0 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 13 Sep 2024 01:53:47 +0200 Subject: [PATCH] fix: do not report as unused import when `parent` is null, fix #100 --- src/rules/load-rule.ts | 2 +- src/rules/predicates.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rules/load-rule.ts b/src/rules/load-rule.ts index f329c8a..4bc4d8f 100644 --- a/src/rules/load-rule.ts +++ b/src/rules/load-rule.ts @@ -1,5 +1,5 @@ import { Rule } from "eslint"; -import { createRequire } from 'module' +import { createRequire } from "module"; let rule: Rule.RuleModule | undefined; diff --git a/src/rules/predicates.ts b/src/rules/predicates.ts index 4c8be9a..ea9f85a 100644 --- a/src/rules/predicates.ts +++ b/src/rules/predicates.ts @@ -23,7 +23,9 @@ function makePredicate( ? /^Import(|Default|Namespace)Specifier$/.test(parent.type) == isImport ? Object.assign(problem, addFixer?.(parent, sourceCode)) : false - : problem; + : isImport + ? false + : problem; }; }