-
-
Notifications
You must be signed in to change notification settings - Fork 791
feat(lint/html): add useHtmlLang
#8262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: d0826c3 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 |
WalkthroughAdds a new accessibility lint rule Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (7)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.rs📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
🧠 Learnings (11)📓 Common learnings📚 Learning: 2025-11-24T18:04:42.146ZApplied to files:
📚 Learning: 2025-11-24T18:04:42.146ZApplied to files:
📚 Learning: 2025-11-24T18:04:42.146ZApplied to files:
📚 Learning: 2025-11-24T18:06:03.536ZApplied to files:
📚 Learning: 2025-11-24T18:06:03.536ZApplied to files:
📚 Learning: 2025-11-24T18:05:20.343ZApplied to files:
📚 Learning: 2025-11-24T18:04:42.146ZApplied to files:
📚 Learning: 2025-11-24T18:04:42.146ZApplied to files:
📚 Learning: 2025-11-24T18:04:42.146ZApplied to files:
📚 Learning: 2025-11-24T18:04:42.146ZApplied to files:
⏰ 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). (11)
🔇 Additional comments (1)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
.changeset/fifty-webs-sneeze.md (1)
1-19: Consider adding issue and rule links to the changesetThe description and examples look good; I’d just add links for traceability, e.g.:
-Added the `useHtmlLang` lint rule for HTML. The rule enforces that the `html` element has a `lang` attribute. +Added the `useHtmlLang` lint rule for HTML. The rule enforces that the `html` element has a `lang` attribute. + +- Related issue: https://github.com/biomejs/biome/issues/8155 +- Rule documentation: https://biomejs.dev/linter/rules/use-html-langAs per coding guidelines, this keeps the changeset more user-facing and discoverable.
crates/biome_html_analyze/tests/specs/a11y/useHtmlLang/invalid.html (1)
1-5: Nice spread of invalid cases; optionally add a whitespace-only valueThis hits the obvious failure modes. If you want to fully pin down the
trim_asciilogic, you could add a whitespace-only value case, e.g.:<html lang=" "></html>Purely optional, but it would make the intent around “empty after trimming” explicit in the snapshots.
crates/biome_html_analyze/src/lint/a11y/use_html_lang.rs (1)
10-42: Rule metadata and docs look good; consider documenting optionsThe rule declaration ticks the usual boxes:
version: "next",language: "html", ESLint source,recommended: true, andSeverity::Errorfor an a11y rule all make sense.You’re already following the
## Examples/### Invalid/### Validstructure; since the rule usesUseHtmlLangOptions, it would be nice to surface an## Optionssection in the doc comment (even if it just points to the shared options for now), e.g.:- /// ### Valid - /// - /// ```html - /// <html lang="en"></html> - /// ``` - /// - /// ## Accessibility guidelines + /// ### Valid + /// + /// ```html + /// <html lang="en"></html> + /// ``` + /// + /// ## Options + /// + /// Refer to the shared `useHtmlLang` rule options for configuration details. + /// + /// ## Accessibility guidelinesAs per coding guidelines, this keeps rule docs aligned with options support.
📜 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/useHtmlLang/invalid.html.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/a11y/useHtmlLang/valid.html.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (5)
.changeset/fifty-webs-sneeze.md(1 hunks)crates/biome_html_analyze/src/lint/a11y.rs(1 hunks)crates/biome_html_analyze/src/lint/a11y/use_html_lang.rs(1 hunks)crates/biome_html_analyze/tests/specs/a11y/useHtmlLang/invalid.html(1 hunks)crates/biome_html_analyze/tests/specs/a11y/useHtmlLang/valid.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/fifty-webs-sneeze.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.rscrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
🧠 Learnings (22)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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'
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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/useHtmlLang/valid.htmlcrates/biome_html_analyze/tests/specs/a11y/useHtmlLang/invalid.html
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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/useHtmlLang/invalid.html
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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/useHtmlLang/invalid.htmlcrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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/tests/specs/a11y/useHtmlLang/invalid.html.changeset/fifty-webs-sneeze.mdcrates/biome_html_analyze/src/lint/a11y.rscrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:05:20.343Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.343Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/language.rs : Implement `TestFormatLanguage` trait in `tests/language.rs` for the formatter's test language
Applied to files:
crates/biome_html_analyze/tests/specs/a11y/useHtmlLang/invalid.html
📚 Learning: 2025-11-24T18:03:52.013Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:03:52.013Z
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/fifty-webs-sneeze.md
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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/fifty-webs-sneeze.mdcrates/biome_html_analyze/src/lint/a11y.rscrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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:
.changeset/fifty-webs-sneeze.mdcrates/biome_html_analyze/src/lint/a11y.rscrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:03:52.013Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:03:52.013Z
Learning: Applies to **/*.rs : 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.
Applied to files:
.changeset/fifty-webs-sneeze.md
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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:
.changeset/fifty-webs-sneeze.mdcrates/biome_html_analyze/src/lint/a11y.rscrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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:
.changeset/fifty-webs-sneeze.mdcrates/biome_html_analyze/src/lint/a11y.rscrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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.rscrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules that ensure consistency across the codebase should use the 'useConsistent<Concept>' naming convention (e.g., `useConsistentArrayType`)
Applied to files:
crates/biome_html_analyze/src/lint/a11y.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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.rscrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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.rscrates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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/use_html_lang.rs
📚 Learning: 2025-11-24T18:05:20.343Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.343Z
Learning: Define `FormatHtmlSyntaxNode` struct in a `cst.rs` file implementing `FormatRule<HtmlSyntaxNode>`, `AsFormat<HtmlFormatContext>`, and `IntoFormat<HtmlFormatContext>` traits using the provided boilerplate code
Applied to files:
crates/biome_html_analyze/src/lint/a11y/use_html_lang.rs
📚 Learning: 2025-11-24T18:04:42.146Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.146Z
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/use_html_lang.rs
🧬 Code graph analysis (2)
crates/biome_html_analyze/src/lint/a11y.rs (1)
crates/biome_html_syntax/src/element_ext.rs (1)
name(55-70)
crates/biome_html_analyze/src/lint/a11y/use_html_lang.rs (5)
crates/biome_service/src/workspace.rs (1)
markup(1149-1151)packages/@biomejs/plugin-api/index.d.ts (1)
Severity(1-1)crates/biome_analyze/src/rule.rs (3)
sources(610-613)same(246-251)recommended(595-598)crates/biome_service/src/workspace_types.rs (1)
Self(539-539)crates/biome_rowan/src/syntax/token.rs (1)
token_text(121-123)
⏰ 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: End-to-end tests
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Check Dependencies
- GitHub Check: autofix
🔇 Additional comments (3)
crates/biome_html_analyze/tests/specs/a11y/useHtmlLang/valid.html (1)
1-2: Valid fixture is clear and sufficientHappy-path HTML with
lang="en"is nicely minimal; this should keep the non-diagnostic snapshot easy to reason about.crates/biome_html_analyze/src/lint/a11y.rs (1)
5-10: A11y group wiring forUseHtmlLanglooks consistentExporting
use_html_langand registeringUseHtmlLangin theA11ygroup matches the pattern of the existing rules; no issues spotted here.crates/biome_html_analyze/src/lint/a11y/use_html_lang.rs (1)
86-90: Helper keeps the query focused on<html>elementsThe
is_html_elementhelper witheq_ignore_ascii_case("html")keeps therunbody tidy and correctly handles mixed-case tag names.
dyc3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
It looks like the cli test snapshots need to be updated too. |
6bfbe60 updated. Thanks! |
CodSpeed Performance ReportMerging #8262 will not alter performanceComparing Summary
Footnotes
|
Summary
This PR is a subtask of #8155. It ports the useHtmlLang rule to HTML.
Test Plan