-
-
Notifications
You must be signed in to change notification settings - Fork 427
Closed
Description
I would like to ignore rules in some lines. Are there any plans to adopt such a functions?
It assume that I set the rule of "tag-pair" and I have a file of following HTML's snippet.
<div class="item">
<div class="item-name"><%= name %></div // Oops! I forgot to write > sign...
<div class="item-price"><%= price %><%= unit %></div>
<!-- close-tag against "div class=item" is defined other snippets -->In this case, I will find two errors of "tag-pair" in Line 2 and 5. But I want to skip the error of Line 5 because of expecting.
So I suppose how to write following.
<div class="item" data-htmlhint-ignore="tag-pair">
<div class="item-name"><%= name %></div // Oops! I forgot to write > sign...
<div class="item-price"><%= price %><%= unit %></div>
<!-- close-tag against "div class=item" is defined other snippets -->And I can modify src/rules/tag-pair.js
HTMLHint(master)> git di src/
diff --git a/src/rules/tag-pair.js b/src/rules/tag-pair.js
index 060e941..454ca3f 100644
--- a/src/rules/tag-pair.js
+++ b/src/rules/tag-pair.js
@@ -49,6 +49,14 @@ HTMLHint.addRule({
}
if(arrTags.length > 0){
var lastEvent = stack[stack.length-1];
+ var matches = /data-htmlhint-ignore="(.+)?"/.exec(lastEvent.raw);
+ if (matches.length) {
+ var rules = matches[1].split(/[,\s]+/);
+ if (rules.some(function (rule) { return self.id === rule; })) {
+ // skip
+ return;
+ }
+ }
reporter.error('Tag must be paired, missing: [ '+ arrTags.join('') + ' ], open tag match failed [ ' + lastEvent.raw + ' ] on line ' + lastEvent.line + '.', event.line, event.col, self, '');
}
});Would you consider it?
Thank you for your time.
eliasschoof
Metadata
Metadata
Assignees
Labels
No labels