normalizeAllRuleSettings.cjs 969 B

1234567891011121314151617181920212223242526272829303132333435
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const getStylelintRule = require('./utils/getStylelintRule.cjs');
  5. const normalizeRuleSettings = require('./normalizeRuleSettings.cjs');
  6. /** @import {Config as StylelintConfig} from 'stylelint' */
  7. /**
  8. * @param {StylelintConfig} config
  9. * @returns {Promise<StylelintConfig>}
  10. */
  11. async function normalizeAllRuleSettings(config) {
  12. if (!config.rules) return config;
  13. /** @type {StylelintConfig['rules']} */
  14. const normalizedRules = {};
  15. for (const [ruleName, rawRuleSettings] of Object.entries(config.rules)) {
  16. const rule = await getStylelintRule(ruleName, config);
  17. if (rule) {
  18. normalizedRules[ruleName] = normalizeRuleSettings(rawRuleSettings, rule);
  19. } else {
  20. normalizedRules[ruleName] = [];
  21. }
  22. }
  23. config.rules = normalizedRules;
  24. return config;
  25. }
  26. module.exports = normalizeAllRuleSettings;