Skip to content

feat: sort interface members#8164

Merged
ematipico merged 4 commits intonextfrom
feat/use-sorted-members-v2
Nov 19, 2025
Merged

feat: sort interface members#8164
ematipico merged 4 commits intonextfrom
feat/use-sorted-members-v2

Conversation

@ematipico
Copy link
Member

Summary

Superseeds #7553

That action was supposed to go to next, but I did a mistake during its rebasing. I preferred to open a new PR.

The commits have been cherry-picked from the original PR

Test Plan

Docs

@changeset-bot
Copy link

changeset-bot bot commented Nov 19, 2025

🦋 Changeset detected

Latest commit: aba2590

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

@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Nov 19, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 19, 2025

CodSpeed Performance Report

Merging #8164 will not alter performance

Comparing feat/use-sorted-members-v2 (aba2590) with next (5901d79)

Summary

✅ 53 untouched
⏩ 85 skipped1

Footnotes

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 19, 2025

Walkthrough

This PR introduces a new assist action useSortedInterfaceMembers that automatically sorts members within TypeScript interfaces alphabetically. The implementation includes configuration integration, a dedicated rule module with fix logic that preserves comments and non-sortable members (constructors, call signatures, index signatures), and comprehensive test cases covering various sorting scenarios. The rule is configured as safe with automatic fix capability.

Suggested labels

A-Project, A-Tooling, L-JavaScript, A-Diagnostic

Suggested reviewers

  • dyc3
  • unvalley
  • mdevils

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: sort interface members' clearly and concisely describes the main change: introducing a new assist action that sorts members within TypeScript interfaces.
Description check ✅ Passed The description adequately explains the PR's context, referencing the superseded PR #7553, acknowledging a rebasing mistake, and noting that commits were cherry-picked from the original PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/use-sorted-members-v2

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5901d79 and aba2590.

⛔ Files ignored due to path filters (12)
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/mixed_literals.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/multiple_non_sortable.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/numeric_literals.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/simple_comment.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/sortable_after_non_sortable.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/sorted.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/string_literals.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/unsorted.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/with_comments.ts.snap is excluded by !**/*.snap and included by **
  • 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 (16)
  • .changeset/chilly-jokes-decide.md (1 hunks)
  • crates/biome_configuration/src/analyzer/assist/actions.rs (9 hunks)
  • crates/biome_js_analyze/src/assist/source.rs (1 hunks)
  • crates/biome_js_analyze/src/assist/source/use_sorted_interface_members.rs (1 hunks)
  • crates/biome_js_analyze/src/options.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/mixed_literals.ts (1 hunks)
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/multiple_non_sortable.ts (1 hunks)
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/numeric_literals.ts (1 hunks)
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/simple_comment.ts (1 hunks)
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/sortable_after_non_sortable.ts (1 hunks)
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/sorted.ts (1 hunks)
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/string_literals.ts (1 hunks)
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/unsorted.ts (1 hunks)
  • crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/with_comments.ts (1 hunks)
  • crates/biome_rule_options/src/lib.rs (1 hunks)
  • crates/biome_rule_options/src/use_sorted_interface_members.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-20T16:24:59.781Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7266
File: crates/biome_js_type_info/src/type.rs:94-102
Timestamp: 2025-08-20T16:24:59.781Z
Learning: In crates/biome_js_type_info/src/type.rs, the flattened_union_variants() method returns TypeReference instances that already have the correct module IDs applied to them. These references should be used directly with resolver.resolve_reference() without applying additional module ID transformations, as variant references may originate from nested unions in different modules.

Applied to files:

  • crates/biome_rule_options/src/use_sorted_interface_members.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/assist/source/use_sorted_interface_members.rs (2)
crates/biome_rowan/src/syntax/token.rs (2)
  • token_text (121-123)
  • trailing_trivia (492-494)
crates/biome_rowan/src/syntax/node.rs (2)
  • first_token (323-325)
  • last_token (327-329)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: autofix
  • GitHub Check: Documentation
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_configuration)
🔇 Additional comments (8)
.changeset/chilly-jokes-decide.md (1)

11-29: Example clearly demonstrates the sorting behaviour.

The before/after examples effectively show how the rule alphabetically sorts property members whilst preserving non-sortable members (like call signatures) at their relative positions or moving them to the end.

crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/string_literals.ts (1)

1-4: Good test case for string literal keys.

This interface with reverse-alphabetically-ordered string literal keys ("zz", "aa") properly exercises the sorting rule for quoted property names.

crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/simple_comment.ts (1)

1-5: Essential test for comment preservation.

This case validates that inline comments are correctly preserved when reordering members, which is crucial for maintaining developer intent.

crates/biome_rule_options/src/lib.rs (1)

351-351: Module export correctly positioned.

The new module is alphabetically placed between use_sorted_classes and use_sorted_keys, maintaining consistency with the rest of the file.

crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/mixed_literals.ts (1)

1-8: Comprehensive test for mixed key types.

This interface exercises the sorting rule with a mix of string literals, identifiers, and numeric keys, ensuring the implementation handles heterogeneous property declarations correctly.

crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/unsorted.ts (1)

1-5: Solid baseline test case.

This straightforward unsorted interface (zebra, apple, banana) provides a clear baseline for verifying the alphabetical sorting behaviour.

crates/biome_js_analyze/tests/specs/source/useSortedInterfaceMembers/sortable_after_non_sortable.ts (1)

1-7: Critical test for member ordering constraints.

This case validates that sortable properties (bProperty, cProperty) appearing after non-sortable members (index signature, call signature) are correctly flagged. The inline comments clearly document the expected errors.

crates/biome_js_analyze/src/assist/source/use_sorted_interface_members.rs (1)

175-263: Slick trivia juggling. Copying the stored leading/trailing trivia before each swap keeps comments and blank lines welded to the right member—ace attention to detail.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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

@ematipico ematipico merged commit 1d25856 into next Nov 19, 2025
18 checks passed
@ematipico ematipico deleted the feat/use-sorted-members-v2 branch November 19, 2025 15:44
@coderabbitai coderabbitai bot mentioned this pull request Nov 26, 2025
@github-actions github-actions bot mentioned this pull request Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants