Skip to content

docs: safety of useSortedKeys#6112

Merged
ematipico merged 6 commits intobiomejs:mainfrom
Sjlver:use-sorted-keys-safety
Sep 4, 2025
Merged

docs: safety of useSortedKeys#6112
ematipico merged 6 commits intobiomejs:mainfrom
Sjlver:use-sorted-keys-safety

Conversation

@Sjlver
Copy link
Copy Markdown
Contributor

@Sjlver Sjlver commented May 22, 2025

Summary

Expands the documentation of useSortedKeys, to make developers more aware about potential semantic changes.

This follows a discussion in #5907

There are a few drive-by changes to other assist descriptions, so that they follow a consistent sentence structure.

Test Plan

Documentation-only change, no tests needed.

@github-actions github-actions Bot added A-Project Area: project A-Linter Area: linter A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages labels May 22, 2025
@Sjlver Sjlver changed the title Documentation: safety of useSortedKeys docs: safety of useSortedKeys May 22, 2025
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 22, 2025

CodSpeed Performance Report

Merging #6112 will not alter performance

Comparing Sjlver:use-sorted-keys-safety (a946338) with main (fad34b9)1

Summary

✅ 133 untouched benchmarks

Footnotes

  1. No successful run was found on main (b35090f) during the generation of this report, so fad34b9 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Sep 4, 2025

⚠️ No Changeset found

Latest commit: a946338

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 4, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR updates documentation comments across configuration, linter, and assist rules. In analyzer and codegen, field docs for recommended and use_sorted_keys are reworded for grammar and consistency. The linter’s RuleDomainValue::Recommended doc string is similarly adjusted. JS and JSON UseSortedKeys rule docs are expanded to define “natural order,” clarify case and numeric comparisons, note non-sortable keys behaviour, potential semantic impacts, and include the suppression comment: // biome-ignore assist/source/useSortedKeys. There are no behavioural changes, no control-flow modifications, and no public API signature changes.

Suggested reviewers

  • siketyan
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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/use_sorted_keys.rs (1)

88-96: Options section: tidy phrasing

Quick grammar clean-ups:

-    /// This actions accepts following options
+    /// This action accepts the following options.
@@
-    /// This options supports `natural` and `lexicographic` values. Where as `natural` is the default.
+    /// This option supports `natural` and `lexicographic` values, with `natural` as the default.
@@
-    /// Following will apply the natural sort order.
+    /// The following applies the natural sort order.
@@
-    /// Following will apply the lexicographic sort order.
+    /// The following applies the lexicographic sort order.

Also applies to: 92-94, 113-121, 115-119

🧹 Nitpick comments (3)
crates/biome_configuration/src/analyzer/assist/actions.rs (1)

181-184: Make the summary language-agnostic

The config field describes an action used in both JS and JSON. Consider removing “JSON” to avoid narrowing the scope.

-    #[doc = "Sort the keys of a JSON object in natural order."]
+    #[doc = "Sort object keys in natural order."]

Also applies to: 196-199

xtask/codegen/src/generate_configuration.rs (1)

495-498: Follow-through: align top-level ‘recommended’ docs too

For full consistency, consider updating the top-level generated structs (Actions/Rules) as well:

-                /// It enables the assist actions recommended by Biome. `true` by default.
+                /// Enables the assist actions recommended by Biome. `true` by default.
-                /// It enables the lint rules recommended by Biome. `true` by default.
+                /// Enables the lint rules recommended by Biome. `true` by default.

Also applies to: 634-637

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

21-43: Polish documentation comments

  • Fix typos: “e.g. [k]: 1” and “if one exists”.
  • Replace “Since ES2020…” with “Per the ECMAScript specification…” to avoid a brittle year reference.
-    /// This rule will consider spread/calculated keys e.g [k]: 1 as
-    /// non-sortable. Instead, whenever it encounters a non-sortable key, it
-    /// will sort all the previous sortable keys up until the nearest
-    /// non-sortable key, if one exist. This prevents breaking the override of
-    /// certain keys using spread keys.
+    /// This rule considers spread/calculated keys (e.g. `[k]: 1`) as non-sortable.
+    /// When it encounters a non-sortable key, it sorts preceding sortable keys
+    /// up to the nearest non-sortable key. This prevents breaking overrides of
+    /// certain keys introduced via spread keys.
@@
-    /// Sorting the keys of an object technically changes the semantics of the
-    /// program. It affects the result of operations like
-    /// `Object.getOwnPropertyNames`. Since ES2020, operations like `for-in`
-    /// loops, `Object.keys`, and `JSON.stringify` are guaranteed to process
-    /// string keys in insertion order.
+    /// Sorting object keys can change program semantics (e.g. the result of
+    /// `Object.getOwnPropertyNames`). Per the ECMAScript specification,
+    /// operations such as `for-in` loops, `Object.keys`, and `JSON.stringify`
+    /// process string keys in insertion order.

