gulp-htmlhint
gulp-htmlhint copied to clipboard
Allow to load custom rules giving rules directory option
With htmlhint 0.9.12, it's possible to load custom rules giving a directory option
htmlhint --plugin ./plugins/ --rules test-rule
In the next release, this option will be renamed to rulesdir
htmlhint --rulesdir ./rules/ --rules test-rule
+1 to this. In the meantime, hunting through the source of gulp-htmlhint, it appears the addRule function is passed through to htmlhint. So, you could do this:
htmlhint.addRule({
id: 'test-rule',
description: 'test rule.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
var tagName = event.tagName.toLowerCase();
if(tagName === 'body'){
reporter.warn('Found body.', event.line, event.col, self, event.raw);
}
});
}
});
gulp.src('index.html')
.pipe(htmlhint());