UNPKG

scancss

Version:

A robust CSS stylesheet statistics collector and analyzer

37 lines (29 loc) 978 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleRule = handleRule; var _isKeyframeSelector = require('../../predicates/isKeyframeSelector'); var _handleSelector = require('../handleSelector'); function handleRule(rule, report, options) { report.rules.total++; if (rule.nodes.length === 0) { report.rules.empty++; } if (rule.raws.semicolon === false) { report.rules.withoutTrailingSemicolon++; } /** * PostCSS `walkRules` goes throw @keyframes and consider * `to`, `from` and percent values as selectors of the rules */ if (options.selectors && (0, _isKeyframeSelector.isKeyframeSelector)(rule.selector) === false) { if (report.selectors.maxPerRule < rule.selectors.length) { report.selectors.maxPerRule = rule.selectors.length; report.selectors.maxPerRuleList = rule.selectors; } rule.selectors.forEach(selector => { (0, _handleSelector.handleSelector)(selector, report, options); }); } }