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.
34 lines
797 B
34 lines
797 B
|
2 years ago
|
'use strict';
|
||
|
|
|
||
|
|
const normalizeRuleSettings = require('./normalizeRuleSettings');
|
||
|
|
const getStylelintRule = require('./utils/getStylelintRule');
|
||
|
|
|
||
|
|
/** @typedef {import('stylelint').Config} StylelintConfig */
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param {StylelintConfig} config
|
||
|
|
* @return {StylelintConfig}
|
||
|
|
*/
|
||
|
|
function normalizeAllRuleSettings(config) {
|
||
|
|
if (!config.rules) return config;
|
||
|
|
|
||
|
|
/** @type {StylelintConfig['rules']} */
|
||
|
|
const normalizedRules = {};
|
||
|
|
|
||
|
|
for (const [ruleName, rawRuleSettings] of Object.entries(config.rules)) {
|
||
|
|
const rule = getStylelintRule(ruleName, config);
|
||
|
|
|
||
|
|
if (rule) {
|
||
|
|
normalizedRules[ruleName] = normalizeRuleSettings(rawRuleSettings, rule);
|
||
|
|
} else {
|
||
|
|
normalizedRules[ruleName] = [];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
config.rules = normalizedRules;
|
||
|
|
|
||
|
|
return config;
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = normalizeAllRuleSettings;
|