1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | function rule(analyzer) {
|
7 | analyzer.setMetric("multiClassesSelectors");
|
8 |
|
9 | analyzer.on("selector", (_, selector, expressions) => {
|
10 | const expressionsWithClass = expressions.filter(
|
11 | (expr) => expr.name === "class"
|
12 | );
|
13 |
|
14 |
|
15 |
|
16 | if (expressionsWithClass.length > 1) {
|
17 | analyzer.incrMetric("multiClassesSelectors");
|
18 | analyzer.addOffender(
|
19 | "multiClassesSelectors",
|
20 | "." + expressionsWithClass.map((expr) => expr.value).join(".")
|
21 | );
|
22 | }
|
23 | });
|
24 | }
|
25 |
|
26 | rule.description = "Reports selectors with multiple classes";
|
27 | module.exports = rule;
|