epiphany/node_modules/stylelint/lib/normalizeAllRuleSettings.js
2023-12-09 22:48:07 -08:00

33 lines
797 B
JavaScript

'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;