lang
Configuration
rslint.config.ts
Rule Details
This rule enforces that every <html> element's lang prop, when set to a
literal value, is a well-formed and registered
BCP-47 language tag.
The lang attribute on the root <html> element tells assistive technology
which natural language to use when announcing the page; an invalid value
makes the assistive technology fall back to the user's default voice and
violates
WCAG 3.1.1.
The element name is resolved through the standard jsx-a11y settings —
components and polymorphicPropName — so a custom component mapped to
html (e.g. <HTMLRoot /> with
settings: { 'jsx-a11y': { components: { HTMLRoot: 'html' } } }) is checked
the same way as a literal <html> tag.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Differences from ESLint
- A non-string literal
langvalue —<html lang />,<html lang={true} />,<html lang="true" />,<html lang={1} />,<html lang={["en"]} />— is reported as an invalid value. ESLint'stags.check(value)throws aTypeErroron non-string input, which aborts the lint run on the affected file; rslint emits a normal diagnostic so the developer sees the problem without losing the rest of the file's reports.