all files / htmlcs/lib/rules/ no-bom.js

100% Statements 5/5
100% Branches 4/4
100% Functions 1/1
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 25 26                            103× 101×              
/**
 * @file rule: no-bom
 * @author chris<wfsr@foxmail.com>
 */
 
module.exports = {
 
    name: 'no-bom',
 
    desc: 'HTML file should save with UTF-8 encoding without BOM.',
 
    target: 'parser',
 
    lint: function (getCfg, parser, reporter, code) {
 
        if (!getCfg()) {
            return;
        }
 
        if (code.charCodeAt(0) === 0xFEFF) {
            reporter.warn(0, '046', 'Unexpected Unicode BOM (Byte Order Mark).');
        }
    }
 
};