all files / htmlcs/lib/rules/ img-title.js

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                      103×                
/**
 * @file rule: img-title
 * @author nighca<nighca@live.cn>
 */
 
module.exports = {
 
    name: 'img-title',
 
    desc: 'Attribute "title" of <img> is not recommended to be set.',
 
    lint: function (getCfg, document, reporter) {
        document.querySelectorAll('img[title]').forEach(function (img) {
            if (!getCfg(img)) {
                return;
            }
 
            reporter.warn(img.startIndex, '014', 'Attribute "title" of <img> is not recommended to be set.');
        });
 
    }
 
};