Code coverage report for htmlcs/lib/rules/lowercase-class-with-hyphen.js

Statements: 100% (8 / 8)      Branches: 100% (6 / 6)      Functions: 100% (2 / 2)      Lines: 100% (8 / 8)      Ignored: none     

All files » htmlcs/lib/rules/ » lowercase-class-with-hyphen.js
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          1             37 36     1 3 1   3 1            
/**
 * @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 (enable, document, reporter) {
        if (!enable) {
            return;
        }
 
        document.querySelectorAll('[class]').forEach(function (element) {
            if (element.className.toLowerCase() !== element.className) {
                reporter.warn(element, '018', 'ClassName should be lowercase words.');
            }
            if (element.className.indexOf('_') >= 0) {
                reporter.warn(element, '019', 'ClassName parts should be connected with "-" insteadof "_".');
            }
        });
    }
 
};