Skip to content

fix(lint): ignore useJsxKeyInIterable in Astro#9659

Closed
raashish1601 wants to merge 1 commit intobiomejs:mainfrom
raashish1601:contributor-75/issue-9507-astro-jsx-key
Closed

fix(lint): ignore useJsxKeyInIterable in Astro#9659
raashish1601 wants to merge 1 commit intobiomejs:mainfrom
raashish1601:contributor-75/issue-9507-astro-jsx-key

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

  • skip useJsxKeyInIterable when analyzing Astro embeddings
  • add an Astro CLI regression with the React domain enabled
  • add the expected snapshot for the new regression

Closes #9507.

Testing

  • rustfmt --edition 2021 --check crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs crates/biome_cli/tests/cases/handle_astro_files.rs
  • cargo test -p biome_cli use_jsx_key_in_iterable_is_ignored_for_astro_files -- --exact (blocked locally on the shared worker machine by no space on device / long-running compile contention)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 29, 2026

⚠️ No Changeset found

Latest commit: fe00907

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-CLI Area: CLI A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Mar 29, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

Walkthrough

This PR addresses issue #9507 by modifying the useJsxKeyInIterable rule to skip analysis when processing Astro-embedded sources. The rule now detects the source's embedding kind via JsFileSource and returns early for Astro files, since JSX keys are unnecessary in Astro template expressions that compile to static HTML. A corresponding test case is added to verify this behaviour.

Possibly related PRs

Suggested labels

A-Linter, L-JavaScript

Suggested reviewers

  • siketyan
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: skipping the useJsxKeyInIterable rule for Astro files.
Description check ✅ Passed The description clearly outlines the changes: skipping the rule for Astro, adding a regression test, and references the linked issue #9507.
Linked Issues check ✅ Passed The code changes directly address issue #9507 by implementing the embedding-kind check to skip the rule in Astro files and adding the required regression test.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objectives: modifying the lint rule logic and adding Astro-specific test coverage.

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

✨ 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 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: 1

🤖 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_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs`:
- Around line 88-93: The current early return checks only for
ctx.source_type::<JsFileSource>().as_embedding_kind() == EmbeddingKind::Astro,
but that misses Astro <script> element embeds which have no embedding kind;
update the guard to also detect the containing file is an Astro file and return
early (for example, check for the presence of an Astro source type like
ctx.source_type::<AstroFileSource>() or inspect the file/language kind on ctx to
identify Astro files) so that the rule is skipped for all Astro contexts
(including EmbedCandidate::Element and the Frontmatter/TextExpression/Directive
cases).
🪄 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: 3804aa97-fb0b-4227-a828-1258d1a46fde

📥 Commits

Reviewing files that changed from the base of the PR and between c17e08e and fe00907.

⛔ Files ignored due to path filters (1)
  • crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/use_jsx_key_in_iterable_is_ignored_for_astro_files.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_cli/tests/cases/handle_astro_files.rs
  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs

Comment on lines +88 to +93
if matches!(
ctx.source_type::<JsFileSource>().as_embedding_kind(),
EmbeddingKind::Astro { .. }
) {
return Vec::new().into_boxed_slice();
}
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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify embed-kind assignment paths for Astro and this rule's guard.
# Expected: Astro EmbedCandidate::Element path does not assign EmbeddingKind::Astro,
# which means the Line 89 guard won't match those embeds.

rg -n -C4 'EmbedCandidate::(Frontmatter|Element|TextExpression|Directive)|with_embedding_kind\(EmbeddingKind::Astro' crates/biome_service/src/file_handlers/html.rs

rg -n -C3 'source_type::<JsFileSource>\(\)\.as_embedding_kind\(\)|EmbeddingKind::Astro' crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs

Repository: biomejs/biome

Length of output: 7078


Astro skip guard doesn't cover <script> element embeds

The guard on line 89 only skips when as_embedding_kind() returns EmbeddingKind::Astro { .. }. However, Astro <script> element embeds (created as EmbedCandidate::Element) are deliberately assigned no embedding kind—they only skip for Frontmatter, TextExpression, and Directive contexts. If the intent is to exclude the rule entirely from Astro files, the guard is incomplete.

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

In `@crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs`
around lines 88 - 93, The current early return checks only for
ctx.source_type::<JsFileSource>().as_embedding_kind() == EmbeddingKind::Astro,
but that misses Astro <script> element embeds which have no embedding kind;
update the guard to also detect the containing file is an Astro file and return
early (for example, check for the presence of an Astro source type like
ctx.source_type::<AstroFileSource>() or inspect the file/language kind on ctx to
identify Astro files) so that the rule is skipped for all Astro contexts
(including EmbedCandidate::Element and the Frontmatter/TextExpression/Directive
cases).

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 29, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 168 skipped benchmarks1


Comparing raashish1601:contributor-75/issue-9507-astro-jsx-key (fe00907) with main (5bfee36)

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.

@Conaclos Conaclos added the M-Likely Agent This was likely an automated PR without a human in the loop label Mar 29, 2026
@ematipico ematipico closed this Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Linter Area: linter L-JavaScript Language: JavaScript and super languages M-Likely Agent This was likely an automated PR without a human in the loop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 useJsxKeyInIterable should not apply to Astro files

3 participants