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