Skip to content

Commit

Permalink
Merge pull request #121 from molant/lowercase-whitelist
Browse files Browse the repository at this point in the history
Adding support for a white list of attributes that can be lower case.
  • Loading branch information
yaniswang committed May 1, 2016
2 parents fa5913f + db994d7 commit 1b649c2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/rules/attr-lowercase.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
HTMLHint.addRule({
id: 'attr-lowercase',
description: 'All attribute names must be in lowercase.',
init: function(parser, reporter){
init: function(parser, reporter, options){
var self = this;
var exceptions = Array.isArray(options) ? options : [];
parser.addListener('tagstart', function(event){
var attrs = event.attrs,
attr,
col = event.col + event.tagName.length + 1;
for(var i=0, l=attrs.length;i<l;i++){
attr = attrs[i];
var attrName = attr.name;
if(attrName !== attrName.toLowerCase()){
if (exceptions.indexOf(attrName) === -1 && attrName !== attrName.toLowerCase()){
reporter.error('The attribute name of [ '+attrName+' ] must be in lowercase.', event.line, col + attr.index, self, attr.raw);
}
}
});
}
});
});

0 comments on commit 1b649c2

Please sign in to comment.