1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | module.exports = function (results, config = {}) {
|
13 |
|
14 | const report = [];
|
15 | const usedRules = new Set(Object.keys(config.rules || {}));
|
16 |
|
17 | usedRules.add('all');
|
18 |
|
19 | results.forEach((result) => {
|
20 |
|
21 | if (!result._postcssResult) {
|
22 | return;
|
23 | }
|
24 |
|
25 |
|
26 | const sourceReport = { source: result.source, ranges: [] };
|
27 | const rangeData = result._postcssResult.stylelint.disabledRanges;
|
28 | const disabledRules = Object.keys(rangeData);
|
29 |
|
30 | disabledRules.forEach((rule) => {
|
31 | if (usedRules.has(rule)) {
|
32 | return;
|
33 | }
|
34 |
|
35 | rangeData[rule].forEach((range) => {
|
36 | if (!range.strictStart && !range.strictEnd) {
|
37 | return;
|
38 | }
|
39 |
|
40 | sourceReport.ranges.push({
|
41 | unusedRule: rule,
|
42 | start: range.start,
|
43 | end: range.end,
|
44 | });
|
45 | });
|
46 | });
|
47 |
|
48 | if (sourceReport.ranges.length > 0) {
|
49 | report.push(sourceReport);
|
50 | }
|
51 | });
|
52 |
|
53 | return report;
|
54 | };
|