Skip to content

feat(linter): implement import/extensions #11548

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

Merged
merged 73 commits into from
Jun 13, 2025

Conversation

taearls
Copy link
Contributor

@taearls taearls commented Jun 7, 2025

Added the rule for import/extensions from the eslint-plugin-import package.

I ported the tests from https://github.com/import-js/eslint-plugin-import/blob/main/tests/src/rules/extensions.js, which needed to be done manually because the rule generation script did not work for me.

One difference between my tests and theirs is that their tests occasionally will pass eslint configuration settings on a per test basis. For our purposes, this didn't seem necessary, because we just need to pass the rule-specific configurations.

I categorized this rule as performance in light of this recommendation from the Vite docs: https://github.com/import-js/eslint-plugin-import/blob/main/tests/src/rules/extensions.js

@taearls taearls requested a review from camc314 as a code owner June 7, 2025 14:54
@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI labels Jun 7, 2025
@taearls taearls changed the title linter: add import/extensions rule feat(linter): add import/extensions rule Jun 7, 2025
@github-actions github-actions bot added the C-enhancement Category - New feature or request label Jun 7, 2025
Copy link

codspeed-hq bot commented Jun 7, 2025

CodSpeed Instrumentation Performance Report

Merging #11548 will not alter performance

Comparing taearls:tyler/import/extensions (d870279) with main (4ca659c)

Summary

✅ 38 untouched benchmarks

@github-actions github-actions bot added the A-parser Area - Parser label Jun 8, 2025
@camc314
Copy link
Contributor

camc314 commented Jun 13, 2025

I categorized this rule as performance in light of this recommendation from the Vite docs: https://github.com/import-js/eslint-plugin-import/blob/main/tests/src/rules/extensions.js

I changed the category to restriction, as I think as:

  1. having a config of never would make the perf slower?
  2. forcing the file extension can be confusing when using ts, e.g. to i use the TS extension, and have it transformed to the JS at build time, or do i use the js extension, as that will be the extension of the TS file at runtime?

@camc314 camc314 changed the title feat(linter): add import/extensions rule feat(linter): implement import/extensions Jun 13, 2025
@camc314 camc314 merged commit 52ecc87 into oxc-project:main Jun 13, 2025
22 checks passed
@camc314
Copy link
Contributor

camc314 commented Jun 13, 2025

thank you!

@taearls
Copy link
Contributor Author

taearls commented Jun 13, 2025

I categorized this rule as performance in light of this recommendation from the Vite docs: https://github.com/import-js/eslint-plugin-import/blob/main/tests/src/rules/extensions.js

I changed the category to restriction, as I think as:

  1. having a config of never would make the perf slower?
  2. forcing the file extension can be confusing when using ts, e.g. to i use the TS extension, and have it transformed to the JS at build time, or do i use the js extension, as that will be the extension of the TS file at runtime?

Yeah that's a valid point, makes sense.

Boshen added a commit that referenced this pull request Jun 19, 2025
## [1.2.0] - 2025-06-19

### 🚀 Features

- 8c341a2 sema/check: Ts setters cannot have initializers (#11695) (Don
Isaac)
- 38dc614 oxc_linter: Reuse allocators (#11736) (camc314)
- bf8263d playground: Allow specifying a JSON string as the linter
config (#11710) (Nicholas Rayburn)
- 0b4261b vscode: Add `oxc.requireConfig` configuration (#11700) (Sysix)
- 52ecc87 linter: Implement import/extensions (#11548) (Tyler Earls)
- 094b81c language_server: Add `unusedDisableDirectives` option (#11645)
(Sysix)

### 🐛 Bug Fixes

- 3d88eeb linter/no-console: False negative when `console.*` methods are
used as args to functions (#11790) (camc314)
- c80e405 linter/no-new-wrappers: Fix panic in fixer with multi byte
chars (#11773) (camc314)
- e58a0b0 linter: Panic in unicorn/consistent-function-scoping (#11772)
(camc314)
- 80c87d4 linter: Typo in typescript/consistent-index-object-style
(#11744) (camc314)
- ff775e9 linter/consistent-function-scoping: Descriptive diagnostic
labels (#11682) (Don Isaac)
- 989634a linter/no-inner-declaration: False negative with for loops
(#11692) (camc314)
- b272b91 linter/no-undef: False negative with unresolved ref after type
ref (#11721) (camc314)
- 6252275 linter: Panic in import/extensions with empty file names
(#11720) (camc314)
- f34e432 linter: Use fixer::noop in dangerous cases for eslint/no-var
(#11693) (camc314)
- 6c2b41c linter/consistent-function-scoping: Allow functions in TS
modules/namespaces (#11681) (Don Isaac)
- 2ca1c70 linter/exhaustive-deps: False positive with TS Non null
assertion operator (#11690) (camc314)
- ee15f7d linter: False negative in typescript/prefer-function-type
(#11674) (camc314)
- abd0441 linter: Add missing menuitemradio and menutitemcheckbox roles
(#11651) (Daniel Flynn)
- 8776301 linter/no-inner-declarations: Flag `var` statement as body of
`for` loop (#11632) (overlookmotel)

### 🚜 Refactor

- 5ca3d04 ast: Add `TSArrayType` as `AstKind` (#11745) (camchenry)
- abdbaa9 language_server: Use rule name directly from OxcCode instead
of parsing out of the stringified version of OxcCode (#11714) (Nicholas
Rayburn)
- 219adcc ast: Don't generate AstKind for ArrayExpressionElement
(#11684) (Ulrich Stark)
- c1be6b8 linter: Shorten Span construction (#11686) (Ulrich Stark)
- 4ca659c linter: Cleanup typescript/prefer-function-type (#11672) (Brad
Dunbar)
- 8e30c5f ast: Don't generate AstKind for ForStatementInit (#11617)
(Ulrich Stark)

### 📚 Documentation

- ea6ce9d linter: Fix typo in import/no-namespace (#11741) (camc314)
- 8b6076e linter: Document options for the `typescript/array-type` rule
(#11665) (yefan)

### ⚡ Performance

- f539f64 allocator: Remove `Arc` from `AllocatorPool` (#11760)
(overlookmotel)
- cfdc518 linter/no-inner-declarations: Move work to cold path (#11746)
(overlookmotel)
- 7c0fff7 linter: Skip running `consistent-function-scoping` on `.d.ts`
files (#11739) (camc314)
- b34c6f6 parser,semantic: Improve handling of diagnostics (#11641)
(Boshen)
- 2cd786b linter/no-inner-declarations: Remove unnecessary code and
reduce branches (#11633) (overlookmotel)

### 🧪 Testing

- 44a9df8 linter: Update testsuite for `no-undef` (#11706) (Sysix)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area - CLI A-linter Area - Linter A-parser Area - Parser C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants