fix(file-extension-in-import): handle files with dots in basename #506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Created by Claude Code and reviewed by @patricktree
Fixes false negative when importing files like
./utils.clientwhere actual file isutils.client.ts.Problem
path.extname("./utils.client")returns.client, treating it as the extension. When the resolver can't find an exact match, it falls back to the raw path. The rule then seescurrentExt === actualExt(both.client) and reports no error—missing that.tsshould be required.Same issue applies to directories with dots (e.g.,
my-things.client/index.ts).Fix
When the resolved
filePathdoesn't exist as a file, search for files matching the full import basename and use the found file's actual extension.Testing
utils.client.ts,my-things.client/index.tsnpm run test:mocha tests/lib/rules/file-extension-in-import.jspasses