Skip to content

fix(useJsxKeyInIterable): ignore rule in Map constructor#8758

Merged
dyc3 merged 1 commit intobiomejs:mainfrom
Pranav2612000:fix/dont-run-use-jsx-key-in-iterable-in-map-constructor
Feb 10, 2026
Merged

fix(useJsxKeyInIterable): ignore rule in Map constructor#8758
dyc3 merged 1 commit intobiomejs:mainfrom
Pranav2612000:fix/dont-run-use-jsx-key-in-iterable-in-map-constructor

Conversation

@Pranav2612000
Copy link
Contributor

Summary

Test Plan

  • Adds snapshot tests for the rule

@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2026

🦋 Changeset detected

Latest commit: 94ce0bd

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

@Pranav2612000
Copy link
Contributor Author

Does the change also require creating a changeset?

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Jan 13, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This change updates the useJsxKeyInIterable lint rule to skip key-in-iterable checks for JSX elements inside arrays that are used with new Map([...]). It adds a should_ignore_check function that walks from a JsArrayExpression through parent nodes to detect Map constructor patterns, imports additional AST node types to support the traversal, and early-returns from handle_collections when matched. Tests (valid and invalid cases) and a changeset documenting the behavioural update were added. Public APIs remain unchanged.

Suggested labels

A-Diagnostic

Suggested reviewers

  • siketyan
  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: ignoring the useJsxKeyInIterable rule in Map constructors, which aligns with the changeset and code modifications.
Description check ✅ Passed The description properly references the linked issue #8572, explains the fix (ignoring the rule in Map constructors), and outlines the test plan (snapshot tests), all directly related to the changeset.
Linked Issues check ✅ Passed The code changes fully address issue #8572: the new should_ignore_check function detects Map constructor patterns and skips the rule verification, preventing false positives as required.
Out of Scope Changes check ✅ Passed All changes are scoped to the useJsxKeyInIterable rule: logic modifications, test file updates, and changeset documentation are all directly related to fixing the issue.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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

🧹 Nitpick comments (2)
crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs (2)

220-231: Use .map() instead of .and_then(|t| Some(...)).

Line 229 can be simplified - the and_then wrapping a Some is equivalent to map.

✨ Suggested simplification
 fn should_ignore_check(node: &JsArrayExpression) -> bool {
     // Map constructors don't need key in arrays e.g new Map([["Partial", <div></div>]])
     node.parent::<JsArrayElementList>()
         .and_then(|n| n.parent::<JsArrayExpression>())
         .and_then(|n| n.parent::<JsCallArgumentList>())
         .and_then(|n| n.parent::<JsCallArguments>())
         .and_then(|n| n.parent::<JsNewExpression>())
         .and_then(|n| n.callee().ok())
         .and_then(|c| c.get_callee_member_name())
-        .and_then(|t| Some(t.token_text_trimmed() == "Map"))
+        .map(|t| t.token_text_trimmed() == "Map")
         .unwrap_or(false)
 }

Based on learnings, helper functions like map are preferred over excessive nesting.


220-231: Consider handling new Set() and new WeakMap() constructors in a follow-up.

The same false positive could occur with new Set([<JSX />]) or new WeakMap([[key, <JSX />]]), which have identical semantics to new Map() regarding key requirements. This is out of scope for the current Map-specific fix but worth addressing together later.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f244526 and 0cea3c4.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (3)
  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/invalid.jsx
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/valid.jsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use inline rustdoc documentation for rules, assists, and their options
Use the dbg!() macro for debugging output in Rust tests and code
Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests

