fix(lint): ignore useJsxKeyInIterable in Astro#9659
fix(lint): ignore useJsxKeyInIterable in Astro#9659raashish1601 wants to merge 1 commit intobiomejs:mainfrom
Conversation
|
WalkthroughThis PR addresses issue Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 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
⛔ 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.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (2)
crates/biome_cli/tests/cases/handle_astro_files.rscrates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
| if matches!( | ||
| ctx.source_type::<JsFileSource>().as_embedding_kind(), | ||
| EmbeddingKind::Astro { .. } | ||
| ) { | ||
| return Vec::new().into_boxed_slice(); | ||
| } |
There was a problem hiding this comment.
🧩 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.rsRepository: 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).
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
useJsxKeyInIterablewhen analyzing Astro embeddingsCloses #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.rscargo test -p biome_cli use_jsx_key_in_iterable_is_ignored_for_astro_files -- --exact(blocked locally on the shared worker machine byno space on device/ long-running compile contention)