all files / htmlcs/lib/rules/ lowercase-class-with-hyphen.js

100% Statements 8/8
100% Branches 6/6
100% Functions 2/2
100% Lines 8/8
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                      103× 95× 76×     19×   19×            
/**
 * @file rule: lowercase-class-with-hyphen
 * @author nighca<nighca@live.cn>
 */
 
module.exports = {
 
    name: 'lowercase-class-with-hyphen',
 
    desc: 'ClassName should be lowercase words connected with hyphens.',
 
    lint: function (getCfg, document, reporter) {
        document.querySelectorAll('[class]').forEach(function (element) {
            if (!getCfg(element)) {
                return;
            }
 
            if (element.className.toLowerCase() !== element.className) {
                reporter.warn(element.startIndex, '018', 'ClassName should be lowercase words.');
            }
            if (element.className.indexOf('_') >= 0) {
                reporter.warn(element.startIndex, '019', 'ClassName parts should be connected with "-" insteadof "_".');
            }
        });
    }
 
};