UNPKG

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