This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/stylelint/lib/rules/valueListCommaWhitespaceChecker.js
2020-11-01 22:46:04 +00:00

58 lines
1.1 KiB
JavaScript

// @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,
});
},
});
}
};