+
Skip to content

Conversation

drwpow
Copy link
Contributor

@drwpow drwpow commented Aug 6, 2025

Summary

Fixes #6951

Test Plan

  • Tests updated

Docs

Bugfix?

Copy link

changeset-bot bot commented Aug 6, 2025

🦋 Changeset detected

Latest commit: c6d5338

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

Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Walkthrough

This change updates the useSemanticElements accessibility linter rule in the Biome project. Specifically, it introduces a conditional check to exclude the ARIA roles combobox, listbox, and option from triggering the linter's semantic element suggestions. The update ensures that when these roles are encountered, the linter does not provide recommendations to replace them with native semantic HTML elements. No public API or exported entity signatures are altered.

Assessment against linked issues

Objective Addressed Explanation
Prevent the useSemanticElements rule from recommending semantic HTML replacements for elements with ARIA roles option, listbox, or combobox (#6951).
Ensure the linter skips suggestions for these roles due to browser inconsistencies and accessibility constraints (#6951).
Do not alter behaviour for other roles or suggest replacements for combobox except in explicit, safe cases, trusting developers' intent (#6951).

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected. All modifications are directly related to the objectives in the linked issue.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3522caf and c6d5338.

⛔ Files ignored due to path filters (3)
  • crates/biome_js_analyze/tests/specs/a11y/useSemanticElements/invalid.jsx.snap is excluded by !**/*.snap
  • crates/biome_js_analyze/tests/specs/a11y/useSemanticElements/invalid_self_closing.jsx.snap is excluded by !**/*.snap
  • crates/biome_js_analyze/tests/specs/a11y/useSemanticElements/valid.jsx.snap is excluded by !**/*.snap
📒 Files selected for processing (5)
  • .changeset/new-shrimps-reply.md (1 hunks)
  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useSemanticElements/invalid.jsx (0 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useSemanticElements/invalid_self_closing.jsx (0 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useSemanticElements/valid.jsx (1 hunks)
💤 Files with no reviewable changes (2)
  • crates/biome_js_analyze/tests/specs/a11y/useSemanticElements/invalid.jsx
  • crates/biome_js_analyze/tests/specs/a11y/useSemanticElements/invalid_self_closing.jsx
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_js_analyze/tests/specs/a11y/useSemanticElements/valid.jsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/new-shrimps-reply.md
  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: autofix
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Documentation
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_css_analyze)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Aug 6, 2025
@drwpow drwpow force-pushed the drwpow/semantic-element-suggestions branch 4 times, most recently from 88aae32 to 3522caf Compare August 6, 2025 07:12
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)
.changeset/new-shrimps-reply.md (1)

5-5: Add missing full stop.

Per the changeset guidelines, sentences should end with a full stop.

-Fix: remove option, combobox, listbox roles from [useSemanticElements](https://biomejs.dev/linter/rules/use-semantic-elements/) suggestions
+Fix: remove option, combobox, listbox roles from [useSemanticElements](https://biomejs.dev/linter/rules/use-semantic-elements/) suggestions.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9642ab and 3522caf.

📒 Files selected for processing (2)
  • .changeset/new-shrimps-reply.md (1 hunks)
  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{rs,toml}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Format code (Rust + TOML) using just format

Format Rust and TOML files using just f (alias for just format).

Files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
crates/biome_*/**/*

📄 CodeRabbit Inference Engine (CLAUDE.md)

Core crates must be located in /crates/biome_*/

Files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
**/*.rs

📄 CodeRabbit Inference Engine (CONTRIBUTING.md)

Update documentation for new features or changes, using inline rustdoc for rules, assists, and their options.

Files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
.changeset/*.md

📄 CodeRabbit Inference Engine (CONTRIBUTING.md)

.changeset/*.md: Changeset descriptions should be about user-facing changes, use past tense for what you did, present tense for Biome behavior, reference issues/rules/assists with links, include code blocks when applicable, and end every sentence with a full stop.
Headers in changesets should use #### or ##### only; other headers may break the changelog.

Files:

  • .changeset/new-shrimps-reply.md
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : Update the `language` field in `declare_lint_rule!` to match the language the rule applies to (e.g., `js`, `jsx`, `ts`, `tsx`).
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : When a rule requires semantic information, use the `Semantic<>` query type and access the semantic model via `ctx.model()`.
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : If a lint rule is ported from another ecosystem (e.g., ESLint), add a `sources` metadata field in `declare_lint_rule!` referencing the original rule.
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/{use*,no*}_*{vue,react,angular,svelte}*.rs : If a rule overwhelmingly applies to a specific framework, it should be named using the `use<Framework>...` or `no<Framework>...` pattern (e.g., `noVueReservedProps`).
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : If a rule provides a code action, add the `fix_kind` metadata to the `declare_lint_rule!` macro and implement the `action` function.
📚 Learning: applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : when a rule requires semantic in...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : When a rule requires semantic information, use the `Semantic<>` query type and access the semantic model via `ctx.model()`.

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
  • .changeset/new-shrimps-reply.md
📚 Learning: applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : update the `language` field in `...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : Update the `language` field in `declare_lint_rule!` to match the language the rule applies to (e.g., `js`, `jsx`, `ts`, `tsx`).

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
  • .changeset/new-shrimps-reply.md
📚 Learning: applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : if a rule provides a code action...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : If a rule provides a code action, add the `fix_kind` metadata to the `declare_lint_rule!` macro and implement the `action` function.

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
  • .changeset/new-shrimps-reply.md
📚 Learning: applies to crates/biome_analyze/biome_rule_options/lib/*.rs : use boxed slices (`box<[box]>`) i...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/*.rs : Use boxed slices (`Box<[Box<str>]>`) instead of `Vec<String>` for string arrays in rule options to save memory.

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
  • .changeset/new-shrimps-reply.md
📚 Learning: applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : when banning certain functions o...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : When banning certain functions or variables, always check if the variable is global using the semantic model to avoid false positives.

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
📚 Learning: applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : if a lint rule is ported from an...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : If a lint rule is ported from another ecosystem (e.g., ESLint), add a `sources` metadata field in `declare_lint_rule!` referencing the original rule.

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
  • .changeset/new-shrimps-reply.md
📚 Learning: applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : when implementing the `run` func...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : When implementing the `run` function for a rule, prefer transforming `Result` into `Option` and using the `?` operator for concise code.

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
📚 Learning: applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/{use*,no*}_*{vue,react,angular,svelte}*...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/{use*,no*}_*{vue,react,angular,svelte}*.rs : If a rule overwhelmingly applies to a specific framework, it should be named using the `use<Framework>...` or `no<Framework>...` pattern (e.g., `noVueReservedProps`).

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
  • .changeset/new-shrimps-reply.md
📚 Learning: applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : the `declare_lint_rule!` macro m...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : The `declare_lint_rule!` macro must be used to declare an analyzer rule type and implement the RuleMeta trait.

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
📚 Learning: applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : assign the `domains` field in `d...
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:50:18.454Z
Learning: Applies to crates/biome_analyze/biome_*/lib/src/lint/nursery/*.rs : Assign the `domains` field in `declare_lint_rule!` if the rule belongs to a specific domain (e.g., testing, framework).

Applied to files:

  • crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs
📚 Learning: the file `packages/@biomejs/biome/configuration_schema.json` is auto-generated and should not be man...
Learnt from: dyc3
PR: biomejs/biome#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/new-shrimps-reply.md
📚 Learning: applies to .changeset/*.md : changeset descriptions should be about user-facing changes, use past te...
Learnt from: CR
PR: biomejs/biome#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:49:35.574Z
Learning: Applies to .changeset/*.md : Changeset descriptions should be about user-facing changes, use past tense for what you did, present tense for Biome behavior, reference issues/rules/assists with links, include code blocks when applicable, and end every sentence with a full stop.

Applied to files:

  • .changeset/new-shrimps-reply.md
📚 Learning: applies to crates/biome_lint_rules/**/*.rs : linter rules must have a `version` metadata field in th...
Learnt from: CR
PR: biomejs/biome#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-08-05T14:49:35.574Z
Learning: Applies to crates/biome_lint_rules/**/*.rs : Linter rules must have a `version` metadata field in their implementation, set to "next" for new rules and updated to the new version when releasing.

Applied to files:

  • .changeset/new-shrimps-reply.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: autofix
🔇 Additional comments (1)
crates/biome_js_analyze/src/lint/a11y/use_semantic_elements.rs (1)

91-98: LGTM! Well-implemented solution.

The exclusion logic is correctly placed and follows the existing pattern. The detailed comments explain the rationale well, referencing the W3C documentation. This effectively addresses the accessibility concerns raised in issue #6951.

@drwpow drwpow force-pushed the drwpow/semantic-element-suggestions branch from 3522caf to 5b27e7e Compare August 6, 2025 07:16
22 │ <div role="link" ></div>
23 │ <div role="list" ></div>
> 24 │ <div role="listbox" ></div>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worth noting this wasn’t correct in the first place. <select> gets combobox by default, and will only be read as a listbox when using <select multiple>. And nobody’s using that (hopefully). We live in a society

Copy link

codspeed-hq bot commented Aug 6, 2025

CodSpeed Performance Report

Merging #7129 will not alter performance

Comparing drwpow:drwpow/semantic-element-suggestions (c6d5338) with main (b9642ab)

Summary

✅ 128 untouched benchmarks

@dyc3 dyc3 merged commit 9f4538a into biomejs:main Aug 6, 2025
30 checks passed
@github-actions github-actions bot mentioned this pull request Aug 5, 2025
@drwpow drwpow deleted the drwpow/semantic-element-suggestions branch August 6, 2025 22:53
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.

💅 [useSemanticElements] gives bad suggestions for listbox/option

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载