1 | 'use strict';
|
2 |
|
3 | const createPartialStylelintResult = require('./createPartialStylelintResult');
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | module.exports = async function createStylelintResult(
|
16 | stylelint,
|
17 | postcssResult,
|
18 | filePath,
|
19 | cssSyntaxError,
|
20 | ) {
|
21 | let stylelintResult = createPartialStylelintResult(postcssResult, cssSyntaxError);
|
22 |
|
23 | const configForFile = await stylelint.getConfigForFile(filePath, filePath);
|
24 |
|
25 | const config = configForFile === null ? {} : configForFile.config;
|
26 | const file = stylelintResult.source || (cssSyntaxError && cssSyntaxError.file);
|
27 |
|
28 | if (config.resultProcessors) {
|
29 | for (const resultProcessor of config.resultProcessors) {
|
30 |
|
31 |
|
32 | const returned = resultProcessor(stylelintResult, file);
|
33 |
|
34 | if (returned) {
|
35 | stylelintResult = returned;
|
36 | }
|
37 | }
|
38 | }
|
39 |
|
40 | return stylelintResult;
|
41 | };
|