Skip to content

Linter Rule: Disallow redundant use of all in herb:disable comments

Rule: herb-disable-comment-no-redundant-all

Description

Prevents using all together with specific rule names in <%# herb:disable ... %> comments, as this is redundant.

Rationale

When you use all in a <%# herb:disable ... %> comment, it disables every linter rule for that line. Adding specific rule names alongside all is redundant because all already covers them.

This rule helps maintain clean, concise disable comments by ensuring you either use herb:disable all by itself to disable all rules or lists only the specific rules you want to disable.

Examples

✅ Good

erb
<DIV>test</DIV> <%# herb:disable all %>

<DIV class='value'>test</DIV> <%# herb:disable html-tag-name-lowercase, html-attribute-double-quotes %>

<DIV>test</DIV> <%# herb:disable html-tag-name-lowercase %>

🚫 Bad

erb
<DIV>test</DIV> <%# herb:disable all, html-tag-name-lowercase %>
Using `all` with specific rules is redundant. Use `herb:disable all` by itself or list only specific rules. (herb-disable-comment-no-redundant-all)
<DIV>test</DIV> <%# herb:disable html-tag-name-lowercase, all, html-attribute-double-quotes %>
Using `all` with specific rules is redundant. Use `herb:disable all` by itself or list only specific rules. (herb-disable-comment-no-redundant-all)
<DIV>test</DIV> <%# herb:disable all, all %>
Duplicate rule `all` in `herb:disable` comment. Remove the duplicate. (herb-disable-comment-no-duplicate-rules)
Using `all` with specific rules is redundant. Use `herb:disable all` by itself or list only specific rules. (herb-disable-comment-no-redundant-all)

Fix

Remove either the all keyword or the specific rule names:

Option 1: Keep only all

erb
<DIV class='value'>test</DIV> <%# herb:disable all %>

Option 2: Keep only specific rules

erb
<DIV class='value'>test</DIV> <%# herb:disable html-tag-name-lowercase, html-attribute-double-quotes %>

References

-

Released under the MIT License.