gulp-htmlhint icon indicating copy to clipboard operation
gulp-htmlhint copied to clipboard

Allow to load custom rules giving rules directory option

Open ggirou opened this issue 8 years ago • 1 comments

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

ggirou avatar Apr 26 '16 16:04 ggirou

+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());

tdmalone avatar Oct 03 '16 02:10 tdmalone