[Fix] newline-after-import: preserve comments between imports - #3281
Merged
ljharb merged 1 commit intoAug 20, 2026
Merged
Conversation
The early return also skips comments before a following non-export `import x = require(..)`, and keeps checking when the next statement is an `export import`; neither half had coverage. Both tests are mutation-verified: removing the TSImportEqualsDeclaration early return fails the new valid test, and removing the `!isExport` guard fails the new invalid one. The combined condition is also split into two early returns, since the repo's `no-extra-parens` setting forbids clarifying the mixed `||`/`&&` precedence with parentheses. Also brings the changelog entry in line with conventions: defines the previously dangling `[import-js#2673]` link ref (markdownlint skips CHANGELOG.md, so CI never catches those), adds contributor attribution, and moves the entry to the end of the Fixed list.
NoClueMike
approved these changes
Aug 1, 2026
ljharb
force-pushed
the
agent/fix-newline-after-import-comments
branch
from
August 20, 2026 07:32
9a87957 to
46fa43b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3281 +/- ##
==========================================
- Coverage 79.58% 79.57% -0.01%
==========================================
Files 98 98
Lines 4535 4539 +4
Branches 1567 1569 +2
==========================================
+ Hits 3609 3612 +3
- Misses 926 927 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
newline-after-import: preserve comments between imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
newline-after-importruns withconsiderComments, comments between twoimports are part of the import group and should not trigger a blank-line error.
The rule now checks the following import declaration before evaluating the
intervening comment, with a regression test for consecutive imports.
Fixes #2673.
Validation
git diff --checkAI assistance
AI assistance was used for investigation and drafting. I reviewed the rule,
test contract, and complete diff, then independently ran the full validation.