Skip to content

feat(lint/html): implement noDistractingElements for html#8287

Merged
dyc3 merged 3 commits intobiomejs:nextfrom
mehm8128:feat/html-no-distarcting-elements
Nov 27, 2025
Merged

feat(lint/html): implement noDistractingElements for html#8287
dyc3 merged 3 commits intobiomejs:nextfrom
mehm8128:feat/html-no-distarcting-elements

Conversation

@mehm8128
Copy link
Copy Markdown
Contributor

@mehm8128 mehm8128 commented Nov 27, 2025

Summary

close #8272

implemented noDistractingElements for html.

Test Plan

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 27, 2025

🦋 Changeset detected

Latest commit: 0a03137

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

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

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 github-actions Bot added A-Linter Area: linter L-HTML Language: HTML and super languages labels Nov 27, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 27, 2025

Walkthrough

This PR introduces a new HTML accessibility lint rule NoDistractingElements that flags the use of distracting HTML elements (<marquee> and <blink>). The implementation includes the rule module with detection logic, diagnostic emission, and an unsafe fix to remove offending elements. A changeset documents the minor release, and test fixtures validate both invalid cases (with marquee and blink elements) and valid cases (without them).

Possibly related PRs

Suggested reviewers

  • ematipico
  • dyc3

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarises the main change: implementing a new HTML lint rule for distracting elements.
Description check ✅ Passed The description references the related issue and explains what was implemented, though minimal detail is provided.
Linked Issues check ✅ Passed The PR implements the noDistractingElements rule as requested in issue #8272, with proper test files and rule integration.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the noDistractingElements rule; no extraneous modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

🧹 Nitpick comments (2)
.changeset/smooth-clocks-change.md (1)

5-18: Reference the tracking issue in the changeset

The prose and examples look good. To align with the changeset guidelines, consider explicitly linking the tracking issue so users can find more context:

-Added the `noDistractingElements` lint rule for HTML. The rule enforces that no distracting elements are used.
+Added the `noDistractingElements` lint rule for HTML. The rule enforces that no distracting elements are used. See https://github.com/biomejs/biome/issues/8272 for more details.

You can add a rule-doc link later once the website page exists.

crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs (1)

56-103: Simplify the helper return type (and consider future options wiring)

The core rule logic looks solid and matches the specs. Two small clean-ups you might consider:

  • is_marquee_or_blink_element never returns None, so the Option<bool> plus ? in run is a bit overkill. You could make it a plain bool and drop the ?:
