Skip to content

feat(linter): implement import/newline-after-import rule#19142

Merged
camchenry merged 13 commits into
oxc-project:mainfrom
apple-yagi:feat/import-newline-after-import
May 16, 2026
Merged

feat(linter): implement import/newline-after-import rule#19142
camchenry merged 13 commits into
oxc-project:mainfrom
apple-yagi:feat/import-newline-after-import

Conversation

@apple-yagi

Copy link
Copy Markdown
Contributor

Implemented the import/newline-after-import rule.

Related issues

#1117

Disclose AI usage

This PR was written with assistance from Codex.

@apple-yagi apple-yagi requested a review from camc314 as a code owner February 8, 2026 12:47
Copilot AI review requested due to automatic review settings February 8, 2026 12:47
@github-actions github-actions Bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Feb 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds the import/newline-after-import lint rule to oxc_linter, mirroring the behavior of eslint-plugin-import’s newline-after-import, including autofix support and snapshot-based tests.

Changes:

  • Implement import/newline-after-import with support for count, exactCount, and considerComments, plus fixes for missing blank lines.
  • Add comprehensive rule tests (pass/fail/fix) and update the corresponding snapshot output.
  • Register the new rule in the linter rule module list and generated rule wiring (enum + runner impls).

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/oxc_linter/src/rules/import/newline_after_import.rs New rule implementation + tests and fixer logic.
crates/oxc_linter/src/snapshots/import_newline_after_import.snap Snapshot outputs for the new rule’s diagnostics/fixes.
crates/oxc_linter/src/rules.rs Exposes the new rule module under import.
crates/oxc_linter/src/generated/rules_enum.rs Registers the rule in the generated rule enum and metadata plumbing.
crates/oxc_linter/src/generated/rule_runner_impls.rs Adds the generated RuleRunner impl for run-once execution.

Comment thread crates/oxc_linter/src/rules/import/newline_after_import.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Feb 8, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing apple-yagi:feat/import-newline-after-import (5acfb6e) with main (dbbc059)2

Open in CodSpeed

Footnotes

  1. 47 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.

  2. No successful run was found on main (bb22240) during the generation of this report, so dbbc059 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@apple-yagi apple-yagi force-pushed the feat/import-newline-after-import branch from 8fde86e to 9e5e2cd Compare February 8, 2026 13:11
@camc314 camc314 self-assigned this Feb 10, 2026
@choi-me

choi-me commented Mar 5, 2026

Copy link
Copy Markdown

Any updates?
I need this rule.

@apple-yagi

Copy link
Copy Markdown
Contributor Author

@camc314 I've improved the performance, so please review it when you have a moment. The performance degradation in the local environment is kept within 3%.

@apple-yagi apple-yagi force-pushed the feat/import-newline-after-import branch from 2f90c16 to 6c7a3eb Compare April 22, 2026 07:09
@camchenry camchenry self-assigned this May 12, 2026
@camchenry camchenry requested a review from overlookmotel as a code owner May 16, 2026 03:24

@camchenry camchenry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you!

@camchenry camchenry merged commit d8d9c74 into oxc-project:main May 16, 2026
28 checks passed
camc314 pushed a commit that referenced this pull request May 18, 2026
# Oxlint
### 🚀 Features

- 1ae291e linter/no-underscore-dangle: Add `allowInUsingDeclarations`
option (#22483) (吴杨帆)
- 0440b0f linter/eslint: Implement `id-match` rule (#22379) (Vladislav
Sayapin)
- 65bf119 linter: Implement react no-object-type-as-default-prop
(#22481) (uhyo)
- 2a6ddce linter/eslint: Implement `no-implied-eval` rule (#22391)
(Vladislav Sayapin)
- d3a3c1d linter: Auto detect agents from CLI and transition to the
agent output format (#22068) (Jovi De Croock)
- 625758a linter/vitest: Implement padding-around-after-all-blocks rule
(#21788) (kapobajza)
- 37680b0 linter: Implement react no-unstable-nested-components (#22248)
(Jovi De Croock)
- d8d9c74 linter: Implement import/newline-after-import rule (#19142)
(Ryuya Yanagi)

### 🐛 Bug Fixes

- 3f59e03 linter: Only call rayon/miette/tracing inits once (#21899)
(Matiss Janis Aboltins)
- 602dfd6 linter/promise/no-return-wrap: Detect Promise calls in all
branches (#22474) (zennnnnnn11)
- e182aee linter: Allow dialogs and popovers for no_autofocus (#22289)
(mehm8128)
- 7ffb710 linter/jest/vitest: Jest/no-standalone-expect ignores
additionalTestBlockFunctions option for jest/vitest hooks (#22477)
(kapobajza)
- c6f2d3f linter: Add more expression support for iframe-has-title
(#22460) (mehm8128)
- 5747ff1 linter: Avoid enabling jest with vitest plugin (#22499)
(camc314)
- 863984f linter/no-find-dom-node: Run on all files (#22479) (bab)

### ⚡ Performance

- 2afef79 linter: Optimize `no-loop-func` (#22491) (camchenry)
- 4c9ca72 oxlint: Align walker thread count with rayon pool (#22494)
(Boshen)

### 📚 Documentation

- f7967c7 linter/id-match: Clarify `onlyDeclarations` config docs
(#22523) (camc314)
- 1e0c97f linter: Fix closing code block in documentation for
`padding-around-after-all-blocks` rule. (#22513) (connorshea)
- a9049fd linter: Exclude directly provide autoFocus to dialog pattern
(#22510) (mehm8128)
# Oxfmt
### 🐛 Bug Fixes

- 8ee946f formatter/sort_imports: Use label to classify lines (#22512)
(leaysgur)
- 8c1da44 formatter: Normalize destructuring keys in DCR (#22478)
(camc314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants