feat(analyze/json): implement organizePackageJson (Broken)#8657
feat(analyze/json): implement organizePackageJson (Broken)#8657arthurfiorette wants to merge 16 commits intobiomejs:mainfrom
organizePackageJson (Broken)#8657Conversation
🦋 Changeset detectedLatest commit: 023dce8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
WalkthroughThis PR introduces a new Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/biome_json_analyze/src/assist/source.rs (1)
1-8: The file has a duplicate comment line that shouldn't be there.The codegen should produce a single preamble comment, but this file has two identical comment lines at the start (lines 1 and 3). Either this file was manually edited, or codegen wasn't executed properly. Run
cargo run --package xtask --bin codegen -- assistand ensure the output matches the expected generated format before committing.
🧹 Nitpick comments (7)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_scripts.rs (1)
30-37: Consider iterator chain for conciseness (optional).The manual loop could be simplified, though the current version is perfectly readable.
🔎 Optional refactor
- let mut script_names = Vec::new(); - for m in &members { - if let Ok(member) = m - && let Ok(name) = member.name().and_then(|n| n.inner_string_text()) - { - script_names.push(name.text().to_string()); - } - } + let script_names: Vec<String> = members + .iter() + .filter_map(|m| m.ok()) + .filter_map(|member| member.name().ok()?.inner_string_text().ok()) + .map(|name| name.text().to_string()) + .collect();crates/biome_json_analyze/src/assist/source/organize_package_json/sort_pnpm_config.rs (1)
21-25: Consider adding rustdoc.The implementation is clear, but adding inline rustdoc with a brief example would be helpful, especially since the coding guidelines mention using rustdoc for assists.
🔎 Suggested rustdoc addition
+/// Transforms a PNPM base configuration object by sorting its keys according to +/// the canonical field order defined in sort-package-json. +/// +/// # Example +/// ```rust,ignore +/// // Input: { "overrides": {...}, "peerDependencyRules": {...} } +/// // Output: { "peerDependencyRules": {...}, "overrides": {...} } +/// ``` pub fn transform(value: &AnyJsonValue) -> Option<AnyJsonValue> { let object = value.as_json_object_value()?; let sorted = sort_object_by_key_order(object, PNPM_BASE_CONFIG_PROPERTIES)?; Some(AnyJsonValue::from(sorted)) }Based on coding guidelines recommending rustdoc for assists and their options.
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies.rs (1)
64-73: Early return on any parse failure may skip valid members.Using
?onmember.ok()at Line 66 causes the function to returnNoneif any member fails to parse, even if subsequent members contain the target key. Consider usingcontinueto skip unparseable members instead.🔎 Proposed fix
fn find_member_value(members: &JsonMemberList, key: &str) -> Option<AnyJsonValue> { for member in members { - let member = member.ok()?; - let name = member.name().ok()?.inner_string_text().ok()?; + let Ok(member) = member else { continue }; + let Ok(name) = member.name().and_then(|n| n.inner_string_text()) else { continue }; if name.text() == key { return member.value().ok(); } } None }crates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies_meta.rs (1)
47-77: Consider returningNonewhen no transformation occurs.Currently, when
has_changesis false (Line 66-68), the function returnsSome(object.clone()). This is consistent with the overall transform returning the original if nothing changed. However, returningNonewould signal "no action needed" and align with the pattern insorters.rswheresort_object_by_comparatorreturnsNonefor single-element objects.This is minor — the current behaviour works, just a consistency note.
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rs (1)
83-129: Consider reusingsort_object_by_comparatorfor ESLint rules sorting.The
sort_eslint_rulesfunction reimplements much of whatsort_object_by_comparatoralready provides. You could simplify:🔎 Proposed refactor
+use super::sorters::sort_object_by_comparator; + fn sort_eslint_rules(object: &JsonObjectValue) -> Option<JsonObjectValue> { - let members = object.json_member_list(); - let mut member_vec: Vec<JsonMember> = Vec::new(); - - for m in (&members).into_iter().flatten() { - member_vec.push(m.clone()); - } - - member_vec.sort_by(|a, b| { - let a_name = a - .name() - .ok() - .and_then(|n| n.inner_string_text().ok()) - .map(|t| t.text().to_string()); - let b_name = b - .name() - .ok() - .and_then(|n| n.inner_string_text().ok()) - .map(|t| t.text().to_string()); - - match (a_name, b_name) { - (Some(a), Some(b)) => { - let a_slash_count = a.matches('/').count(); - let b_slash_count = b.matches('/').count(); - - match a_slash_count.cmp(&b_slash_count) { - std::cmp::Ordering::Equal => a.cmp(&b), - other => other, - } - } - _ => std::cmp::Ordering::Equal, - } - }); - - let mut elements = Vec::new(); - let mut separators = Vec::new(); - - for (i, member) in member_vec.iter().enumerate() { - elements.push(member.clone()); - if i < member_vec.len() - 1 { - separators.push(make::token(T![,])); - } - } - - let new_members = make::json_member_list(elements, separators); - Some(object.clone().with_json_member_list(new_members)) + sort_object_by_comparator(object, |a, b| { + let a_slashes = a.matches('/').count(); + let b_slashes = b.matches('/').count(); + a_slashes.cmp(&b_slashes).then_with(|| a.cmp(b)) + }) }crates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs (2)
536-536:UniqArrayandUniqAndSortArraytransformers are not implemented.These transformers simply return
value.clone(), meaning fields likekeywords,files,bundledDependencies, etc., won't be deduplicated or sorted. If this is intentional for the WIP, consider adding a// TODOcomment.Would you like me to help implement these array transformers?
307-310: Unreachable catch-all pattern.The
_ => {}at Line 309 is unreachable since allFieldTransformervariants are explicitly matched above. While harmless, it could mask future enum additions.🔎 Suggested fix
Remove the catch-all or use
#[deny(unreachable_patterns)]:FieldTransformer::SortPnpmConfig => { sorted.sort(); } - _ => {} + FieldTransformer::None + | FieldTransformer::UniqArray + | FieldTransformer::UniqAndSortArray => {} }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (25)
Cargo.lockis excluded by!**/*.lockand included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/already_sorted/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/basic/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/all_fields_order/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_meta/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_npm/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_yarn/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dev_engines/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_field_order/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_rules_builtin_first/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_default_last/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_nested_deep/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_types_first/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/fields_badges/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/fields_contributors/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/husky_hooks/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/pnpm_config/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/prettier_overrides_last/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/private_fields/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/scripts_grouped/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/scripts_lifecycle/package.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/workspaces_object/package.json.snapis excluded by!**/*.snapand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**packages/@biomejs/biome/configuration_schema.jsonis excluded by!**/configuration_schema.jsonand included by**
📒 Files selected for processing (44)
.changeset/cool-rice-change.md.gitignorecrates/biome_configuration/src/analyzer/assist/actions.rscrates/biome_json_analyze/Cargo.tomlcrates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/field_order.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies_meta.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_pnpm_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_scripts.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_workspaces.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sorters.rscrates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_json_analyze/tests/specs/source/organizePackageJson/already_sorted/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/basic/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/README.mdcrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/all_fields_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_meta/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_npm/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_yarn/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dev_engines/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_field_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_rules_builtin_first/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_default_last/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_nested_deep/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_types_first/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/fields_badges/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/fields_contributors/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/husky_hooks/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/pnpm_config/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/prettier_overrides_last/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/private_fields/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/scripts_grouped/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/scripts_lifecycle/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/workspaces_object/package.jsoncrates/biome_json_syntax/src/generated.rscrates/biome_json_syntax/src/member_ext.rscrates/biome_json_syntax/src/object_ext.rscrates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/organize_package_json.rs
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Use inline rustdoc documentation for rules, assists, and their options
Use thedbg!()macro for debugging output in Rust tests and code
Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests
Files:
crates/biome_rule_options/src/lib.rscrates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_pnpm_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies.rscrates/biome_configuration/src/analyzer/assist/actions.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies_meta.rscrates/biome_json_syntax/src/generated.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_workspaces.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_scripts.rscrates/biome_json_syntax/src/member_ext.rscrates/biome_json_analyze/src/assist/source/organize_package_json/field_order.rscrates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rscrates/biome_json_syntax/src/object_ext.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sorters.rs
**/Cargo.toml
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/Cargo.toml: Use workspace dependencies withworkspace = truefor internal crates in Cargo.toml
Use path dependencies for dev-dependencies in crates to avoid requiring published versions
Files:
crates/biome_json_analyze/Cargo.toml
🧠 Learnings (59)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Implement the `action` function and add `fix_kind` metadata to the rule macro if the rule provides code actions
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Apply `#[serde(rename_all = "camelCase")]` to rule option structs to match JSON configuration naming convention
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/*.jsonc : Use `.jsonc` format for test files containing multiple code snippets, where each snippet is a string in an array
Applied to files:
crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/README.mdcrates/biome_json_analyze/tests/specs/source/organizePackageJson/already_sorted/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/workspaces_object/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_nested_deep/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dev_engines/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/private_fields/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/pnpm_config/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/fields_badges/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_default_last/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/scripts_lifecycle/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_npm/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/scripts_grouped/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_field_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/fields_contributors/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/prettier_overrides_last/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/all_fields_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_meta/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_types_first/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/husky_hooks/package.json
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/specs/**/options.json : Create an `options.json` file (formatted as `biome.json`) in test specification folders to apply non-default formatting options to all test files in that folder
Applied to files:
crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/README.mdcrates/biome_json_analyze/tests/specs/source/organizePackageJson/already_sorted/package.jsoncrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_nested_deep/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dev_engines/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/private_fields/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/pnpm_config/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_default_last/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/scripts_grouped/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_field_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/prettier_overrides_last/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/all_fields_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_meta/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/exports_types_first/package.json
📚 Learning: 2025-12-04T13:29:49.287Z
Learnt from: dyc3
Repo: biomejs/biome PR: 8291
File: crates/biome_html_formatter/tests/specs/prettier/vue/html-vue/elastic-header.html:10-10
Timestamp: 2025-12-04T13:29:49.287Z
Learning: Files under `crates/biome_html_formatter/tests/specs/prettier` are test fixtures synced from Prettier and should not receive detailed code quality reviews (e.g., HTTP vs HTTPS, formatting suggestions, etc.). These files are test data meant to validate formatter behavior and should be preserved as-is.
Applied to files:
crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/README.mdcrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dev_engines/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/private_fields/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_field_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/prettier_overrides_last/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/all_fields_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_meta/package.json
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/* : Test snapshot output files must be placed in `tests/specs/` folder with subfolders matching the rule group and rule name
Applied to files:
crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/README.mdcrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_field_order/package.json
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Create specification test files in `tests/specs/<language>/` directories with one or more test files; use `cargo insta accept` or `cargo insta review` to accept/reject snapshots
Applied to files:
crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/README.md
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Apply `#[serde(rename_all = "camelCase")]` to rule option structs to match JSON configuration naming convention
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_pnpm_config.rscrates/biome_json_analyze/Cargo.tomlcrates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies.rscrates/biome_configuration/src/analyzer/assist/actions.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies_meta.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_workspaces.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_scripts.rscrates/biome_json_syntax/src/member_ext.rscrates/biome_json_analyze/src/assist/source/organize_package_json/field_order.rscrates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rscrates/biome_json_syntax/src/object_ext.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sorters.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Rule options must be defined in the `biome_rule_options` crate with a file named after the rule
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/Cargo.tomlcrates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Use `Option<_>` wrapper for rule option fields to enable proper merging of configurations
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_pnpm_config.rscrates/biome_json_analyze/Cargo.tomlcrates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rscrates/biome_json_analyze/src/assist/source/organize_package_json/field_order.rscrates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Rule option types must derive `Deserializable`, `Serialize`, `Deserialize`, and optionally `JsonSchema` traits
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rscrates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rscrates/biome_json_syntax/src/object_ext.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Implement `biome_deserialize::Merge` for rule option types to define how shared and user configurations are merged
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Use `Box<[Box<str>]>` instead of `Vec<String>` for collections of strings in rule options to save memory
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/Cargo.toml
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Apply `#[serde(deny_unknown_fields)]` to rule option structs to enforce strict configuration validation
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/field_order.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : New rules must be placed inside the `nursery` group before promotion to other groups
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_configuration/src/analyzer/assist/actions.rscrates/biome_json_syntax/src/generated.rscrates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Store type data in linear vectors instead of using recursive data structures with `Arc` for improved data locality and performance
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/organize_package_json.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Deprecated rules must include a `deprecated` field in the `declare_lint_rule!` macro with an explanation of what rule to use instead
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_json_analyze/Cargo.tomlcrates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Rule names should use the `use` prefix when the rule's sole intention is to mandate a single concept
Applied to files:
crates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_json_analyze/src/assist/source.rs
📚 Learning: 2025-12-22T09:27:13.161Z
Learnt from: ematipico
Repo: biomejs/biome PR: 8537
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:167-210
Timestamp: 2025-12-22T09:27:13.161Z
Learning: In crates/biome_analyze/**/*analyze/src/**/*.rs, the `fix_kind` field in `declare_lint_rule!` should only be specified when the rule implements the `action` function. Rules that only emit diagnostics without providing code fixes should not include `fix_kind` in their metadata.
Applied to files:
crates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_configuration/src/analyzer/assist/actions.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use helper functions like `map`, `filter`, and `and_then` to avoid excessive nested `if let` statements
Applied to files:
crates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rscrates/biome_json_analyze/src/assist/source.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types
Applied to files:
crates/biome_json_analyze/src/assist/source/use_sorted_keys.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : When porting rules from other linters, use `sources` metadata with `RuleSource::Eslint().same()` for identical behavior or `.inspired()` for different behavior
Applied to files:
crates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_configuration/src/analyzer/assist/actions.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `rule_category!()` macro to refer to the diagnostic category instead of dynamically parsing its string name
Applied to files:
crates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_configuration/src/analyzer/assist/actions.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Check if a variable is global using the semantic model before reporting diagnostics for rules that ban global functions or variables
Applied to files:
crates/biome_json_analyze/src/assist/source/use_sorted_keys.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Implement the `action` function and add `fix_kind` metadata to the rule macro if the rule provides code actions
Applied to files:
crates/biome_json_analyze/src/assist/source/use_sorted_keys.rscrates/biome_json_analyze/Cargo.tomlcrates/biome_configuration/src/analyzer/assist/actions.rscrates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs
📚 Learning: 2025-12-21T21:15:03.796Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.796Z
Learning: Applies to **/*.rs : Use inline rustdoc documentation for rules, assists, and their options
Applied to files:
crates/biome_rule_options/src/organize_package_json.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Rule severity should be set to `error` for hard errors, dangerous code, and accessibility issues; `warn` for possibly erroneous code; and `info` for stylistic suggestions
Applied to files:
crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_rules_builtin_first/package.json
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter
Applied to files:
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_syntax/src/generated.rscrates/biome_json_syntax/src/member_ext.rscrates/biome_json_syntax/src/object_ext.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `.ok()?` to transform `Result` types into `Option` or `let else` pattern to handle errors when the function returns `Vec`
Applied to files:
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rscrates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use the `try operator (?)` to transform `Result` types into `Option` when the `run` function returns `Option`
Applied to files:
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rs
📚 Learning: 2025-12-21T21:15:03.796Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.796Z
Learning: In changesets, reference rules and assists with links to the website documentation
Applied to files:
.changeset/cool-rice-change.md
📚 Learning: 2025-12-21T21:15:03.796Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.796Z
Learning: Applies to **/Cargo.toml : Use workspace dependencies with `workspace = true` for internal crates in Cargo.toml
Applied to files:
crates/biome_json_analyze/Cargo.toml
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace*.rs : Implement the Workspace trait in the Biome Service to manage internal state of projects, including open documents, project layout instances, and module graph instances
Applied to files:
crates/biome_json_analyze/Cargo.tomlcrates/biome_json_analyze/src/assist/source/organize_package_json/sort_workspaces.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/Cargo.toml : Include development dependencies in `Cargo.toml` for formatter tests: `biome_formatter_test`, `biome_<language>_factory`, `biome_<language>_parser`, `biome_parser`, `biome_service`, `countme`, `iai`, `quickcheck`, `quickcheck_macros`, and `tests_macros`
Applied to files:
crates/biome_json_analyze/Cargo.tomlcrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_meta/package.json
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Implement watcher tests for workspace methods in watcher.tests.rs and end-to-end tests in LSP tests
Applied to files:
crates/biome_json_analyze/Cargo.toml
📚 Learning: 2025-12-21T21:15:03.796Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.796Z
Learning: Applies to **/Cargo.toml : Use path dependencies for dev-dependencies in crates to avoid requiring published versions
Applied to files:
crates/biome_json_analyze/Cargo.toml
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `declare_node_union!` macro to query multiple node types together to avoid redundant traversal passes
Applied to files:
crates/biome_json_analyze/Cargo.tomlcrates/biome_json_syntax/src/generated.rscrates/biome_json_analyze/src/assist/source.rs
📚 Learning: 2025-12-21T21:15:03.796Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.796Z
Learning: Build debug binaries using `cargo build --bin biome` for development and triaging
Applied to files:
crates/biome_json_analyze/Cargo.toml
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Debug the WorkspaceWatcher by starting the daemon with cargo run --bin=biome -- start and running commands such as cargo run --bin=biome -- lint --use-server <path>
Applied to files:
crates/biome_json_analyze/Cargo.toml
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.
Applied to files:
crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dev_engines/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/pnpm_config/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/scripts_lifecycle/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_npm/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_field_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/prettier_overrides_last/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/all_fields_order/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dependencies_meta/package.json
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/* : Create test files with `invalid` and `valid` prefixes to represent code that should and should not trigger the rule
Applied to files:
crates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/dev_engines/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/private_fields/package.jsoncrates/biome_json_analyze/tests/specs/source/organizePackageJson/sort_package_json/eslint_field_order/package.json
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Code actions must pass `ctx.action_category(ctx.category(), ctx.group())` as the category parameter
Applied to files:
crates/biome_configuration/src/analyzer/assist/actions.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `Markup!` macro for diagnostic messages and code action descriptions to ensure proper formatting
Applied to files:
crates/biome_configuration/src/analyzer/assist/actions.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/flattening.rs : Implement type flattening to simplify `TypeofExpression` variants once all component types are resolved
Applied to files:
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : No module may copy or clone data from another module in the module graph, not even behind an `Arc`
Applied to files:
crates/biome_json_syntax/src/generated.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)
Applied to files:
crates/biome_json_syntax/src/generated.rscrates/biome_json_syntax/src/member_ext.rscrates/biome_json_syntax/src/object_ext.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to 'fix' the code; if a token/node is known to be mandatory but is missing, return `None` instead
Applied to files:
crates/biome_json_syntax/src/generated.rscrates/biome_json_syntax/src/member_ext.rscrates/biome_json_syntax/src/object_ext.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced
Applied to files:
crates/biome_json_syntax/src/generated.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/lib.rs : Expose a public `format_node` function that accepts formatting options and a root syntax node, returning a `FormatResult<Formatted<Context>>` with appropriate documentation
Applied to files:
crates/biome_json_syntax/src/generated.rscrates/biome_json_syntax/src/member_ext.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Create two new crates `biome_{language}_syntax` and `biome_{language}_factory` using `cargo new --lib` for new language parsers
Applied to files:
crates/biome_json_syntax/src/generated.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `ConditionalParsedSyntax` for syntax that is only valid in specific contexts (e.g., strict mode, file types, language versions) and call `or_invalid_to_bogus()` to convert to a bogus node if not supported
Applied to files:
crates/biome_json_syntax/src/generated.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : For tokens that are not mandatory, use helper functions instead of hardcoding
Applied to files:
crates/biome_json_syntax/src/member_ext.rscrates/biome_json_syntax/src/object_ext.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Avoid string allocations by using `&str` or `TokenText` instead of `to_string()`
Applied to files:
crates/biome_json_syntax/src/member_ext.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `ParseSeparatedList` and `ParseNodeList` for parsing lists with error recovery to avoid infinite loops
Applied to files:
crates/biome_json_syntax/src/member_ext.rscrates/biome_json_syntax/src/object_ext.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/*.ungram : Unions of nodes must start with `Any*`, e.g., `AnyHtmlAttribute`
Applied to files:
crates/biome_json_syntax/src/member_ext.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `p.eat(token)` for optional tokens, `p.expect(token)` for required tokens, `parse_rule(p).ok(p)` for optional nodes, and `parse_rule(p).or_add_diagnostic(p, error)` for required nodes
Applied to files:
crates/biome_json_syntax/src/member_ext.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `declare_lint_rule!` macro with a `version` field set to `next` for new rules
Applied to files:
crates/biome_json_analyze/src/assist/source.rscrates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/context.rs : Define `<Language>FormatContext` struct in a `context.rs` file containing `comments` and `source_map` fields, implementing `FormatContext` and `CstFormatContext` traits
Applied to files:
crates/biome_json_analyze/src/assist/source.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/*.ungram : Nodes that represent a list must end with the postfix `List`, e.g., `HtmlAttributeList`, and lists are mandatory (not optional) but empty by default
Applied to files:
crates/biome_json_syntax/src/object_ext.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Implement error recovery in list parsing using `or_recover()` to wrap unparseable tokens in a `BOGUS_*` node and consume tokens until a recovery token is found
Applied to files:
crates/biome_json_syntax/src/object_ext.rs
🧬 Code graph analysis (8)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_prettier_config.rs (1)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rs (1)
transform(24-46)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_pnpm_config.rs (1)
crates/biome_json_analyze/src/assist/source/organize_package_json/sorters.rs (1)
sort_object_by_key_order(82-122)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies.rs (2)
crates/biome_json_analyze/src/assist/source/organize_package_json/sorters.rs (2)
sort_alphabetically(6-8)sort_object_by_comparator(47-80)crates/biome_json_parser/src/lib.rs (1)
parse_json(26-29)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rs (4)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_pnpm_config.rs (1)
transform(21-25)crates/biome_json_analyze/src/assist/source/organize_package_json/sort_workspaces.rs (1)
transform(6-12)crates/biome_json_analyze/src/assist/source/organize_package_json/sort_scripts.rs (1)
transform(23-51)crates/biome_json_parser/src/lib.rs (1)
parse_json(26-29)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies_meta.rs (1)
crates/biome_json_analyze/src/assist/source/organize_package_json/sorters.rs (2)
sort_object_by_comparator(47-80)sort_alphabetically_deep(10-13)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_scripts.rs (1)
crates/biome_json_analyze/src/assist/source/organize_package_json/sorters.rs (1)
sort_object_by_key_order(82-122)
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rs (1)
crates/biome_json_analyze/src/assist/source/organize_package_json/sorters.rs (2)
sort_alphabetically(6-8)sort_object_by_key_order(82-122)
crates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs (10)
crates/biome_json_analyze/src/assist/source/organize_package_json/field_order.rs (2)
get_field_index(496-500)get_field_transformer(502-507)crates/biome_json_analyze/src/assist/source/use_sorted_keys.rs (3)
run(93-121)diagnostic(123-131)action(141-175)crates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies_meta.rs (1)
transform(35-45)crates/biome_json_analyze/src/assist/source/organize_package_json/sort_exports.rs (1)
transform(4-49)crates/biome_json_analyze/src/assist/source/organize_package_json/sort_pnpm_config.rs (1)
transform(21-25)crates/biome_json_analyze/src/assist/source/organize_package_json/sort_workspaces.rs (1)
transform(6-12)crates/biome_json_analyze/src/assist/source/organize_package_json/sort_eslint_config.rs (1)
transform(24-46)crates/biome_json_analyze/src/assist/source/organize_package_json/sort_scripts.rs (1)
transform(23-51)crates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies.rs (1)
transform(7-22)crates/biome_json_analyze/src/assist/source/organize_package_json/sorters.rs (6)
transform_people_array(222-224)transform_badges_array(226-230)sort_alphabetically_deep(10-13)transform_nested_property(273-309)sort_alphabetically(6-8)sort_people_object(125-127)
⏰ 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). (1)
- GitHub Check: Validate PR title
| FieldMetadata { | ||
| key: "preferGlobal", | ||
| transformer: FieldTransformer::SortObject, | ||
| }, |
There was a problem hiding this comment.
preferGlobal is typically a boolean, not an object.
The preferGlobal field in package.json is a deprecated boolean flag. Assigning SortObject as its transformer will have no effect (since booleans aren't objects), but it's semantically misleading.
🔎 Suggested fix
FieldMetadata {
key: "preferGlobal",
- transformer: FieldTransformer::SortObject,
+ transformer: FieldTransformer::None,
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| FieldMetadata { | |
| key: "preferGlobal", | |
| transformer: FieldTransformer::SortObject, | |
| }, | |
| FieldMetadata { | |
| key: "preferGlobal", | |
| transformer: FieldTransformer::None, | |
| }, |
🤖 Prompt for AI Agents
In
crates/biome_json_analyze/src/assist/source/organize_package_json/field_order.rs
around lines 457 to 460, the entry for "preferGlobal" incorrectly uses
FieldTransformer::SortObject even though preferGlobal is a deprecated boolean;
replace the transformer with a no-op transformer (e.g., FieldTransformer::None
or a passthrough variant used elsewhere in this file) or remove the transformer
entry so it’s not treated as an object transformer, ensuring the field is
handled as a boolean.
| FieldTransformer::SortDependencies | ||
| | FieldTransformer::SortDependenciesMeta | ||
| | FieldTransformer::SortScripts | ||
| | FieldTransformer::SortExports | ||
| | FieldTransformer::SortEslintConfig | ||
| | FieldTransformer::SortPrettierConfig | ||
| | FieldTransformer::SortPeopleArray | ||
| | FieldTransformer::SortBadgesArray | ||
| | FieldTransformer::SortObjectDeep | ||
| | FieldTransformer::SortHusky | ||
| | FieldTransformer::SortDevEngines | ||
| | FieldTransformer::SortWorkspaces | ||
| | FieldTransformer::SortPnpmConfig => false, | ||
|
|
||
| FieldTransformer::UniqArray | FieldTransformer::UniqAndSortArray => false, | ||
| } |
There was a problem hiding this comment.
Complex transformers always return false in needs_transformation.
For transformers like SortDependencies, SortScripts, SortExports, etc., needs_transformation returns false. This means is_organized won't detect when these fields are unordered, potentially causing the rule not to trigger when it should.
If the intent is to avoid expensive checks, consider adding a comment explaining this trade-off. Otherwise, implement proper checks for at least the most common transformers.
🤖 Prompt for AI Agents
In crates/biome_json_analyze/src/assist/source/organize_package_json/mod.rs
around lines 206–221 the complex FieldTransformer variants all return false from
needs_transformation which prevents is_organized from detecting
unordered/duplicate fields; either implement proper predicate checks for these
variants (e.g., detect unsorted dependency keys, unsorted script keys, unsorted
export keys, unsorted eslint/prettier config entries, unsorted people/badges
arrays, deep-object order, husky keys, devEngines/workspaces/pnpm config
ordering, and detect duplicates for UniqArray/UniqAndSortArray) and wire those
checks into needs_transformation, or if this is an intentional performance
trade-off add a clear comment explaining why these expensive checks are skipped
and add TODOs and/or targeted tests; also update/add unit tests to cover the
common transformers you implement to ensure is_organized triggers correctly.
| let sorted = if should_sort_dependencies_like_npm(package_json_root) { | ||
| sort_object_by_comparator(object, |a, b| a.cmp(b))? | ||
| } else { | ||
| sort_alphabetically(object)? | ||
| }; |
There was a problem hiding this comment.
Both branches produce identical sorting.
Looking at the relevant snippet from sorters.rs, sort_alphabetically uses |a, b| a.cmp(b) — the same comparator as Line 16. The npm vs non-npm distinction has no effect.
The docstring at Line 5-6 mentions npm uses "locale-aware comparison", but String::cmp is lexicographic byte comparison, not locale-aware. If sort-package-json truly differs here, consider using str::to_lowercase().cmp(...) or a locale-aware comparator for npm.
🔎 Suggested clarification or fix
If both should genuinely be the same, remove the conditional and simplify:
- let sorted = if should_sort_dependencies_like_npm(package_json_root) {
- sort_object_by_comparator(object, |a, b| a.cmp(b))?
- } else {
- sort_alphabetically(object)?
- };
+ let sorted = sort_alphabetically(object)?;Otherwise, implement the intended locale-aware comparison for npm.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let sorted = if should_sort_dependencies_like_npm(package_json_root) { | |
| sort_object_by_comparator(object, |a, b| a.cmp(b))? | |
| } else { | |
| sort_alphabetically(object)? | |
| }; | |
| let sorted = sort_alphabetically(object)?; |
🤖 Prompt for AI Agents
In
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_dependencies.rs
around lines 15–19, both branches call the same comparator (String::cmp) so the
npm-vs-non-npm conditional has no effect; either collapse the branches into a
single call and remove the conditional, or implement the intended
locale-aware/comparator difference by replacing the comparator in the npm branch
with a locale/case-insensitive comparison (for example compare a.to_lowercase()
and b.to_lowercase(), or use a proper collation crate like ICU4X/unic or
similar) so the npm path actually performs a different, locale-aware sort.
| fn sort_script_names(names: Vec<String>, prefix: &str) -> Vec<String> { | ||
| let mut group_map: HashMap<String, Vec<String>> = HashMap::new(); | ||
|
|
||
| for key in &names { | ||
| let rest = if prefix.is_empty() { | ||
| key.as_str() | ||
| } else { | ||
| &key[prefix.len() + 1..] | ||
| }; | ||
|
|
||
| if let Some(idx) = rest.find(':') { | ||
| let base_len = if prefix.is_empty() { | ||
| 0 | ||
| } else { | ||
| prefix.len() + 1 | ||
| }; | ||
| let base = &key[..base_len + idx]; | ||
| group_map | ||
| .entry(base.to_string()) | ||
| .or_default() | ||
| .push(key.clone()); | ||
| } else { | ||
| group_map.entry(key.clone()).or_default().push(key.clone()); | ||
| } | ||
| } |
There was a problem hiding this comment.
Potential panic on string slicing.
Line 169 performs &key[prefix.len() + 1..] assuming key starts with prefix:. If key equals prefix exactly or doesn't contain the expected :, this could panic or produce unexpected results.
The guard at line 172 checks for : in rest, but rest is already derived from the potentially unsafe slice.
🔎 Suggested safer approach
for key in &names {
let rest = if prefix.is_empty() {
key.as_str()
} else {
- &key[prefix.len() + 1..]
+ key.get(prefix.len() + 1..).unwrap_or("")
};Or validate that key starts with {prefix}: before slicing.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fn sort_script_names(names: Vec<String>, prefix: &str) -> Vec<String> { | |
| let mut group_map: HashMap<String, Vec<String>> = HashMap::new(); | |
| for key in &names { | |
| let rest = if prefix.is_empty() { | |
| key.as_str() | |
| } else { | |
| &key[prefix.len() + 1..] | |
| }; | |
| if let Some(idx) = rest.find(':') { | |
| let base_len = if prefix.is_empty() { | |
| 0 | |
| } else { | |
| prefix.len() + 1 | |
| }; | |
| let base = &key[..base_len + idx]; | |
| group_map | |
| .entry(base.to_string()) | |
| .or_default() | |
| .push(key.clone()); | |
| } else { | |
| group_map.entry(key.clone()).or_default().push(key.clone()); | |
| } | |
| } | |
| fn sort_script_names(names: Vec<String>, prefix: &str) -> Vec<String> { | |
| let mut group_map: HashMap<String, Vec<String>> = HashMap::new(); | |
| for key in &names { | |
| let rest = if prefix.is_empty() { | |
| key.as_str() | |
| } else { | |
| key.get(prefix.len() + 1..).unwrap_or("") | |
| }; | |
| if let Some(idx) = rest.find(':') { | |
| let base_len = if prefix.is_empty() { | |
| 0 | |
| } else { | |
| prefix.len() + 1 | |
| }; | |
| let base = &key[..base_len + idx]; | |
| group_map | |
| .entry(base.to_string()) | |
| .or_default() | |
| .push(key.clone()); | |
| } else { | |
| group_map.entry(key.clone()).or_default().push(key.clone()); | |
| } | |
| } |
🤖 Prompt for AI Agents
In
crates/biome_json_analyze/src/assist/source/organize_package_json/sort_scripts.rs
around lines 162-186, the code slices key with &key[prefix.len() + 1..] assuming
key contains “prefix:”, which can panic or be incorrect when key == prefix or
doesn’t include the colon; change to safely derive rest by checking and using
strip_prefix or starts_with before slicing: if prefix.is_empty() just use
key.as_str(), otherwise check if key.starts_with(&format!("{}:", prefix)) and
then use key.strip_prefix(&format!("{}:", prefix)).unwrap_or("") (or fall back
to a safe alternative) and only search for ':' in that safe rest; similarly
compute base by using the known split point rather than indexing with
prefix.len() + 1 to avoid out-of-bounds panics.
| /// https://docs.npmjs.com/cli/v7/using-npm/workspaces?v=true#running-commands-in-the-context-of-workspaces | ||
| pub fn transform(value: &AnyJsonValue, _root: &JsonObjectValue) -> Option<AnyJsonValue> { | ||
| let object = value.as_json_object_value()?; | ||
|
|
||
| let sorted_base = sort_object_by_key_order(object, &["packages", "catalog"])?; | ||
|
|
||
| Some(AnyJsonValue::from(sorted_base)) | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's read the file to see the full context
cat -n crates/biome_json_analyze/src/assist/source/organize_package_json/sort_workspaces.rsRepository: biomejs/biome
Length of output: 619
🏁 Script executed:
# Let's check if there are other similar functions in the same directory for pattern comparison
fd -t f "\.rs$" crates/biome_json_analyze/src/assist/source/organize_package_json/ | head -10Repository: biomejs/biome
Length of output: 902
🏁 Script executed:
# Search for other public functions in similar assists to see rustdoc patterns
rg -A 3 "^pub fn " crates/biome_json_analyze/src/assist/source/organize_package_json/ | head -50Repository: biomejs/biome
Length of output: 5208
🌐 Web query:
npm CLI current version 2026 workspaces documentation
💡 Result:
As of Jan 3, 2026 the latest stable npm CLI release is v11.7.0 (released Dec 9, 2025). (gitclear.com)
Official npm CLI workspaces documentation: "Workspaces" on the npm docs site. (docs.npmjs.com)
Citations:
- 1: https://www.gitclear.com/open_repos/npm/cli/release/v11.6.3?utm_source=openai
- 2: https://docs.npmjs.com/cli/v8/using-npm/workspaces/?utm_source=openai
Add rustdoc documentation for the public function.
The transform function lacks inline rustdoc. Per the coding guidelines, assistsrequire inline documentation for their public functions. The suggested documentation below covers purpose, parameters, and return values:
📝 Suggested rustdoc addition
/// https://docs.npmjs.com/cli/v7/using-npm/workspaces?v=true#running-commands-in-the-context-of-workspaces
+/// Transforms workspace configuration by sorting keys according to the standard order.
+///
+/// Filters and orders workspace object keys to include only `packages` and `catalog`.
+///
+/// # Arguments
+/// * `value` - The JSON value to transform (must be an object)
+/// * `_root` - The root package.json object (currently unused)
+///
+/// # Returns
+/// The sorted workspace object, or `None` if the input is not an object.
pub fn transform(value: &AnyJsonValue, _root: &JsonObjectValue) -> Option<AnyJsonValue> {Update the npm documentation URL reference.
The URL references npm CLI v7 documentation, but the current version is v11 (released December 2025). Update the reference to a current version—v8 or later. Whilst the v7 docs may still be accessible, using current documentation is better for maintainability.
|
Opened #8659 with correct |
organizePackageJson (WIP)organizePackageJson (Broken)
I opened this PR after #941 (comment).
First of all, I haven’t written Rust since 2023, so my code is probably not optimal or may not use recent features. Feel free to bash me.
Summary
An assist action,
organizePackageJson, is being introduced (with a safe fix) to reorder a user’s package.json based on the infamous https://www.npmjs.com/package/sort-package-json package.This PR heavily relies on the upstream JS implementation, in some places it is exactly the same code. The implementation was fairly easy, as it was mostly a translation from JS to Rust.
Before reviewing, I recommend reading sort-package-json/defaultRules.md and possibly sort-package-json/index.js to understand how the sorting is done.
All the sorting logic implemented here has a corresponding implementation in JS provided by sort-package-json. This means that Biome should be able to produce matching output to the aforementioned package. No new features were added, this PR only mimics the package’s behavior.
While implementing this, I noticed that
crates/biome_json_syntax/src/generated.rswas not referencing the generatednodes_mutfile, unlike othergenerated.rsfiles in other crates, and I neededJsonArrayValue::with_elements. After adding it myself, I had to remove some duplicated references incrates/biome_json_syntax/src/member_ext.rsandcrates/biome_json_syntax/src/object_ext.rs, but I am not sure if that is the correct approach, a dedicated review there is needed.Test Plan
Besides some inline tests and two basic tests, the entire test suite from https://github.com/keithamus/sort-package-json was rewritten here to ensure it is working correctly. I assume we can expect 1:1 behavior.
In the future, we could create a set of test files and run them against both Biome and
sort-package-jsonto ensure they produce the same output.Docs
Documentation is included inline via rustdoc, with before/after examples and references to the authoritative sort-package-json defaultRules.