Code coverage report for htmlcs/lib/rules/asset-type.js

Statements: 100% (7 / 7)      Branches: 100% (2 / 2)      Functions: 100% (3 / 3)      Lines: 100% (7 / 7)      Ignored: none     

All files » htmlcs/lib/rules/ » asset-type.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 29 30 31          1             37 36     1 1     1 1                  
/**
 * @file rule: asset-type
 * @author nighca<nighca@live.cn>
 */
 
module.exports = {
 
    name: 'asset-type',
 
    desc: 'Default value of attribute "type" (<link>/<script>) does not need to be set.',
 
    lint: function (enable, document, reporter) {
        if (!enable) {
            return;
        }
 
        document.querySelectorAll('link[type="text/css"]').forEach(function (element) {
            reporter.warn(element, '001', 'Default value of attribute "type" ("text/css") does not need to be set.');
        });
 
        document.querySelectorAll('script[type="text/javascript"]').forEach(function (element) {
            reporter.warn(
                element,
                '002',
                'Default value of attribute "type" ("text/javascript") does not need to be set.'
            );
        });
    }
 
};