Files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
🧠 Learnings (15)
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use helper functions like `map`, `filter`, and `and_then` to avoid excessive nested `if let` statements

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Prefer using `Box<[_]>` over `Vec<_>` for signal collections to reduce memory usage

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Store type data in linear vectors instead of using recursive data structures with `Arc` for improved data locality and performance

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-12-22T09:26:56.943Z
Learnt from: ematipico
Repo: biomejs/biome PR: 8537
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:167-210
Timestamp: 2025-12-22T09:26:56.943Z
Learning: When defining lint rules (declare_lint_rule!), only specify fix_kind if the rule implements an action(...) function. Rules that only emit diagnostics without a code fix should omit fix_kind. This applies to all Rust lint rule definitions under crates/.../src/lint (e.g., crates/biome_js_analyze/src/lint/...).

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `declare_node_union!` macro to query multiple node types together to avoid redundant traversal passes

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Implement custom `Queryable` and `Visitor` types for rules that require deep inspection of child nodes to avoid inefficient traversals

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/js_module_info/collector.rs : Implement module-level (thin) inference to resolve `TypeReference::Qualifier` variants by looking up declarations in module scopes and handling import statements

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `.ok()?` to transform `Result` types into `Option` or `let else` pattern to handle errors when the function returns `Vec`

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use the `Semantic<T>` query type to access semantic information about bindings, references, and scope within a rule

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `ConditionalParsedSyntax` for syntax that is only valid in specific contexts (e.g., strict mode, file types, language versions) and call `or_invalid_to_bogus()` to convert to a bogus node if not supported

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Check if a variable is global using the semantic model before reporting diagnostics for rules that ban global functions or variables

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs (1)
crates/biome_js_analyze/src/lint/complexity/no_extra_boolean_cast.rs (1)
  • JsCallArgumentList (79-81)
🔇 Additional comments (4)
crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/invalid.jsx (1)

127-130: LGTM - tests that inner arrays within Map values still require keys.

This correctly exercises the case where a Map value is itself an array of JSX elements. Unlike a direct JSX value (tested in valid.jsx), arrays rendered as React children still need keys for reconciliation.

crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/valid.jsx (1)

152-156: LGTM - confirms Map constructor JSX values are correctly ignored.

This directly addresses the false positive from issue #8572 where JSX as a Map value was incorrectly flagged.

crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs (2)

10-12: LGTM - imports align with new AST traversal requirements.


130-132: LGTM - clean early return for the ignore condition.

@siketyan
Copy link
Member

Does the change also require creating a changeset?

Yes, please add one to describe users what is fixed

@Pranav2612000 Pranav2612000 force-pushed the fix/dont-run-use-jsx-key-in-iterable-in-map-constructor branch from 0cea3c4 to b389ad5 Compare January 13, 2026 12:20
@Pranav2612000
Copy link
Contributor Author

Done @siketyan . Is this a good changeset? Or do you have suggestions?

Copy link
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

🤖 Fix all issues with AI agents
In @.changeset/modern-crews-stick.md:
- Line 5: The changeset message has a typo in the rule name: replace the plural
form "useJsxKeyInIterables" with the correct singular rule name
"useJsxKeyInIterable" so the description accurately reflects the rule being
updated; update the text in the .changeset entry to use "useJsxKeyInIterable"
wherever the plural form appears.
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs (1)

220-231: Prefer .map() over .and_then(|x| Some(...)).

Line 229 uses .and_then(|t| Some(...)) which is equivalent to .map(|t| ...). The latter is more idiomatic Rust.

