1 |
|
2 |
|
3 | "use strict";
|
4 |
|
5 | const chalk = require("chalk");
|
6 | const path = require("path");
|
7 |
|
8 | function logFrom(fromValue /*: string */) /*: string */ {
|
9 | if (fromValue.charAt(0) === "<") return fromValue;
|
10 |
|
11 | return path
|
12 | .relative(process.cwd(), fromValue)
|
13 | .split(path.sep)
|
14 | .join("/");
|
15 | }
|
16 |
|
17 | module.exports = function(
|
18 | report /*:: ?: stylelint$needlessDisablesReport */
|
19 | ) /*: string */ {
|
20 | if (!report) return "";
|
21 |
|
22 | let output = "";
|
23 |
|
24 | report.forEach(sourceReport => {
|
25 | if (!sourceReport.ranges || sourceReport.ranges.length === 0) {
|
26 | return;
|
27 | }
|
28 |
|
29 | output += "\n";
|
30 | output += chalk.underline(logFrom(sourceReport.source)) + "\n";
|
31 | sourceReport.ranges.forEach(range => {
|
32 | output += `unused rule: ${range.unusedRule}, start line: ${range.start}`;
|
33 |
|
34 | if (range.end !== undefined) {
|
35 | output += `, end line: ${range.end}`;
|
36 | }
|
37 |
|
38 | output += "\n";
|
39 | });
|
40 | });
|
41 |
|
42 | return output;
|
43 | };
|