stylelint
Version:
Modern CSS linter
36 lines (28 loc) • 1.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (rawSettings, ruleName) {
// Settings can be
// a. A solitary primitive value or object, in which case put it in an array
// b. An array with a primary option and a secondary options object, in which case use that array
// c. A solitary array ... in which case we have trouble and need to special-case it
// ... hence the list above
if (!Array.isArray(rawSettings)) {
return [rawSettings];
}
// Everything below is an array ...
if (!rulesWithPrimaryOptionArray.has(ruleName)) {
return rawSettings;
}
// Everything below is a rule that CAN have an array for a primary option ...
// (they might also have something else, e.g. rule-properties-order can
// have the string "alphabetical")
if (rawSettings.length === 2 && !(0, _lodash.isPlainObject)(rawSettings[0]) && (0, _lodash.isPlainObject)(rawSettings[1])) {
return rawSettings;
}
return [rawSettings];
};
var _lodash = require("lodash");
// These are rules that accept an array as the primary option
var rulesWithPrimaryOptionArray = new Set(["declaration-block-properties-order", "function-blacklist", "function-whitelist", "property-blacklist", "property-unit-blacklist", "property-unit-whitelist", "property-whitelist", "unit-blacklist", "unit-whitelist"]);