Conversation
Co-authored-by: annes <76728727+annesnour03@users.noreply.github.com>
* Added current-state snapshots Capturing the current state of transformations so we can see how the upcoming changes affect them. * Add `<SEPARATOR>` support When `importOrderSeparation` is enabled, users can further control separation placement with the `<SEPARATOR>` keyword.
Switch to ESM
* Require node >= 20.x * Add checking 24.x
I was still hitting issues with jest and trying to get full ESM support, so I decided to switch to vitest. This seems to be working and snapshots are generated essentially the same.
Switch to vitest for better ESM support
[Format] Run prettier on most files
Summary: This logic can hide breakages and cause tests to pass when the underlying logic is actually broken. I encountered these hidden breakages while working on some further feature changes, and figured it was appropriate to fix this first. As all existing tests pass without the try/catch, this change is effectively a no-op. Test Plan: `yarn install && yarn run test ./tests/`
[Test] Stop ignoring exceptions thrown in snapshot tests
Summary:
This change replaces the existing RegExp replace() logic with
concatenated string slices. This avoids reallocation the result
string for each node replacement, replacing it with string slice
operations (which are implemented as O(1) string views within v8) and
a single .join(''), which can be optimized by the runtime to a single
allocation.
This probably won't make a noticable difference, but the change also
simplifies some further feature work I am attempting to add.
Test Plan:
`yarn install && yarn run test --all`
[Perf] Improve performance of removeNodesFromOriginalCode()
Summary: This commit changes how the sorted imports are combined with the original source. Prior to this commit, all ImportDeclaration nodes and their leading comments, plus any InterpreterDirective and Directive nodes, were extracted from the original code and re-rendered using babel. The rendered nodes were then concatenated with the original source with those nodes removed to produce the updated source. This approach safely protected against functional changes, but removed newlines around comments near the beginning of the file when the first node of the original source was an ImportDeclaration, as babel does not preserve whitespace when rendering content. If a user has configured a plugin that attempts to manage comments and/or whitespace near the top of the file, such as auto-inserting a license header (as I am trying to do), this results in conflicts / formatting churn. This commit does not directly resolve this incompatibility, however it better prepares the codebase for a plugin option to be added that can resolve the issue. Test Plan: `yarn install && yarn run test --all` Note that one snapshot was changed by this commit where a newline was changed, acting as an effective example of how the original approach could affect whitespace in the re-rendered portion of the file.
[Refactor] Stop rerendering directives, inject imports instead
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`
[Feature] Expand detection for `sort-imports-ignore`
Add <BUILTIN_MODULES> option for Node.js builtin modules
ayusharma
approved these changes
Oct 28, 2025
This reverts commit 5b1b267.
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.
No description provided.