Skip to content

fix(file-extension-in-import): handle directory index imports#499

Merged
aladdin-add merged 1 commit intoeslint-community:masterfrom
patricktree:fix-file-extension-rule-issue-for-directory-indexjs-import
Jan 13, 2026
Merged

fix(file-extension-in-import): handle directory index imports#499
aladdin-add merged 1 commit intoeslint-community:masterfrom
patricktree:fix-file-extension-rule-issue-for-directory-indexjs-import

Conversation

@patricktree
Copy link

@patricktree patricktree commented Jan 8, 2026

Fixes #403

Summary

  • lookup index.* extensions for directory imports so file-extension-in-import knows what to require
  • reuse the rule's try-extensions order and convert the resolved extension before comparing/fixing
  • update the fixer to append index (plus a slash when needed) and add fixtures/tests covering both ./dir and ./dir/

Testing

  • npm run test:mocha tests/lib/rules/file-extension-in-import.js runs through

Notes

@aladdin-add aladdin-add force-pushed the fix-file-extension-rule-issue-for-directory-indexjs-import branch from 44b9635 to ad75460 Compare January 8, 2026 14:27
@patricktree patricktree force-pushed the fix-file-extension-rule-issue-for-directory-indexjs-import branch from ad75460 to 1d67d2d Compare January 10, 2026 15:36
Copy link

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

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

LGTM, a big thanks! Leaving open for two more days to give others chance to review before merging.

@patricktree
Copy link
Author

just FYI when we land this PR and #506 the https://github.com/open-telemetry/opentelemetry-js repo can use file-extension-in-import to take a step towards proper ESM publishing, see also open-telemetry/opentelemetry-js#4898 (comment)

Copy link

@scagood scagood left a comment

Choose a reason for hiding this comment

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

Are we sure we want to add a fixer for /index here?

That feels like a little out of scope for file-extension-in-import -- That being said I am happy with this

@aladdin-add aladdin-add merged commit 754a1a6 into eslint-community:master Jan 13, 2026
29 checks passed
@patricktree patricktree deleted the fix-file-extension-rule-issue-for-directory-indexjs-import branch January 13, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: file-extension-in-import cannot fix correctly for barrel file

3 participants