Also update the options section phrasing (see next comment).

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b35090f and 300285e.

⛔ Files ignored due to path filters (3)
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs 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 (5)
  • crates/biome_configuration/src/analyzer/assist/actions.rs (2 hunks)
  • crates/biome_configuration/src/analyzer/linter/mod.rs (1 hunks)
  • crates/biome_js_analyze/src/assist/source/use_sorted_keys.rs (1 hunks)
  • crates/biome_json_analyze/src/assist/source/use_sorted_keys.rs (1 hunks)
  • xtask/codegen/src/generate_configuration.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files before committing (use just f/just format).

Files:

  • crates/biome_configuration/src/analyzer/assist/actions.rs
  • crates/biome_configuration/src/analyzer/linter/mod.rs
  • crates/biome_json_analyze/src/assist/source/use_sorted_keys.rs
  • xtask/codegen/src/generate_configuration.rs
  • crates/biome_js_analyze/src/assist/source/use_sorted_keys.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_configuration/src/analyzer/assist/actions.rs
  • crates/biome_configuration/src/analyzer/linter/mod.rs
  • crates/biome_json_analyze/src/assist/source/use_sorted_keys.rs
  • crates/biome_js_analyze/src/assist/source/use_sorted_keys.rs
crates/biome_configuration/src/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep configuration sources under biome_configuration/src/

Files:

  • crates/biome_configuration/src/analyzer/assist/actions.rs
  • crates/biome_configuration/src/analyzer/linter/mod.rs
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_json_analyze/src/assist/source/use_sorted_keys.rs
  • crates/biome_js_analyze/src/assist/source/use_sorted_keys.rs
🧠 Learnings (3)
📚 Learning: 2025-08-11T11:40:38.097Z
Learnt from: CR
PR: biomejs/biome#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:40:38.097Z
Learning: For documentation of rules/assists/options, use inline Rustdoc in source code; other docs updates should go to the website repo’s next branch.

Applied to files:

  • crates/biome_configuration/src/analyzer/assist/actions.rs
  • crates/biome_js_analyze/src/assist/source/use_sorted_keys.rs
📚 Learning: 2025-08-17T08:56:30.831Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:56:30.831Z
Learning: Applies to crates/biome_analyze/crates/**/lib/src/**/nursery/**/*.rs : Use `domains` in `declare_lint_rule!` when applicable; recommended rules with domains enable only when the domain is active

Applied to files:

  • crates/biome_configuration/src/analyzer/linter/mod.rs
📚 Learning: 2025-08-17T08:56:30.831Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:56:30.831Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Define per-rule options in the `biome_rule_options` crate under `lib/`, with serde- and schemars-compatible derives and `#[serde(rename_all = "camelCase", deny_unknown_fields, default)]`

Applied to files:

  • crates/biome_configuration/src/analyzer/linter/mod.rs
⏰ 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). (27)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Parser conformance
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Test Node.js API
  • GitHub Check: Check JS Files
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
🔇 Additional comments (2)
crates/biome_configuration/src/analyzer/linter/mod.rs (1)

50-51: LGTM: clearer phrasing for Recommended domain

Reads well and aligns with the other “Enables …” docs.

xtask/codegen/src/generate_configuration.rs (1)

940-942: LGTM: consistent “Enables …” phrasing

Good consistency upgrade for generated group structs.

Also applies to: 1013-1015

Comment thread crates/biome_json_analyze/src/assist/source/use_sorted_keys.rs
@ematipico ematipico merged commit 7f53274 into biomejs:main Sep 4, 2025
31 checks passed
kedevked pushed a commit to kedevked/biome that referenced this pull request Sep 22, 2025
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

Co-authored-by: dyc3 <1808807+dyc3@users.noreply.github.com>
dyc3 added a commit that referenced this pull request Oct 3, 2025
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

Co-authored-by: dyc3 <1808807+dyc3@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter A-Project Area: project A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants