Skip to content

Commit

Permalink
fix(eslint-plugin-esm): allow @types/* deps in dependencies when type…
Browse files Browse the repository at this point in the history
… importing
  • Loading branch information
zanminkian committed Nov 29, 2024
1 parent 41c783a commit b002aa9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/eslint-plugin-esm/src/rules/no-phantom-dep-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ export const noPhantomDepImports = createRule({
const isInDep = moduleName in dep || moduleName in peerDep;
const isInDev = moduleName in devDep;
if ("importKind" in node && node.importKind === "type") {
return moduleName.startsWith("@") && moduleName.includes("/")
? !(
isInDep ||
isInDev ||
`@types/${moduleName.slice(1).replace("/", "__")}` in devDep
)
: !(isInDep || isInDev || `@types/${moduleName}` in devDep);
const typeDepName = moduleName.startsWith("@")
? `@types/${moduleName.slice(1).replace("/", "__")}`
: `@types/${moduleName}`;
return !(
isInDep ||
isInDev ||
typeDepName in dep ||
typeDepName in devDep
);
} else {
return allowDevDependencies ? !(isInDep || isInDev) : !isInDep;
}
Expand Down

0 comments on commit b002aa9

Please sign in to comment.