Skip to content

Linter Rule: Disallow duplicate rule names in herb:disable comments

Rule: herb-disable-comment-no-duplicate-rules

Description

Prevents listing the same rule name multiple times in a <%# herb:disable ... %> comment.

Rationale

Listing a rule name more than once in a <%# herb:disable ... %> comment is unnecessary and likely indicates a copy-paste error or mistake. Each rule only needs to be mentioned once to be disabled.

This rule helps keep disable comments clean and prevents confusion about which rules are being disabled.

Examples

✅ Good

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

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

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

🚫 Bad

erb
<DIV>test</DIV> <%# herb:disable html-tag-name-lowercase, html-tag-name-lowercase %>
Duplicate rule `html-tag-name-lowercase` in `herb:disable` comment. Remove the duplicate. (herb-disable-comment-no-duplicate-rules)
<DIV class='value'>test</DIV> <%# herb:disable html-attribute-double-quotes, html-tag-name-lowercase, html-tag-name-lowercase %>
Duplicate rule `html-tag-name-lowercase` in `herb:disable` comment. Remove the duplicate. (herb-disable-comment-no-duplicate-rules)
<DIV class='value'>test</DIV> <%# herb:disable html-tag-name-lowercase, html-tag-name-lowercase, html-attribute-double-quotes, html-attribute-double-quotes %>
Duplicate rule `html-attribute-double-quotes` in `herb:disable` comment. Remove the duplicate. (herb-disable-comment-no-duplicate-rules)
Duplicate rule `html-tag-name-lowercase` in `herb:disable` comment. Remove the duplicate. (herb-disable-comment-no-duplicate-rules)
<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 the duplicate rule names, keeping only one instance of each:

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

References

-

Released under the MIT License.