feat(linter): import/no-useless-path-segments
Implement the import/no-useless-path-segments rule (part of https://github.com/oxc-project/oxc/issues/1117):
I ported the original JS test cases over 1:1 and tried to follow the original JS logic as closely as possible.
Note that this implementation avoids additional filesystem lookups where possible (i.e. ESM) but needs to for CommonJS (not in module_record).
How to use the Graphite Merge Queue
Add either label to this PR to merge it via the merge queue:
- 0-merge - adds this PR to the back of the merge queue
- hotfix - for urgent hot fixes, skip the queue and merge this PR next
You must have a Graphite account in order to use the merge queue. Sign up using this link.
An organization admin has enabled the Graphite Merge Queue in this repository.
Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.
CodSpeed Performance Report
Merging #14569 will degrade performances by 5.86%
Comparing rtsao:no-useless-path-segments (625ea87) with main (ba76081)[^unexpected-base]
[^unexpected-base]: No successful run was found on main (9de1322) during the generation of this report, so ba76081 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.
Summary
❌ 3 regressions
✅ 1 untouched
⏩ 33 skipped[^skipped]
:warning: Please fix the performance issues or acknowledge them on CodSpeed.
Benchmarks breakdown
| Mode | Benchmark | BASE |
HEAD |
Change | |
|---|---|---|---|---|---|
| ❌ | Simulation | linter[binder.ts] |
46.7 ms | 49.6 ms | -5.86% |
| ❌ | Simulation | linter[cal.com.tsx] |
465.4 ms | 479.8 ms | -3.02% |
| ❌ | Simulation | linter[react.development.js] |
18.7 ms | 19.4 ms | -3.46% |
| [^skipped]: 33 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. |
Thanks for working on this. Unfortunately the CI is failing.
I see, I was just running cargo test locally (CI had to be manually enabled on this PR).
There are some additional checks in CI that are attempting to parse some code fence syntax within comments as Rust code (which can be fixed by removing the non-Rust annotated code fences from the comments https://github.com/rtsao/oxc/commit/92df668ef7fe163d68890c53c5a40af6c4731dc7)
Would you mind re-opening the PR? I'd be more than happy to address feedback now that I can see the results of CI :)
Thanks for working on this. Unfortunately the CI is failing.
@camc314 CI is passing now: I had to re-run codegen and remove a few instances of markdown code fence syntax within comments that were incorrectly being parsed as Rust code as part of a CI check.
CodSpeed Performance Report
Merging #14569 will degrade performances by 5.86%
Comparing
rtsao:no-useless-path-segments(625ea87) withmain(ba76081)1Summary
❌ 3regressions✅ 1untouched⏩ 33skipped2⚠️ Please fix the performance issues or acknowledge them on CodSpeed.
Benchmarks breakdown
Mode Benchmark
BASEHEADChange ❌ Simulationlinter[binder.ts]46.7 ms 49.6 ms -5.86% ❌ Simulationlinter[cal.com.tsx]465.4 ms 479.8 ms -3.02% ❌ Simulationlinter[react.development.js]18.7 ms 19.4 ms -3.46%Footnotes
- No successful run was found on
main(9de1322) during the generation of this report, so ba76081 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩- 33 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Performance regression is not ideal, probably due to calling canonicalize.