Skip to content

Conversation

@ckwalsh
Copy link
Contributor

@ckwalsh ckwalsh commented May 2, 2025

Summary:
Prior to this commit, isSortImportsIgnored() checked comments
associated with the extracted ImportDirectives, and only if the
comment started on line 1. This could result in a failure to suppress
sorting if the comment was not next to an ImportDirective (never
considered), the first import directive were embedded later in the
file (line mismatch), or directives/shebangs were used (Line 1 is
unavailable).

With this change, the line restriction is removed, and all comments
from the beginning of the file and the first statement are checked.
This ensures better coverage, especially with the
importOrderIgnoreHeaderComments feature stacked on this commit.

Test Plan:
yarn install && yarn run test --all

Stack created with Sapling. Best reviewed with ReviewStack.

Summary:
Prior to this commit, isSortImportsIgnored() checked comments
associated with the extracted ImportDirectives, and only if the
comment started on line 1. This could result in a failure to suppress
sorting if the comment was not next to an ImportDirective (never
considered), the first import directive were embedded later in the
file (line mismatch), or directives/shebangs were used (Line 1 is
unavailable).

With this change, the line restriction is removed, and all comments
from the beginning of the file and the first statement are checked.
This ensures better coverage, especially with the
importOrderIgnoreHeaderComments feature stacked on this commit.

Test Plan:
`yarn install && yarn run test --all`
@vladislavarsenev
Copy link
Collaborator

Yes, it was an issue for a while. Thank you for addressing it! I made a small edit, that requires the comment to start with sort-imports-ignore

@vladislavarsenev vladislavarsenev merged commit e750c32 into trivago:v6 Oct 17, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants