Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-doors-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-import-x": patch
---

Fix regression in rule `no-unused-modules` which would incorrectly initialize option `src` to `[]` instead of `[process.cwd()]`, breaking file discovery.
15 changes: 4 additions & 11 deletions src/rules/no-unused-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,6 @@ const determineUsage = () => {
}
}

const getSrc = (src?: string[]) => {
if (src) {
return src
}
return [process.cwd()]
}

/**
* prepare the lists of existing imports and exports - should only be executed once at
* the start of a new eslint run
Expand All @@ -306,7 +299,7 @@ let srcFiles: Set<string>
let lastPrepareKey: string

const doPreparation = (
src: string[] = [],
src: string[],
ignoreExports: string[],
context: RuleContext,
) => {
Expand All @@ -324,7 +317,7 @@ const doPreparation = (
ignoredFiles.clear()
filesOutsideSrc.clear()

srcFiles = resolveFiles(getSrc(src), ignoreExports, context)
srcFiles = resolveFiles(src, ignoreExports, context)
prepareImportsAndExports(srcFiles, context)
determineUsage()
lastPrepareKey = prepareKey
Expand Down Expand Up @@ -486,7 +479,7 @@ export = createRule<Options[], MessageId>({
defaultOptions: [],
create(context) {
const {
src,
src = [process.cwd()],
ignoreExports = [],
missingExports,
unusedExports,
Expand Down Expand Up @@ -559,7 +552,7 @@ export = createRule<Options[], MessageId>({

// make sure file to be linted is included in source files
if (!srcFiles.has(filename)) {
srcFiles = resolveFiles(getSrc(src), ignoreExports, context)
srcFiles = resolveFiles(src, ignoreExports, context)
if (!srcFiles.has(filename)) {
filesOutsideSrc.add(filename)
return
Expand Down
Loading