Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ast.walkRules((rule) => {
const selectors = rule.selectors;
for (const selector of selectors) {
const matchingElements = element.ownerDocument.querySelectorAll(selector);
const matchingElementsOutsideParentSVG = matchingElements.filter(isOutsideParentSVG(parentSVG));
if (matchingElementsOutsideParentSVG.length) {
const message = formatRuleMessage(matchingElementsOutsideParentSVG.length);
const location = getCSSLocationFromNode(rule);
const codeSnippet = getCSSCodeSnippet(rule);
context.report(resource, message, {
codeLanguage: 'css',
codeSnippet,
element,
location,
severity: Severity.error
});
let maxReportsPerCSSRule = Infinity;
if (context.hintOptions && context.hintOptions.maxReportsPerCSSRule !== undefined) {
maxReportsPerCSSRule = context.hintOptions.maxReportsPerCSSRule;
}
for (let i = 0; (i < matchingElementsOutsideParentSVG.length && i < maxReportsPerCSSRule); i++) {
const report = ({ feature, formatFeature, isValue, node, unsupported }: ReportData) => {
const alternatives = formatAlternatives(context.language, unsupported, formatFeature);
const message = [
getMessage('featureNotSupported', context.language, [feature, joinBrowsers(unsupported)]),
...alternatives
].join(' ');
const codeSnippet = getCSSCodeSnippet(node);
const location = getCSSLocationFromNode(node, { isValue });
const severity = alternatives.length ? Severity.error : Severity.warning;
context.report(
resource,
message,
{
codeLanguage: 'css',
codeSnippet,
element,
location,
severity
});
};