1 | 'use strict';
|
2 |
|
3 | const descriptionlessDisables = require('./descriptionlessDisables');
|
4 | const invalidScopeDisables = require('./invalidScopeDisables');
|
5 | const needlessDisables = require('./needlessDisables');
|
6 | const reportDisables = require('./reportDisables');
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function prepareReturnValue(stylelintResults, options, formatter) {
|
21 | const {
|
22 | reportNeedlessDisables,
|
23 | reportInvalidScopeDisables,
|
24 | reportDescriptionlessDisables,
|
25 | maxWarnings,
|
26 | } = options;
|
27 |
|
28 | reportDisables(stylelintResults);
|
29 |
|
30 | if (reportNeedlessDisables) needlessDisables(stylelintResults);
|
31 |
|
32 | if (reportInvalidScopeDisables) invalidScopeDisables(stylelintResults);
|
33 |
|
34 | if (reportDescriptionlessDisables) descriptionlessDisables(stylelintResults);
|
35 |
|
36 | const errored = stylelintResults.some(
|
37 | (result) => result.errored || result.parseErrors.length > 0,
|
38 | );
|
39 |
|
40 |
|
41 | const returnValue = {
|
42 | errored,
|
43 | results: [],
|
44 | output: '',
|
45 | reportedDisables: [],
|
46 | };
|
47 |
|
48 | if (maxWarnings !== undefined) {
|
49 | const foundWarnings = stylelintResults.reduce((count, file) => {
|
50 | return count + file.warnings.length;
|
51 | }, 0);
|
52 |
|
53 | if (foundWarnings > maxWarnings) {
|
54 | returnValue.maxWarningsExceeded = { maxWarnings, foundWarnings };
|
55 | }
|
56 | }
|
57 |
|
58 | returnValue.output = formatter(stylelintResults, returnValue);
|
59 | returnValue.results = stylelintResults;
|
60 |
|
61 | return returnValue;
|
62 | }
|
63 |
|
64 | module.exports = prepareReturnValue;
|