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