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