Skip to content

Commit

Permalink
Adding support for a white list of attributes that can be lower case.
Browse files Browse the repository at this point in the history
When enabling the rule instead of using a boolean, use an array with the attributes (camelCased) that you want to ignore
```json
{
  "attr-lowercase": ["viewBox"]
}
```
Fixes #28
  • Loading branch information
molant committed Apr 15, 2016
1 parent fa5913f commit db994d7
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 db994d7

Please sign in to comment.