Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to load custom rules giving rules directory option #21

Open
ggirou opened this issue Apr 26, 2016 · 1 comment
Open

Allow to load custom rules giving rules directory option #21

ggirou opened this issue Apr 26, 2016 · 1 comment

Comments

@ggirou
Copy link

ggirou commented Apr 26, 2016

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
@tdmalone
Copy link

tdmalone commented Oct 3, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants