1 | ;
|
2 |
|
3 | var COMPLEX_SELECTOR_THRESHOLD = 3;
|
4 |
|
5 | /**
|
6 | * @param { import("../lib/css-analyzer") } analyzer
|
7 | */
|
8 | function rule(analyzer) {
|
9 | analyzer.setMetric("complexSelectors");
|
10 |
|
11 | // #foo .bar ul li a
|
12 | analyzer.on("selector", function (rule, selector, expressions) {
|
13 | if (expressions.length > COMPLEX_SELECTOR_THRESHOLD) {
|
14 | analyzer.incrMetric("complexSelectors");
|
15 | analyzer.addOffender("complexSelectors", selector);
|
16 | }
|
17 | });
|
18 | }
|
19 |
|
20 | rule.description = "Reports too complex CSS selectors";
|
21 | module.exports = rule;
|