Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (rules, source) => {
const parser = new SAXParser({sourceCodeLocationInfo: true});
return new Promise(resolve => {
parser.on(
'startTag',
({tagName, selfClosing, sourceCodeLocation: {startLine, startCol}}) => {
for (const rule of rules) {
if (rule.openTag && !selfClosing && !(tagName in voidElements)) {
rule.openTag(
{row: startLine - 1, column: startCol - 1},
{name: tagName},
);
}
}
},
);
parser.on(
'endTag',