Suggested fix
 fn should_ignore_check(node: &JsArrayExpression) -> bool {
     // Map constructors don't need key in arrays e.g new Map([["Partial", <div></div>]])
     node.parent::<JsArrayElementList>()
         .and_then(|n| n.parent::<JsArrayExpression>())
         .and_then(|n| n.parent::<JsCallArgumentList>())
         .and_then(|n| n.parent::<JsCallArguments>())
         .and_then(|n| n.parent::<JsNewExpression>())
         .and_then(|n| n.callee().ok())
         .and_then(|c| c.get_callee_member_name())
-        .and_then(|t| Some(t.token_text_trimmed() == "Map"))
-        .unwrap_or(false)
+        .is_some_and(|t| t.token_text_trimmed() == "Map")
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0cea3c4 and b389ad5.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • .changeset/modern-crews-stick.md
  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/invalid.jsx
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/valid.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/invalid.jsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use inline rustdoc documentation for rules, assists, and their options
Use the dbg!() macro for debugging output in Rust tests and code
Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests

Files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
🧠 Learnings (12)
📚 Learning: 2025-12-21T21:15:03.796Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.796Z
Learning: Changesets should describe user-facing changes only; internal refactoring without behavior changes does not require a changeset

Applied to files:

  • .changeset/modern-crews-stick.md
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use helper functions like `map`, `filter`, and `and_then` to avoid excessive nested `if let` statements

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `declare_node_union!` macro to query multiple node types together to avoid redundant traversal passes

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Implement custom `Queryable` and `Visitor` types for rules that require deep inspection of child nodes to avoid inefficient traversals

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-12-22T09:26:56.943Z
Learnt from: ematipico
Repo: biomejs/biome PR: 8537
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:167-210
Timestamp: 2025-12-22T09:26:56.943Z
Learning: When defining lint rules (declare_lint_rule!), only specify fix_kind if the rule implements an action(...) function. Rules that only emit diagnostics without a code fix should omit fix_kind. This applies to all Rust lint rule definitions under crates/.../src/lint (e.g., crates/biome_js_analyze/src/lint/...).

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use the `Semantic<T>` query type to access semantic information about bindings, references, and scope within a rule

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `ConditionalParsedSyntax` for syntax that is only valid in specific contexts (e.g., strict mode, file types, language versions) and call `or_invalid_to_bogus()` to convert to a bogus node if not supported

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Check if a variable is global using the semantic model before reporting diagnostics for rules that ban global functions or variables

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs (1)
crates/biome_js_analyze/src/lint/complexity/no_extra_boolean_cast.rs (1)
  • JsCallArgumentList (79-81)
🔇 Additional comments (3)
crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs (2)

10-12: LGTM!

The additional imports for AST traversal types are appropriate for the new should_ignore_check function.


130-132: LGTM!

Clean early return to skip processing for Map constructor patterns.

crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/valid.jsx (1)

154-156: LGTM!

Good test case that directly validates the fix for issue #8572 — JSX elements inside Map constructor entries should not trigger the key-in-iterable rule.

@Pranav2612000 Pranav2612000 force-pushed the fix/dont-run-use-jsx-key-in-iterable-in-map-constructor branch from b389ad5 to a064752 Compare January 13, 2026 12:25
Copy link
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: 0

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs (1)

220-231: Simplify with .map() instead of .and_then(|t| Some(...))

Line 229 can be made more idiomatic. Based on learnings, prefer helper functions like map to avoid unnecessary constructs.

♻️ Suggested simplification
 fn should_ignore_check(node: &JsArrayExpression) -> bool {
     // Map constructors don't need key in arrays e.g new Map([["Partial", <div></div>]])
     node.parent::<JsArrayElementList>()
         .and_then(|n| n.parent::<JsArrayExpression>())
         .and_then(|n| n.parent::<JsCallArgumentList>())
         .and_then(|n| n.parent::<JsCallArguments>())
         .and_then(|n| n.parent::<JsNewExpression>())
         .and_then(|n| n.callee().ok())
         .and_then(|c| c.get_callee_member_name())
-        .and_then(|t| Some(t.token_text_trimmed() == "Map"))
-        .unwrap_or(false)
+        .is_some_and(|t| t.token_text_trimmed() == "Map")
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b389ad5 and a064752.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • .changeset/modern-crews-stick.md
  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/invalid.jsx
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/valid.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/valid.jsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use inline rustdoc documentation for rules, assists, and their options
Use the dbg!() macro for debugging output in Rust tests and code
Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests

Files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
🧠 Learnings (17)
📚 Learning: 2025-12-21T21:15:03.796Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.796Z
Learning: Changesets should describe user-facing changes only; internal refactoring without behavior changes does not require a changeset

Applied to files:

  • .changeset/modern-crews-stick.md
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.

Applied to files:

  • .changeset/modern-crews-stick.md
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Rule names should use the `use` prefix when the rule's sole intention is to mandate a single concept

Applied to files:

  • .changeset/modern-crews-stick.md
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use helper functions like `map`, `filter`, and `and_then` to avoid excessive nested `if let` statements

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `declare_node_union!` macro to query multiple node types together to avoid redundant traversal passes

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-12-22T09:26:56.943Z
Learnt from: ematipico
Repo: biomejs/biome PR: 8537
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:167-210
Timestamp: 2025-12-22T09:26:56.943Z
Learning: When defining lint rules (declare_lint_rule!), only specify fix_kind if the rule implements an action(...) function. Rules that only emit diagnostics without a code fix should omit fix_kind. This applies to all Rust lint rule definitions under crates/.../src/lint (e.g., crates/biome_js_analyze/src/lint/...).

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Implement custom `Queryable` and `Visitor` types for rules that require deep inspection of child nodes to avoid inefficient traversals

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `.ok()?` to transform `Result` types into `Option` or `let else` pattern to handle errors when the function returns `Vec`

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Prefer using `Box<[_]>` over `Vec<_>` for signal collections to reduce memory usage

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Check if a variable is global using the semantic model before reporting diagnostics for rules that ban global functions or variables

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/js_module_info/collector.rs : Implement module-level (thin) inference to resolve `TypeReference::Qualifier` variants by looking up declarations in module scopes and handling import statements

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use the `Semantic<T>` query type to access semantic information about bindings, references, and scope within a rule

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `ConditionalParsedSyntax` for syntax that is only valid in specific contexts (e.g., strict mode, file types, language versions) and call `or_invalid_to_bogus()` to convert to a bogus node if not supported

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs
🔇 Additional comments (4)
crates/biome_js_analyze/src/lint/correctness/use_jsx_key_in_iterable.rs (2)

130-132: LGTM!

Clean early-return guard. Properly short-circuits processing for Map constructor patterns.


10-12: LGTM!

Imports align with the types used in should_ignore_check.

.changeset/modern-crews-stick.md (1)

1-5: LGTM!

Changeset correctly describes the user-facing fix at an appropriate patch level.

crates/biome_js_analyze/tests/specs/correctness/useJsxKeyInIterable/invalid.jsx (1)

127-130: LGTM!

This correctly tests that the inner array within a Map entry tuple still triggers the missing key diagnostic. The should_ignore_check only exempts the tuple array itself (e.g., ["None", <div/>]), not nested arrays containing JSX.

@dyc3
Copy link
Contributor

dyc3 commented Feb 6, 2026

Sorry for the delay on this one. Please address the CI issues.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 6, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing Pranav2612000:fix/dont-run-use-jsx-key-in-iterable-in-map-constructor (94ce0bd) with main (9d1ae81)1

Summary

✅ 58 untouched benchmarks
⏩ 95 skipped benchmarks2

Footnotes

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

  2. 95 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.

@Pranav2612000 Pranav2612000 force-pushed the fix/dont-run-use-jsx-key-in-iterable-in-map-constructor branch from a064752 to 3a2020a Compare February 9, 2026 13:21
@Pranav2612000 Pranav2612000 force-pushed the fix/dont-run-use-jsx-key-in-iterable-in-map-constructor branch from 3a2020a to 94ce0bd Compare February 9, 2026 13:42
@Pranav2612000
Copy link
Contributor Author

@dyc3 I've updated the PR. Can you please re-trigger the pipelines and review the changes?

@dyc3 dyc3 merged commit 8c789f1 into biomejs:main Feb 10, 2026
18 checks passed
@github-actions github-actions bot mentioned this pull request Feb 10, 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-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useJsxKeyInIterable false alarm in Map declaration

3 participants