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

Version Path
trusty-cms-5.0.7 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-5.0.6 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-5.0.5 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-5.0.4 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-5.0.3 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-5.0.2 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-5.0.1 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.3.5 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-5.0.0 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.3.4 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.3.3 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.3.2 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.3.1 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.3 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.2.3 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.2.2 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.2.1 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.2 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.1.9 node_modules/stylelint/lib/invalidScopeDisables.js
trusty-cms-4.1.8 node_modules/stylelint/lib/invalidScopeDisables.js