feat(lint/html): implement noDistractingElements for html#8287
feat(lint/html): implement noDistractingElements for html#8287dyc3 merged 3 commits intobiomejs:nextfrom
Conversation
🦋 Changeset detectedLatest commit: 0a03137 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
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 |
WalkthroughThis PR introduces a new HTML accessibility lint rule Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
.changeset/smooth-clocks-change.md (1)
5-18: Reference the tracking issue in the changesetThe 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_elementnever returnsNone, so theOption<bool>plus?inrunis a bit overkill. You could make it a plainbooland 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 feedctx.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
📒 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 Rustdbg!()macro for debugging output during test execution, and pass the--show-outputflag tocargo testto display debug output.
Use snapshot testing with theinstacrate for testing in Rust projects. Accept or reject snapshots usingcargo insta accept,cargo insta reject, orcargo 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 thenextbranch of the website repository.
Set theversionmetadata 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.rscrates/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.newcrates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.htmlcrates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.htmlcrates/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.newcrates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.htmlcrates/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.newcrates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rscrates/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.newcrates/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.newcrates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.htmlcrates/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.newcrates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rscrates/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.newcrates/biome_html_analyze/src/lint/a11y/no_distracting_elements.rscrates/biome_html_analyze/src/lint/a11y.rscrates/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.rscrates/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.rscrates/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.rscrates/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.rscrates/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.rscrates/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.rscrates/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.rscrates/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.rscrates/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 consistentFront matter and input match the
valid.htmlfixture, 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 elementsThe snapshot correctly reports two fixable diagnostics (one for
marquee, one forblink), 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 clearThis 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 elementsThe 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 ofNoDistractingElementsto theA11ygroup are in the expected shape for this generated file. No issues from this side.
b33932d to
706ffcb
Compare
| Added the `noDistractingElements` lint rule for HTML. The rule enforces that no distracting elements are used. | ||
|
|
||
| Invalid: | ||
|
|
||
| ```html | ||
| <marquee /> | ||
| <blink /> | ||
| ``` | ||
|
|
||
| Valid: | ||
|
|
||
| ```html | ||
| <div /> | ||
| ``` |
There was a problem hiding this comment.
nit: brevity
| 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. |
There was a problem hiding this comment.
Make sure to accept the snapshots
| <div> | ||
| <div /> | ||
| <marquee /> | ||
| <blink /> | ||
| </div> |
There was a problem hiding this comment.
- nit: brevity
- Need to make sure we also flag full elements too, not just self closing tags.
| <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(), |
There was a problem hiding this comment.
This .to_string() allocates a string. Look at how the jsx rule displays the name without doing that.
There was a problem hiding this comment.
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 formarquee. 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
⛔ Files ignored due to path filters (2)
crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/invalid.html.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/noDistractingElements/valid.html.snapis excluded by!**/*.snapand 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 Rustdbg!()macro for debugging output during test execution, and pass the--show-outputflag tocargo testto display debug output.
Use snapshot testing with theinstacrate for testing in Rust projects. Accept or reject snapshots usingcargo insta accept,cargo insta reject, orcargo 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 thenextbranch of the website repository.
Set theversionmetadata 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.mdcrates/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.mdcrates/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
TokenTextto avoid unnecessary allocations, and the logic for detecting, diagnosing, and removing distracting elements is sound. The use ofFixKind::Unsafeis appropriate since removing elements could affect functionality.
95-97: LGTM on the helper function!Using
eq_ignore_ascii_casefor HTML element name comparison is the right approach.
8-8: I'll verify the review comment by investigating whether theNoDistractingElementsOptionstype 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/bashFirst, 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/bashRead 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/bashFind where NoDistractingElementsOptions is defined
rg -n "NoDistractingElementsOptions" --type rust -B3 -A3
</function_calls>
Summary
close #8272
implemented noDistractingElements for html.
Test Plan
Docs