Skip to content

chore: extra rule sources#9872

Merged
Netail merged 2 commits intonextfrom
chore/extra-rule-sources
Apr 8, 2026
Merged

chore: extra rule sources#9872
Netail merged 2 commits intonextfrom
chore/extra-rule-sources

Conversation

@Netail
Copy link
Copy Markdown
Member

@Netail Netail commented Apr 8, 2026

Summary

Extra sources for the upcoming action useSortedPackageJson. Rule has not been released yet, so I don't think a changeset is necessary

Test Plan

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 8, 2026

⚠️ No Changeset found

Latest commit: 4d2aba2

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

@github-actions github-actions Bot added A-Linter Area: linter L-JSON Language: JSON and super languages labels Apr 8, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3cdc1501-56b9-4081-b36a-5d03d6f26f38

📥 Commits

Reviewing files that changed from the base of the PR and between 3b3c516 and 4d2aba2.

📒 Files selected for processing (1)
  • crates/biome_analyze/src/rule.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_analyze/src/rule.rs

Walkthrough

Added a new RuleSource<'a>::Sherif(&'a str) variant and updated its Display, variant_index(), as_rule_name(), namespace(), to_rule_url() and is_eslint_plugin() behaviour to match parameterised sources. Updated useSortedPackageJson rule sources to include three additional inspired sources: EslintPackageJson("sort-collections"), EslintPackageJsonDependencies("alphabetically-sorted-dependencies"), and Sherif("unordered-dependencies").

Possibly related PRs

Suggested labels

L-JavaScript

Suggested reviewers

  • dyc3
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding extra rule sources for the useSortedPackageJson rule.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of adding extra sources for useSortedPackageJson.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/extra-rule-sources

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

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_analyze/src/rule.rs`:
- Around line 199-200: Add unit tests that exercise the new RuleSource::Sherif
branch: instantiate rules using RuleSource::Sherif("repo/path") and assert
correct behaviour for Display (string formatting via impl Display),
ordering/comparison (PartialOrd/Ord or Rule::cmp), naming (Rule::name or similar
accessor), namespace generation (Rule::namespace) and URL generation (Rule::url
or to_url method). Put tests in the existing rule tests module (or create a new
#[cfg(test)] mod) and include multiple cases (different sherif identifiers and
edge cases) that assert expected strings and ordering to cover the branches
added for Sherif.
- Around line 199-200: The enum variant Sherif(&'a str) is a non-ESLint source
but the is_eslint_plugin method still treats it as plugin-like; update
is_eslint_plugin to explicitly exclude Self::Sherif(_) from returning true (add
a match arm or conditional so Sherif(_) returns false) so Sherif is not
classified as an ESLint plugin, referencing the enum variant Sherif and the
method is_eslint_plugin to locate the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1edbc9a6-b423-4ec2-8b94-f463e295158f

📥 Commits

Reviewing files that changed from the base of the PR and between 6567efa and 3b3c516.

📒 Files selected for processing (2)
  • crates/biome_analyze/src/rule.rs
  • crates/biome_json_analyze/src/assist/source/use_sorted_package_json.rs

Comment on lines +199 to +200
/// Rules from [Sherif](https://github.com/QuiiBz/sherif)
Sherif(&'a str),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Please add targeted tests for the new RuleSource::Sherif branches.

These lines add new behaviour across display, ordering, naming, namespace, and URL generation, but there’s no accompanying test coverage in this PR. A couple of focused unit tests here would save future us from spelunking regressions at 2am.

As per coding guidelines **/*.{rs,ts,tsx,js}: All code changes MUST include appropriate tests: ... and bug fixes require tests that reproduce and validate the fix.

Also applies to: 259-259, 329-329, 396-397, 409-410, 516-516

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

In `@crates/biome_analyze/src/rule.rs` around lines 199 - 200, Add unit tests that
exercise the new RuleSource::Sherif branch: instantiate rules using
RuleSource::Sherif("repo/path") and assert correct behaviour for Display (string
formatting via impl Display), ordering/comparison (PartialOrd/Ord or Rule::cmp),
naming (Rule::name or similar accessor), namespace generation (Rule::namespace)
and URL generation (Rule::url or to_url method). Put tests in the existing rule
tests module (or create a new #[cfg(test)] mod) and include multiple cases
(different sherif identifiers and edge cases) that assert expected strings and
ordering to cover the branches added for Sherif.

⚠️ Potential issue | 🟠 Major

Sherif is currently misclassified as an ESLint plugin.

Line 199 adds a non-ESLint source, but is_eslint_plugin still treats it as plugin-like by default. Please exclude Self::Sherif(_) there.

Suggested fix
 pub const fn is_eslint_plugin(&self) -> bool {
     !matches!(
         self,
         Self::Clippy(_)
             | Self::DenoLint(_)
             | Self::Eslint(_)
             | Self::GraphqlSchemaLinter(_)
             | Self::Stylelint(_)
             | Self::SortPackageJson
+            | Self::Sherif(_)
     )
 }
📝 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.

Suggested change
/// Rules from [Sherif](https://github.com/QuiiBz/sherif)
Sherif(&'a str),
pub const fn is_eslint_plugin(&self) -> bool {
!matches!(
self,
Self::Clippy(_)
| Self::DenoLint(_)
| Self::Eslint(_)
| Self::GraphqlSchemaLinter(_)
| Self::Stylelint(_)
| Self::SortPackageJson
| Self::Sherif(_)
)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_analyze/src/rule.rs` around lines 199 - 200, The enum variant
Sherif(&'a str) is a non-ESLint source but the is_eslint_plugin method still
treats it as plugin-like; update is_eslint_plugin to explicitly exclude
Self::Sherif(_) from returning true (add a match arm or conditional so Sherif(_)
returns false) so Sherif is not classified as an ESLint plugin, referencing the
enum variant Sherif and the method is_eslint_plugin to locate the change.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 8, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 168 skipped benchmarks1


Comparing chore/extra-rule-sources (4d2aba2) with next (6567efa)

Open in CodSpeed

Footnotes

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

Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Wow so many plugins... 🫠

@Netail
Copy link
Copy Markdown
Member Author

Netail commented Apr 8, 2026

Wow so many plugins... 🫠

The record is currently 5: https://biomejs.dev/linter/rules/no-script-url/

@Netail Netail merged commit 5a594fb into next Apr 8, 2026
27 checks passed
@Netail Netail deleted the chore/extra-rule-sources branch April 8, 2026 20:50
@coderabbitai coderabbitai Bot mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants