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-require-whitespace-inside-tags
- Requires whitespace around erb tagshtml-anchor-require-href
- Requires an href attribute on anchor tagshtml-aria-attribute-must-be-valid
- Disallow invalid or unknownaria-*
attributes.html-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-values-require-quotes
- Requires quotes around attribute valueshtml-boolean-attributes-no-value
- Prevents values on boolean attributeshtml-img-require-alt
- Requires alt attributes on img tagshtml-no-block-inside-inline
- Prevents block-level elements inside inline elementshtml-no-duplicate-ids
- Prevents duplicate IDs within a documenthtml-no-duplicate-attributes
- Prevents duplicate attributes on HTML elementshtml-no-nested-links
- Prevents nested anchor tagshtml-tag-name-lowercase
- Enforces lowercase tag names in HTML
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.