Skip to content

fix: do not consider resolved path in extensions rule #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
6 changes: 3 additions & 3 deletions src/rules/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ export default createRule<Options, MessageId>({

const resolvedPath = resolve(importPath, context)

// get extension from resolved path, if possible.
// for unresolved, use source value.
const extension = path.extname(resolvedPath || importPath).slice(1)
Copy link
Member

@JounQin JounQin Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is incorrect for resolving .xyz but ./abc.js or ./abc is imported.

const extension =
path.extname(importPath).slice(1) ||
(resolvedPath ? path.extname(resolvedPath).slice(1) : '')

// determine if this is a module
const isPackage =
Expand Down
Loading