Skip to content

feat: adds the useAstroClientOnlyDirectiveValue rule for .astro files - #11299

Open
jp-knj wants to merge 7 commits into
biomejs:mainfrom
jp-knj:feat/use-astro-client-only-directive-value
Open

feat: adds the useAstroClientOnlyDirectiveValue rule for .astro files#11299
jp-knj wants to merge 7 commits into
biomejs:mainfrom
jp-knj:feat/use-astro-client-only-directive-value

Conversation

@jp-knj

@jp-knj jp-knj commented Aug 10, 2026

Copy link
Copy Markdown

Summary

It reports client:only directives without an initializer. Includes a patch changeset.

This PR was created with AI assistance from OpenAI Codex.

Test Plan

Added analyzer snapshot tests covering a missing client:only initializer and valid static, empty, and dynamic values.

Docs

Relevant official links

@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4664ba3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Organic activity

No automation signals detected in the analyzed events.

View full analysis →

This is an automated analysis by AgentScan

@github-actions github-actions Bot added A-Project Area: project A-Linter Area: linter A-Diagnostic Area: diagnostocis L-HTML Language: HTML and super languages labels Aug 10, 2026
@jp-knj jp-knj changed the title Adds the useAstroClientOnlyDirectiveValue rule for .astro files feat: adds the useAstroClientOnlyDirectiveValue rule for .astro files Aug 10, 2026
@jp-knj
jp-knj marked this pull request as ready for review August 10, 2026 12:50
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds the useAstroClientOnlyDirectiveValue nursery rule. The rule reports Astro client:only directives without an initializer and accepts empty or dynamic values. The change adds Astro rule-domain support, the public options type, test fixtures, domain tests, and a patch changeset.

Suggested reviewers: ematipico, netail

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the new useAstroClientOnlyDirectiveValue rule for .astro files.
Description check ✅ Passed The description explains the rule behaviour, tests, changeset, references, and AI assistance disclosure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@coderabbitai coderabbitai Bot left a comment

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between db36fb4 and 8991ea5.

⛔ Files ignored due to path filters (5)
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_configuration/src/generated/linter_options_check.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_html_analyze/tests/specs/nursery/useAstroClientOnlyDirectiveValue/invalid.astro.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_analyze/tests/specs/nursery/useAstroClientOnlyDirectiveValue/valid.astro.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (6)
  • .changeset/loud-sheep-remain.md
  • crates/biome_html_analyze/src/lint/nursery/use_astro_client_only_directive_value.rs
  • crates/biome_html_analyze/tests/specs/nursery/useAstroClientOnlyDirectiveValue/invalid.astro
  • crates/biome_html_analyze/tests/specs/nursery/useAstroClientOnlyDirectiveValue/valid.astro
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/use_astro_client_only_directive_value.rs

Comment on lines +5 to +7
Added the nursery rule `useAstroClientOnlyDirectiveValue`, which reports Astro `client:only` directives without an initializer.

For example, `<Component client:only />` triggers the rule.

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.

📐 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

Comment on lines +38 to +44
pub UseAstroClientOnlyDirectiveValue {
version: "next",
name: "useAstroClientOnlyDirectiveValue",
language: "html",
recommended: false,
sources: &[RuleSource::EslintAstro("missing-client-only-directive-value").inspired()],
}

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.

I suppose we don't have an astro domain yet. You should add one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

add 7d188b9, Thanks

@codspeed-hq

codspeed-hq Bot commented Aug 10, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 121 untouched benchmarks
⏩ 179 skipped benchmarks1


Comparing jp-knj:feat/use-astro-client-only-directive-value (546542a) with main (fe5b5d4)2

Open in CodSpeed

Footnotes

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

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

@github-actions github-actions Bot added the A-CLI Area: CLI label Aug 10, 2026

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
crates/biome_analyze/tests/rule_domain.rs (1)

5-11: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the new Display and description contracts.

crates/biome_analyze/src/rule.rs adds Display and as_description mappings for RuleDomain::Astro, but this test does not check them. Add assertions for domain.to_string() and domain.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

📥 Commits

Reviewing files that changed from the base of the PR and between 8991ea5 and 7d188b9.

⛔ Files ignored due to path filters (3)
  • crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs is excluded by !**/migrate/eslint_any_rule_to_biome.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 (3)
  • crates/biome_analyze/src/rule.rs
  • crates/biome_analyze/tests/rule_domain.rs
  • crates/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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@ematipico

Copy link
Copy Markdown
Member

@jp-knj can you fix the snapshot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants