feat: adds the useAstroClientOnlyDirectiveValue rule for .astro files - #11299
feat: adds the useAstroClientOnlyDirectiveValue rule for .astro files#11299jp-knj wants to merge 7 commits into
useAstroClientOnlyDirectiveValue rule for .astro files#11299Conversation
🦋 Changeset detectedLatest commit: 4664ba3 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 |
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
useAstroClientOnlyDirectiveValue rule for .astro filesuseAstroClientOnlyDirectiveValue rule for .astro files
WalkthroughAdds the Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/loud-sheep-remain.md:
- Around line 5-7: Update the changeset entry for
useAstroClientOnlyDirectiveValue to include a link to its public rule
documentation page, while preserving the existing description and example.
🪄 Autofix
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 Plus
Run ID: 4081b15d-9b2e-4b75-8920-d43232033969
⛔ Files ignored due to path filters (5)
crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**crates/biome_configuration/src/generated/linter_options_check.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**crates/biome_html_analyze/tests/specs/nursery/useAstroClientOnlyDirectiveValue/invalid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useAstroClientOnlyDirectiveValue/valid.astro.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (6)
.changeset/loud-sheep-remain.mdcrates/biome_html_analyze/src/lint/nursery/use_astro_client_only_directive_value.rscrates/biome_html_analyze/tests/specs/nursery/useAstroClientOnlyDirectiveValue/invalid.astrocrates/biome_html_analyze/tests/specs/nursery/useAstroClientOnlyDirectiveValue/valid.astrocrates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/use_astro_client_only_directive_value.rs
| Added the nursery rule `useAstroClientOnlyDirectiveValue`, which reports Astro `client:only` directives without an initializer. | ||
|
|
||
| For example, `<Component client:only />` triggers the rule. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add a link to the rule documentation.
Link useAstroClientOnlyDirectiveValue to its public rule page. This makes the changeset navigable for users.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.changeset/loud-sheep-remain.md around lines 5 - 7, Update the changeset
entry for useAstroClientOnlyDirectiveValue to include a link to its public rule
documentation page, while preserving the existing description and example.
Source: Coding guidelines
| pub UseAstroClientOnlyDirectiveValue { | ||
| version: "next", | ||
| name: "useAstroClientOnlyDirectiveValue", | ||
| language: "html", | ||
| recommended: false, | ||
| sources: &[RuleSource::EslintAstro("missing-client-only-directive-value").inspired()], | ||
| } |
There was a problem hiding this comment.
I suppose we don't have an astro domain yet. You should add one.
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_analyze/tests/rule_domain.rs (1)
5-11: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the new
Displayand description contracts.
crates/biome_analyze/src/rule.rsaddsDisplayandas_descriptionmappings forRuleDomain::Astro, but this test does not check them. Add assertions fordomain.to_string()anddomain.as_description()so mapping errors fail this test.As per coding guidelines, “All code changes must include appropriate tests.”
Proposed test extension
assert_eq!(domain.as_str(), "astro"); + assert_eq!(domain.to_string(), "astro"); assert_eq!(domain.manifest_dependencies(), &[&("astro", ">=1.0.0")]); assert!(domain.globals().is_empty()); + assert_eq!( + domain.as_description(), + "Use this domain inside Astro projects. This domain enables rules that are specific to Astro projects." + );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_analyze/tests/rule_domain.rs` around lines 5 - 11, Extend astro_domain_metadata with assertions for domain.to_string() and domain.as_description(), verifying the expected Display value and Astro description mapping introduced in RuleDomain. Keep the existing parsing, manifest dependency, and globals assertions unchanged.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/biome_analyze/tests/rule_domain.rs`:
- Around line 5-11: Extend astro_domain_metadata with assertions for
domain.to_string() and domain.as_description(), verifying the expected Display
value and Astro description mapping introduced in RuleDomain. Keep the existing
parsing, manifest dependency, and globals assertions unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 7b8dc11e-c6f4-4475-b911-789e775a7ccf
⛔ Files ignored due to path filters (3)
crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rsis excluded by!**/migrate/eslint_any_rule_to_biome.rsand 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 (3)
crates/biome_analyze/src/rule.rscrates/biome_analyze/tests/rule_domain.rscrates/biome_html_analyze/src/lint/nursery/use_astro_client_only_directive_value.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/biome_html_analyze/src/lint/nursery/use_astro_client_only_directive_value.rs
There was a problem hiding this comment.
Remove, we don't test these things here.
You should create a CLI test. Under cases/, there should be a file that contains the automatic activation of rules. However this is a nursery rule, so it won't active regardless. So for now let's remove
|
@jp-knj can you fix the snapshot? |
Summary
It reports
client:onlydirectives without an initializer. Includes a patch changeset.Test Plan
Added analyzer snapshot tests covering a missing
client:onlyinitializer and valid static, empty, and dynamic values.Docs
Relevant official links
client:onlydirective documentation