Skip to content

Commit

Permalink
perf: make ExportMap util and no-cycle rule faster (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jul 11, 2024
1 parent e340575 commit fe3121a
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 136 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-kangaroos-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-import-x": patch
---

Make `eslint-plugin-import-x` overall faster by refactoring the `ExportMap` util
5 changes: 5 additions & 0 deletions .changeset/wicked-mangos-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-import-x": patch
---

Make `no-cycle` rule faster
11 changes: 6 additions & 5 deletions src/rules/no-cycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
resolve,
} from '../utils'

type Options = ModuleOptions & {
type Options = {
allowUnsafeDynamicCyclicDependency?: boolean
ignoreExternal?: boolean
maxDepth?: number
}
} & ModuleOptions

type MessageId = 'cycle'

Expand Down Expand Up @@ -83,9 +83,10 @@ export = createRule<[Options?], MessageId>({
? options.maxDepth
: Number.POSITIVE_INFINITY

const ignoreModule = (name: string) =>
options.ignoreExternal &&
isExternalModule(name, resolve(name, context)!, context)
const ignoreModule = options.ignoreExternal
? (name: string) =>
isExternalModule(name, resolve(name, context)!, context)
: () => false

return {
...moduleVisitor(function checkSourceValue(sourceNode, importer) {
Expand Down
Loading

0 comments on commit fe3121a

Please sign in to comment.