all files / htmlcs/lib/rules/ attr-lowercase.js

100% Statements 6/6
100% Branches 4/4
100% Functions 2/2
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                          103× 867× 855×     12×                    
/**
 * @file rule: attr-lowercase
 * @author nighca<nighca@live.cn>
 */
 
module.exports = {
 
    name: 'attr-lowercase',
 
    desc: 'Attribute name must be lowercase.',
 
    target: 'parser',
 
    lint: function (getCfg, parser, reporter) {
        parser.tokenizer.on('attribname', function (name) {
            if (!getCfg()) {
                return;
            }
 
            if (name !== name.toLowerCase()) {
                reporter.warn(
                    this._sectionStart,
                    '029',
                    'Attribute name must be lowercase.'
                );
            }
        });
    }
 
};