-fn is_marquee_or_blink_element(element_name: &str) -> Option<bool> {
-    Some(element_name.eq_ignore_ascii_case("marquee") || element_name.eq_ignore_ascii_case("blink"))
-}
+fn is_marquee_or_blink_element(element_name: &str) -> bool {
+    element_name.eq_ignore_ascii_case("marquee")
+        || element_name.eq_ignore_ascii_case("blink")
+}
-        let element_name = element.name()?;
-        if is_marquee_or_blink_element(element_name.text())? {
+        let element_name = element.name()?;
+        if is_marquee_or_blink_element(element_name.text()) {
             return Some(NoDistractingElementsState {
                 name: element_name.text().to_string(),
             });
         }
  • You already declare type Options = NoDistractingElementsOptions;. If/when that type gains configuration (e.g. extra tag names), it would be natural to feed ctx.options() into the helper rather than hard-coding the list.

Nothing blocking, just polish.

📜 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 ce40337 and b33932d.

📒 Files selected for processing (7)
  • .changeset/smooth-clocks-change.md (1 hunks)
  • crates/biome_html_analyze/src/lint/a11y.rs (1 hunks)
  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs (1 hunks)
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html (1 hunks)
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new (1 hunks)
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html (1 hunks)
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the Rust dbg!() macro for debugging output during test execution, and pass the --show-output flag to cargo test to display debug output.
Use snapshot testing with the insta crate for testing in Rust projects. Accept or reject snapshots using cargo insta accept, cargo insta reject, or cargo insta review.
Write doc comments as doc tests in Rust using code blocks with assertions that will be executed during the testing phase.
Use rustdoc inline documentation for rules, assists, and their options. Create corresponding documentation PRs for other documentation updates against the next branch of the website repository.
Set the version metadata field in linter rule implementations to 'next' for newly created rules. Update this field to the new version number when releasing a minor or major version.

Files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
**/.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Changeset descriptions should be user-facing, use past tense for actions taken (e.g., 'Added new feature'), and present tense for Biome behavior (e.g., 'Biome now supports...'). Include issue links, rule links, and code examples where applicable.

Files:

  • .changeset/smooth-clocks-change.md
🧠 Learnings (31)
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/tests/specs/**/*.{js,ts,tsx,jsx,json,css,graphql} : Test files should use 'invalid' or 'valid' prefixes to indicate whether they contain code reported by the rule

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Code blocks in documentation can use 'ignore' property to exclude snippets from automatic validation (use sparingly)

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Code blocks in rule documentation must specify a language and use 'expect_diagnostic' property for invalid snippets that should emit exactly one diagnostic

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rule documentation must include a '## Examples' header followed by '### Invalid' and '### Valid' sections, with '### Invalid' appearing first

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Code blocks in documentation marked with 'expect_diagnostic' must emit exactly one diagnostic for the build system to generate it automatically

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that report valid but misleading code should use the 'noMisleading<Concept>' naming convention (e.g., `noMisleadingCharacterClass`)

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules should only have severity set to 'error' if they report hard errors, dangerous code, or accessibility issues; use 'warn' for possibly erroneous code; use 'info' for stylistic suggestions

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Code blocks in documentation marked with 'options' should contain only rule-specific options in JSON/JSONC format, while 'full_options' contains complete biome.json configuration

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rule documentation must have a '## Options' section after the '## Examples' section if the rule supports options, with each option having its own h3 header

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that report runtime errors from mistyping should use 'noInvalid<Concept>' or 'useValid<Concept>' naming conventions (e.g., `noInvalidConstructorSuper`, `useValidTypeof`)

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Deprecated rules must include a 'deprecated' field in the 'declare_lint_rule!' macro with the reason for deprecation

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules ported from other ecosystems should include a 'sources' field in the 'declare_lint_rule!' macro with RuleSource metadata (e.g., '::ESLint')

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : The 'declare_lint_rule!' macro must include a 'version' field set to 'next' to allow flexibility for the actual release version

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
  • .changeset/smooth-clocks-change.md
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that provide code actions must declare a 'fix_kind' field in the 'declare_lint_rule!' macro with either 'FixKind::Safe' or 'FixKind::Unsafe'

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : The 'language' field in 'declare_lint_rule!' should be set to the specific JavaScript dialect (jsx, ts, tsx) if the rule only applies to that dialect, otherwise use 'js'

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
  • .changeset/smooth-clocks-change.md
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules should be implemented with the 'impl Rule for RuleName' trait, including 'run' function that returns signals and optional 'diagnostic' and 'action' functions

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules can declare 'domains' field in 'declare_lint_rule!' to specify which domain(s) they belong to (e.g., RuleDomain::Test for testing rules)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rule names should follow the 'no<Concept>' prefix when a rule's sole intention is to forbid a single concept (e.g., `noDebugger` for disallowing debugger statements)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rule names should follow the 'use<Concept>' prefix when a rule's sole intention is to mandate a single concept (e.g., `useValidLang` for valid HTML lang attribute values)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rule implementation should use 'Type Query = Ast<NodeType>' to query the AST/CST for specific node types

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that overwhelmingly apply to a specific framework should be named using 'use<Framework>...' or 'no<Framework>...' prefix (e.g., `noVueReservedProps`)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules can declare a 'recommended' field in 'declare_lint_rule!' to indicate if they should be enabled by default

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that report redundant code should use the 'noRedundant<Concept>' naming convention (e.g., `noRedundantUseStrict`)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : The first paragraph of rule documentation must be a single line and serves as the brief description for the rule overview page

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that report unnecessary code that could be removed or simplified should use the 'noUseless<Concept>' naming convention (e.g., `noUselessConstructor`)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Avoid deep indentation in rule implementations by using Rust helper functions like 'map', 'filter', and 'and_then' instead of nested if-let statements

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:57.309Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:57.309Z
Learning: Applies to crates/biome_diagnostics/**/*.rs : Ensure the type implementing Diagnostic derives Debug

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:04:57.309Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:57.309Z
Learning: Applies to crates/biome_diagnostics/**/*.rs : Use #[derive(Diagnostic)] on enums when every variant contains a type that is itself a diagnostic

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:04:57.309Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:57.309Z
Learning: Applies to crates/biome_diagnostics/**/*.rs : Fields with #[advice] or #[verbose_advice] attributes must implement the Advices trait to record advices on the diagnostic

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new
📚 Learning: 2025-11-24T18:03:52.024Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:03:52.024Z
Learning: Applies to **/.changeset/*.md : Changeset descriptions should be user-facing, use past tense for actions taken (e.g., 'Added new feature'), and present tense for Biome behavior (e.g., 'Biome now supports...'). Include issue links, rule links, and code examples where applicable.

Applied to files:

  • .changeset/smooth-clocks-change.md
📚 Learning: 2025-11-24T18:03:52.024Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:03:52.024Z
Learning: For bugfix/feature PRs visible to Biome toolchain users or affecting published crates, create a changeset using the `just new-changeset` command with appropriate package selection, change type (major/minor/patch), and description.

Applied to files:

  • .changeset/smooth-clocks-change.md
🧬 Code graph analysis (1)
crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs (1)
crates/biome_analyze/src/rule.rs (3)
  • sources (617-620)
  • same (246-251)
  • recommended (602-605)
⏰ 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). (8)
  • GitHub Check: Documentation
  • GitHub Check: Check Dependencies
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: autofix
🔇 Additional comments (5)
crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap.new (1)

1-11: Snapshot for the valid case looks consistent

Front matter and input match the valid.html fixture, and the absence of diagnostics aligns with the rule’s intent. All good here.

crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap.new (1)

1-66: Invalid snapshot cleanly exercises both offending elements

The snapshot correctly reports two fixable diagnostics (one for marquee, one for blink), with ranges, messages, notes, and unsafe removal diffs matching the rule’s behaviour. Nicely representative fixture.

crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html (1)

1-2: Valid fixture is minimal and clear

This is a neat “no-op” example for the rule: comment explains intent and the markup contains no distracting elements. Fits the spec nicely.

crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html (1)

1-6: Invalid fixture nicely isolates the problem elements

The mix of a harmless nested <div /> alongside <marquee /> and <blink /> is a good way to check the rule targets only the distracting elements. Looks spot on.

crates/biome_html_analyze/src/lint/a11y.rs (1)

7-11: A11y group wiring looks correct

pub mod no_distracting_elements; and the addition of NoDistractingElements to the A11y group are in the expected shape for this generated file. No issues from this side.

@mehm8128 mehm8128 force-pushed the feat/html-no-distarcting-elements branch from b33932d to 706ffcb Compare November 27, 2025 13:24
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Good start!

Comment thread .changeset/smooth-clocks-change.md Outdated
Comment on lines +5 to +18
Added the `noDistractingElements` lint rule for HTML. The rule enforces that no distracting elements are used.

Invalid:

```html
<marquee />
<blink />
```

Valid:

```html
<div />
```
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.

nit: brevity

Suggested change
Added the `noDistractingElements` lint rule for HTML. The rule enforces that no distracting elements are used.
Invalid:
```html
<marquee />
<blink />
```
Valid:
```html
<div />
```
Added the `noDistractingElements` lint rule for HTML. The rule enforces that no distracting elements like `<marquee>` or `<blink>` are used.

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.

Make sure to accept the snapshots

Comment on lines +2 to +6
<div>
<div />
<marquee />
<blink />
</div>
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.

  1. nit: brevity
  2. Need to make sure we also flag full elements too, not just self closing tags.
Suggested change
<div>
<div />
<marquee />
<blink />
</div>
<marquee />
<blink />
<blink></blink>

let element_name = element.name()?;
if is_marquee_or_blink_element(element_name.text()) {
return Some(NoDistractingElementsState {
name: element_name.text().to_string(),
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.

This .to_string() allocates a string. Look at how the jsx rule displays the name without doing that.

@mehm8128 mehm8128 requested a review from dyc3 November 27, 2025 14:42
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: 0

🧹 Nitpick comments (2)
.changeset/smooth-clocks-change.md (1)

5-5: Enhance the changeset with issue link and code example.

Per coding guidelines, changeset descriptions should include issue links and code examples where applicable. Consider adding a reference to issue #8272 and a brief code example showing what the rule flags.

Example enhancement:

-Added the `noDistractingElements` lint rule for HTML. The rule enforces that no distracting elements like `<marquee>` or `<blink>` are used.
+Added the `noDistractingElements` lint rule for HTML. The rule enforces that no distracting elements like `<marquee>` or `<blink>` are used.
+
+Closes #8272
+
+```html
+<marquee>This is distracting</marquee>
+```

Based on coding guidelines for changeset files.

crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html (1)

2-4: Consider adding a full marquee element for test symmetry.

You've tested both self-closing and full element syntax for blink, but only the self-closing syntax for marquee. Adding <marquee></marquee> would ensure complete coverage of both element types in both formats.

 <!-- should generate diagnostics -->
 <marquee />
 <blink />
 <blink></blink>
+<marquee></marquee>
📜 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 706ffcb and 0a03137.

⛔ Files ignored due to path filters (2)
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (3)
  • .changeset/smooth-clocks-change.md (1 hunks)
  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs (1 hunks)
  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Changeset descriptions should be user-facing, use past tense for actions taken (e.g., 'Added new feature'), and present tense for Biome behavior (e.g., 'Biome now supports...'). Include issue links, rule links, and code examples where applicable.

Files:

  • .changeset/smooth-clocks-change.md
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the Rust dbg!() macro for debugging output during test execution, and pass the --show-output flag to cargo test to display debug output.
Use snapshot testing with the insta crate for testing in Rust projects. Accept or reject snapshots using cargo insta accept, cargo insta reject, or cargo insta review.
Write doc comments as doc tests in Rust using code blocks with assertions that will be executed during the testing phase.
Use rustdoc inline documentation for rules, assists, and their options. Create corresponding documentation PRs for other documentation updates against the next branch of the website repository.
Set the version metadata field in linter rule implementations to 'next' for newly created rules. Update this field to the new version number when releasing a minor or major version.

Files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
🧠 Learnings (17)
📚 Learning: 2025-11-24T18:03:52.024Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:03:52.024Z
Learning: Applies to **/.changeset/*.md : Changeset descriptions should be user-facing, use past tense for actions taken (e.g., 'Added new feature'), and present tense for Biome behavior (e.g., 'Biome now supports...'). Include issue links, rule links, and code examples where applicable.

Applied to files:

  • .changeset/smooth-clocks-change.md
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : The 'language' field in 'declare_lint_rule!' should be set to the specific JavaScript dialect (jsx, ts, tsx) if the rule only applies to that dialect, otherwise use 'js'

Applied to files:

  • .changeset/smooth-clocks-change.md
  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:03:52.024Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:03:52.024Z
Learning: For bugfix/feature PRs visible to Biome toolchain users or affecting published crates, create a changeset using the `just new-changeset` command with appropriate package selection, change type (major/minor/patch), and description.

Applied to files:

  • .changeset/smooth-clocks-change.md
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : The 'declare_lint_rule!' macro must include a 'version' field set to 'next' to allow flexibility for the actual release version

Applied to files:

  • .changeset/smooth-clocks-change.md
  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Deprecated rules must include a 'deprecated' field in the 'declare_lint_rule!' macro with the reason for deprecation

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules ported from other ecosystems should include a 'sources' field in the 'declare_lint_rule!' macro with RuleSource metadata (e.g., '::ESLint')

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that provide code actions must declare a 'fix_kind' field in the 'declare_lint_rule!' macro with either 'FixKind::Safe' or 'FixKind::Unsafe'

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules can declare 'domains' field in 'declare_lint_rule!' to specify which domain(s) they belong to (e.g., RuleDomain::Test for testing rules)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules should only have severity set to 'error' if they report hard errors, dangerous code, or accessibility issues; use 'warn' for possibly erroneous code; use 'info' for stylistic suggestions

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : When checking string values in rules, prefer using '&str' or 'TokenText' comparisons instead of calling 'to_string()' to avoid unnecessary heap allocations

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules should be implemented with the 'impl Rule for RuleName' trait, including 'run' function that returns signals and optional 'diagnostic' and 'action' functions

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rule names should follow the 'no<Concept>' prefix when a rule's sole intention is to forbid a single concept (e.g., `noDebugger` for disallowing debugger statements)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rule names should follow the 'use<Concept>' prefix when a rule's sole intention is to mandate a single concept (e.g., `useValidLang` for valid HTML lang attribute values)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Code blocks in rule documentation must specify a language and use 'expect_diagnostic' property for invalid snippets that should emit exactly one diagnostic

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that report valid but misleading code should use the 'noMisleading<Concept>' naming convention (e.g., `noMisleadingCharacterClass`)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that overwhelmingly apply to a specific framework should be named using 'use<Framework>...' or 'no<Framework>...' prefix (e.g., `noVueReservedProps`)

Applied to files:

  • crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/tests/specs/**/*.{js,ts,tsx,jsx,json,css,graphql} : Test files should use 'invalid' or 'valid' prefixes to indicate whether they contain code reported by the rule

Applied to files:

  • crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html
⏰ 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). (9)
  • GitHub Check: autofix
  • GitHub Check: Documentation
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Validate rules documentation
🔇 Additional comments (3)
crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs (3)

52-93: LGTM on the Rule implementation!

The implementation correctly uses TokenText to avoid unnecessary allocations, and the logic for detecting, diagnosing, and removing distracting elements is sound. The use of FixKind::Unsafe is appropriate since removing elements could affect functionality.


95-97: LGTM on the helper function!

Using eq_ignore_ascii_case for HTML element name comparison is the right approach.


8-8: I'll verify the review comment by investigating whether the NoDistractingElementsOptions type is actually unused. Let me start by exploring the file and understanding the pattern used in this codebase.
<function_calls>
<atml:invoke name="capability_shell">
<atml:parameter name="request">
#!/bin/bash

First, check the structure of the file under review

wc -l crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
</atml:parameter>
</atml:invoke>
</function_calls>
atml:function_calls
<atml:invoke name="capability_shell">
<atml:parameter name="request">
#!/bin/bash

Read the full file to understand the Options type usage

cat -n crates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rs
</atml:parameter>

</function_calls>
<function_calls>
<atml:invoke name="capability_shell">
<atml:parameter name="request">
#!/bin/bash

Find where NoDistractingElementsOptions is defined

rg -n "NoDistractingElementsOptions" --type rust -B3 -A3


</function_calls>

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

Labels

A-Linter Area: linter L-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants