You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
57 lines
1.1 KiB
// @ts-nocheck |
|
|
|
'use strict'; |
|
|
|
const isStandardSyntaxDeclaration = require('../utils/isStandardSyntaxDeclaration'); |
|
const isStandardSyntaxProperty = require('../utils/isStandardSyntaxProperty'); |
|
const report = require('../utils/report'); |
|
const styleSearch = require('style-search'); |
|
|
|
module.exports = function (opts) { |
|
opts.root.walkDecls((decl) => { |
|
if (!isStandardSyntaxDeclaration(decl) || !isStandardSyntaxProperty(decl.prop)) { |
|
return; |
|
} |
|
|
|
const declString = decl.toString(); |
|
|
|
styleSearch( |
|
{ |
|
source: declString, |
|
target: ',', |
|
functionArguments: 'skip', |
|
}, |
|
(match) => { |
|
const indexToCheckAfter = opts.determineIndex |
|
? opts.determineIndex(declString, match) |
|
: match.startIndex; |
|
|
|
if (indexToCheckAfter === false) { |
|
return; |
|
} |
|
|
|
checkComma(declString, indexToCheckAfter, decl); |
|
}, |
|
); |
|
}); |
|
|
|
function checkComma(source, index, node) { |
|
opts.locationChecker({ |
|
source, |
|
index, |
|
err: (m) => { |
|
if (opts.fix && opts.fix(node, index)) { |
|
return; |
|
} |
|
|
|
report({ |
|
message: m, |
|
node, |
|
index, |
|
result: opts.result, |
|
ruleName: opts.checkedRuleName, |
|
}); |
|
}, |
|
}); |
|
} |
|
};
|
|
|