Sha256: 79f32eeb9418c48bc3585488d528d3f988ea30ccec28e79fdd071c2187090da9
Contents?: true
Size: 1.38 KB
Versions: 23
Compression:
Stored size: 1.38 KB
Contents
'use strict'; /** @typedef {import('stylelint').RangeType} RangeType */ /** @typedef {import('stylelint').UnusedRange} UnusedRange */ /** @typedef {import('stylelint').StylelintDisableOptionsReport} StylelintDisableOptionsReport */ /** * @param {import('stylelint').StylelintResult[]} results * @param {import('stylelint').StylelintConfig|undefined} config * @returns {StylelintDisableOptionsReport} */ module.exports = function (results, config = {}) { /** @type {StylelintDisableOptionsReport} */ const report = []; const usedRules = new Set(Object.keys(config.rules || {})); usedRules.add('all'); results.forEach((result) => { // File with `CssSyntaxError` have not `_postcssResult` if (!result._postcssResult) { return; } /** @type {import('stylelint').StylelintDisableReportEntry} */ const sourceReport = { source: result.source, ranges: [] }; const rangeData = result._postcssResult.stylelint.disabledRanges; const disabledRules = Object.keys(rangeData); disabledRules.forEach((rule) => { if (usedRules.has(rule)) { return; } rangeData[rule].forEach((range) => { if (!range.strictStart && !range.strictEnd) { return; } sourceReport.ranges.push({ unusedRule: rule, start: range.start, end: range.end, }); }); }); if (sourceReport.ranges.length > 0) { report.push(sourceReport); } }); return report; };
Version data entries
23 entries across 23 versions & 1 rubygems