1 | 'use strict';
|
2 |
|
3 | const isStandardSyntaxRule = require('../utils/isStandardSyntaxRule');
|
4 | const report = require('../utils/report');
|
5 | const styleSearch = require('style-search');
|
6 |
|
7 | module.exports = function (opts) {
|
8 | opts.root.walkRules((rule) => {
|
9 | if (!isStandardSyntaxRule(rule)) {
|
10 | return;
|
11 | }
|
12 |
|
13 | const selector = rule.raws.selector ? rule.raws.selector.raw : rule.selector;
|
14 |
|
15 | styleSearch(
|
16 | {
|
17 | source: selector,
|
18 | target: ',',
|
19 | functionArguments: 'skip',
|
20 | },
|
21 | (match) => {
|
22 | checkDelimiter(selector, match.startIndex, rule);
|
23 | },
|
24 | );
|
25 | });
|
26 |
|
27 | function checkDelimiter(source, index, node) {
|
28 | opts.locationChecker({
|
29 | source,
|
30 | index,
|
31 | err: (m) => {
|
32 | if (opts.fix && opts.fix(node, index)) {
|
33 | return;
|
34 | }
|
35 |
|
36 | report({
|
37 | message: m,
|
38 | node,
|
39 | index,
|
40 | result: opts.result,
|
41 | ruleName: opts.checkedRuleName,
|
42 | });
|
43 | },
|
44 | });
|
45 | }
|
46 | };
|