Skip to content

Commit fe3121a

Browse files
authored
perf: make ExportMap util and no-cycle rule faster (#109)
1 parent e340575 commit fe3121a

9 files changed

+178
-136
lines changed

.changeset/heavy-kangaroos-relax.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-x": patch
3+
---
4+
5+
Make `eslint-plugin-import-x` overall faster by refactoring the `ExportMap` util

.changeset/wicked-mangos-suffer.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-x": patch
3+
---
4+
5+
Make `no-cycle` rule faster

src/rules/no-cycle.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {
1212
resolve,
1313
} from '../utils'
1414

15-
type Options = ModuleOptions & {
15+
type Options = {
1616
allowUnsafeDynamicCyclicDependency?: boolean
1717
ignoreExternal?: boolean
1818
maxDepth?: number
19-
}
19+
} & ModuleOptions
2020

2121
type MessageId = 'cycle'
2222

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

86-
const ignoreModule = (name: string) =>
87-
options.ignoreExternal &&
88-
isExternalModule(name, resolve(name, context)!, context)
86+
const ignoreModule = options.ignoreExternal
87+
? (name: string) =>
88+
isExternalModule(name, resolve(name, context)!, context)
89+
: () => false
8990

9091
return {
9192
...moduleVisitor(function checkSourceValue(sourceNode, importer) {

0 commit comments

Comments
 (0)