Suppressing Linting Rules with Inline Directives

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

How to use comment directives to suppress Axe DevTools Linter rules in source files

Free Trial
Not for use with personal data

Axe DevTools Linter supports comment directives that let you suppress or re-enable linting rules directly in your source files. This is useful when a file contains a known violation that you want to acknowledge but exclude from linting, without modifying your global axe-linter.yml configuration.

Directives work in block comments (/* ... */), line comments (// ...), and HTML comments (<!-- ... -->), and are supported across all file types that Axe DevTools Linter processes.

To suppress a specific rule, include the rule name after the directive. To suppress all rules, omit the rule name.

Directives

axe-linter-disable

Disables one or more rules from the point of the directive through the rest of the file, or until a matching axe-linter-enable directive is encountered.

<!-- axe-linter-disable image-alt -->
<img src="logo.png" />
<!-- axe-linter-enable image-alt -->
<img src="other.png" />

To disable all rules (not just one), omit the rule name:

<!-- axe-linter-disable -->
<img src="logo.png" />
<a href="#"></a>
<!-- axe-linter-enable -->

axe-linter-enable

Re-enables one or more rules that were previously disabled by an axe-linter-disable directive. Rules will be linted again for any code that appears after this directive.

<!-- axe-linter-disable image-alt -->
<img src="uncaptioned.png" />
<!-- axe-linter-enable image-alt -->
<img src="must-have-alt.png" />

axe-linter-disable-next-line

Disables one or more rules for the single line immediately following the directive.

<!-- axe-linter-disable-next-line image-alt -->
<img src="logo.png" />

axe-linter-disable-line

Disables one or more rules for the line on which the directive appears.

<img src="logo.png" /> <!-- axe-linter-disable-line image-alt -->

See Also