Skip to content

feat(organizeImports): add :STYLE: group matcher#10070

Merged
Conaclos merged 4 commits into
nextfrom
conaclos/organizeImports-style-predefined-group-matcher
Apr 21, 2026
Merged

feat(organizeImports): add :STYLE: group matcher#10070
Conaclos merged 4 commits into
nextfrom
conaclos/organizeImports-style-predefined-group-matcher

Conversation

@Conaclos

@Conaclos Conaclos commented Apr 20, 2026

Copy link
Copy Markdown
Member

Summary

This is a small feature that should improve the life of users that want to group style imports together.

This PR adds a :STYLE: group matcher that matches style imports such as style.css or style.scss.
The list of supported extensions is taken from perfectionist.

Test Plan

I added a test

Docs

I updated the assist action documentation and added a changeset.

@changeset-bot

changeset-bot Bot commented Apr 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2bf8fce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@biomejs/biome Minor
@biomejs/cli-win32-x64 Minor
@biomejs/cli-win32-arm64 Minor
@biomejs/cli-darwin-x64 Minor
@biomejs/cli-darwin-arm64 Minor
@biomejs/cli-linux-x64 Minor
@biomejs/cli-linux-arm64 Minor
@biomejs/cli-linux-x64-musl Minor
@biomejs/cli-linux-arm64-musl Minor
@biomejs/wasm-web Minor
@biomejs/wasm-bundler Minor
@biomejs/wasm-nodejs Minor
@biomejs/backend-jsonrpc Patch
@biomejs/js-api Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Conaclos Conaclos requested review from a team April 20, 2026 20:47
@github-actions github-actions Bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Apr 20, 2026
@coderabbitai

coderabbitai Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c6cb9c4b-5d16-4235-bb87-1a9e67c8bafa

📥 Commits

Reviewing files that changed from the base of the PR and between 80c0460 and 2bf8fce.

⛔ Files ignored due to path filters (2)
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/assist/source/organize_imports.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_js_analyze/src/assist/source/organize_imports.rs

Walkthrough

Adds a :STYLE: predefined group matcher for the organizeImports assist to recognise style imports by extension (css, less, pcss, sass, scss, sss, styl). Updates PredefinedSourceMatcher (enum variant, serde tag, Display and FromStr), adjusts documentation and examples to use :STYLE:, adds a changeset entry, and introduces tests and an options fixture demonstrating grouping and placing style imports last.

Possibly related PRs

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a :STYLE: group matcher to the organizeImports feature.
Description check ✅ Passed The description clearly explains the purpose, implementation, and supporting changes (test and documentation updates) related to the new :STYLE: group matcher.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch conaclos/organizeImports-style-predefined-group-matcher

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/biome_js_analyze/src/assist/source/organize_imports.rs (1)

333-336: ⚠️ Potential issue | 🟡 Minor

Doc text is stale: it says “two exceptions” but the example uses one.

After switching to !:STYLE:, this line should reference a single exception so readers don’t second-guess the config.

✏️ Suggested wording tweak
-    /// `**` matches everything and is followed by the two exceptions that exclude style imports.
+    /// `**` matches everything and is followed by an exception that excludes style imports.

Also applies to: 341-343

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_js_analyze/src/assist/source/organize_imports.rs` around lines
333 - 336, The documentation comment describing the import grouping is
inaccurate: it says “two exceptions” but the example uses a single exception
after switching to `!:STYLE:`; update the doc text to reference a single
exception (e.g., change “two exceptions that exclude style imports” to “an
exception that excludes style imports”), and make the same wording change in the
other occurrence that parallels this text (the comment block that mentions `**`
and `!:STYLE:` further down). Ensure the phrasing clearly matches the example
using `**` followed by the single `!:STYLE:` exception.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_rule_options/src/organize_imports/import_groups.rs`:
- Line 1: The Unix-only import OsStrExt causes Windows builds to fail because
calls using .as_bytes() rely on that trait; remove the use
std::os::unix::ffi::OsStrExt import and replace platform-specific .as_bytes()
usages with a portable conversion such as calling
std::ffi::OsStr::to_string_lossy() and then taking .as_bytes() on the resulting
Cow<str> (or otherwise convert the OsStr to a UTF-8/byte representation in a
cross-platform way) wherever .as_bytes() is used in import_groups.rs so the code
compiles on non-Unix targets; update references to OsStrExt and as_bytes()
accordingly.

---

Outside diff comments:
In `@crates/biome_js_analyze/src/assist/source/organize_imports.rs`:
- Around line 333-336: The documentation comment describing the import grouping
is inaccurate: it says “two exceptions” but the example uses a single exception
after switching to `!:STYLE:`; update the doc text to reference a single
exception (e.g., change “two exceptions that exclude style imports” to “an
exception that excludes style imports”), and make the same wording change in the
other occurrence that parallels this text (the comment block that mentions `**`
and `!:STYLE:` further down). Ensure the phrasing clearly matches the example
using `**` followed by the single `!:STYLE:` exception.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1ad3a156-601f-4000-a08d-21b54044265b

📥 Commits

Reviewing files that changed from the base of the PR and between 69aadc2 and 63772a9.

⛔ Files ignored due to path filters (1)
  • crates/biome_js_analyze/tests/specs/source/organizeImports/style-grouping.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (5)
  • .changeset/dry-crews-shake.md
  • crates/biome_js_analyze/src/assist/source/organize_imports.rs
  • crates/biome_js_analyze/tests/specs/source/organizeImports/style-grouping.js
  • crates/biome_js_analyze/tests/specs/source/organizeImports/style-grouping.options.json
  • crates/biome_rule_options/src/organize_imports/import_groups.rs

Comment thread crates/biome_rule_options/src/organize_imports/import_groups.rs Outdated
Comment thread crates/biome_rule_options/src/organize_imports/import_groups.rs Outdated
@Conaclos Conaclos force-pushed the conaclos/organizeImports-style-predefined-group-matcher branch from 93da04e to e749991 Compare April 20, 2026 21:02
@codspeed-hq

codspeed-hq Bot commented Apr 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 196 skipped benchmarks1


Comparing conaclos/organizeImports-style-predefined-group-matcher (2bf8fce) with next (69aadc2)

Open in CodSpeed

Footnotes

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

@Conaclos Conaclos force-pushed the conaclos/organizeImports-style-predefined-group-matcher branch from e749991 to 80c0460 Compare April 20, 2026 21:03
Comment thread crates/biome_js_analyze/src/assist/source/organize_imports.rs Outdated

@siketyan siketyan 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.

Nice improvement!

@Conaclos Conaclos merged commit bae0710 into next Apr 21, 2026
29 checks passed
@Conaclos Conaclos deleted the conaclos/organizeImports-style-predefined-group-matcher branch April 21, 2026 08:32
@github-actions github-actions Bot mentioned this pull request Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants