fix(file-extension-in-import): handle files with dots in basename#506
Merged
aladdin-add merged 2 commits intoeslint-community:masterfrom Jan 13, 2026
Conversation
When importing "./utils.client" where the actual file is "utils.client.ts", path.extname() treats ".client" as an extension. The resolver falls back to the raw path, causing the rule to think currentExt === actualExt (both ".client") and report no error. Fix: when resolved filePath doesn't exist as a file, search for files matching the full import basename and use the found file's actual extension. Also handle directory imports where the directory name contains dots (e.g., "my-things.client/index.ts"). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
6e765ad to
97395e4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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