1 |
|
2 |
|
3 | 'use strict';
|
4 |
|
5 | const atRuleParamIndex = require('../utils/atRuleParamIndex');
|
6 | const report = require('../utils/report');
|
7 | const styleSearch = require('style-search');
|
8 |
|
9 | module.exports = function (opts) {
|
10 | opts.root.walkAtRules(/^media$/i, (atRule) => {
|
11 | const params = atRule.raws.params ? atRule.raws.params.raw : atRule.params;
|
12 |
|
13 | styleSearch({ source: params, target: ':' }, (match) => {
|
14 | checkColon(params, match.startIndex, atRule);
|
15 | });
|
16 | });
|
17 |
|
18 | function checkColon(source, index, node) {
|
19 | opts.locationChecker({
|
20 | source,
|
21 | index,
|
22 | err: (m) => {
|
23 | const colonIndex = index + atRuleParamIndex(node);
|
24 |
|
25 | if (opts.fix && opts.fix(node, colonIndex)) {
|
26 | return;
|
27 | }
|
28 |
|
29 | report({
|
30 | message: m,
|
31 | node,
|
32 | index: colonIndex,
|
33 | result: opts.result,
|
34 | ruleName: opts.checkedRuleName,
|
35 | });
|
36 | },
|
37 | });
|
38 | }
|
39 | };
|