Linter Rules
This page contains documentation for all Herb Linter rules.
Available Rules
erb-no-empty-tags
- Disallow empty ERB tagserb-no-output-control-flow
- Prevents outputting control flow blockserb-no-silent-tag-in-attribute-name
- Disallow ERB silent tags in HTML attribute nameserb-prefer-image-tag-helper
- Preferimage_tag
helper over<img>
with ERB expressionserb-require-whitespace-inside-tags
- Requires whitespace around ERB tagserb-requires-trailing-newline
- Enforces that all HTML+ERB template files end with exactly one trailing newline character.html-anchor-require-href
- Requires an href attribute on anchor tagshtml-aria-attribute-must-be-valid
- Disallow invalid or unknownaria-*
attributes.html-aria-label-is-well-formatted
-aria-label
must be well-formattedhtml-aria-level-must-be-valid
-aria-level
must be between 1 and 6html-aria-role-heading-requires-level
- Requiresaria-level
when supplying arole
html-aria-role-must-be-valid
- Therole
attribute must have a valid WAI-ARIA Role.html-attribute-double-quotes
- Enforces double quotes for attribute valueshtml-attribute-equals-spacing
- No whitespace around=
in HTML attributeshtml-attribute-values-require-quotes
- Requires quotes around attribute valueshtml-avoid-both-disabled-and-aria-disabled
- Avoid using bothdisabled
andaria-disabled
attributeshtml-boolean-attributes-no-value
- Prevents values on boolean attributeshtml-iframe-has-title
-iframe
elements must have atitle
attributehtml-img-require-alt
- Requiresalt
attributes on<img>
tagshtml-navigation-has-label
- Navigation landmarks must have accessible labelshtml-no-aria-hidden-on-focusable
- Focusable elements should not havearia-hidden="true"
html-no-block-inside-inline
- Prevents block-level elements inside inline elementshtml-no-duplicate-attributes
- Prevents duplicate attributes on HTML elementshtml-no-duplicate-ids
- Prevents duplicate IDs within a documenthtml-no-nested-links
- Prevents nested anchor tagshtml-no-positive-tab-index
- Avoid positivetabindex
valueshtml-no-self-closing
- Disallow self closing tagshtml-no-title-attribute
- Avoid using thetitle
attributehtml-tag-name-lowercase
- Enforces lowercase tag names in HTMLparser-no-errors
- Disallow parser errors in HTML+ERB documentssvg-tag-name-capitalization
- Enforces proper camelCase capitalization for SVG elements
Contributing
To add a new linter rule you can scaffold a new rule by running:
bash
cd javascript/packages/linter
scripts/generate-rule
The script creates the documentation, rule stub, and test stub based on the GitHub issue (requires the linter
label and a Rule name: [rule-name]
line).
Alternatively, you can create one manually:
- Create the rule class implementing the
Rule
interface - Add comprehensive tests in
test/rules/
- Add documentation in
docs/rules/
- Update the main linter to include the rule by default (if appropriate)
See html-tag-name-lowercase.ts
for an example implementation.