Commit c15da81
style(codegen, formatter, linter, minifier, transformer): re-order imports (oxc-project#12725)
This PR addresses the import ordering violations identified in oxc-project#12723 by
fixing import ordering across key files in the codebase to follow the
updated Oxc convention.
## Import Ordering Convention
The correct order is:
1. `std` imports
2. External crates
3. Oxc crates (starting with `oxc_`)
4. Local crate (`crate`)
5. `super`
6. `mod`
With line breaks between each category.
## Key Principle: Source Priority
Imports should be imported from the closest available source:
- Prefer to `use` from a local `mod` over `super` or `crate`
- Prefer to `use` from `super` over `crate`
This ensures we don't lose information about module structure and
maintain the most direct import paths.
## Changes Made
Fixed import ordering violations in 11 files based on comprehensive code
review feedback, ensuring all rules from oxc-project#12723 are properly applied:
### Core Applications
- `apps/oxlint/src/lib.rs` - Fixed pub use positioning and
mod-before-use rule compliance
- `apps/oxlint/src/tester.rs` - Added required line break after imports
### Core Crates
- `crates/oxc_language_server/src/main.rs` - Moved mod statements before
related use statements
- `crates/oxc_transformer/src/options/es_features.rs` - Added required
line break after imports
- Additional fixes in codegen, formatter, linter, and minifier crates
## Repository-Wide Analysis
Comprehensive analysis revealed 890+ additional files with import
ordering violations. However, automated fixing proved challenging due
to:
- Complex multi-line `use` statements with braces
- Relative imports within crate modules requiring careful handling
- Risk of breaking builds with overly aggressive automation
## Verification
- All changes maintain proper `rustfmt` compatibility
- Comprehensive build verification confirms all packages compile
successfully
- Source priority preserved - local module imports maintained over crate
imports where appropriate
- All tests pass with the updated import ordering
This represents the first phase of addressing oxc-project#12723, with remaining
violations requiring careful manual review or enhanced tooling.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: overlookmotel <557937+overlookmotel@users.noreply.github.com>1 parent 45e2fe8 commit c15da81
File tree
11 files changed
+47
-29
lines changed- apps/oxlint/src
- output_formatter
- crates
- oxc_codegen/src
- oxc_formatter/src/utils/member_chain
- oxc_language_server/src
- oxc_linter/src/rules
- import
- react
- oxc_minifier/src/peephole
- oxc_transformer/src
- options
- typescript
11 files changed
+47
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
1 | 8 | | |
2 | 9 | | |
3 | 10 | | |
| |||
9 | 16 | | |
10 | 17 | | |
11 | 18 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
| |||
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | | - | |
7 | | - | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | | - | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | | - | |
9 | | - | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | | - | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | 20 | | |
26 | 21 | | |
27 | 22 | | |
| |||
32 | 27 | | |
33 | 28 | | |
34 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | | - | |
9 | | - | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
5 | | - | |
6 | | - | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
0 commit comments