Files
react-native-devtools-frontend/node_modules/stylelint/lib/createStylelintResult.js
T
Tim van der Lippe 4cb097430f Update Stylelint and Postcss
R=jacktfranklin@chromium.org

Bug: none
Change-Id: I961be18530d3ccbc4efed0c2cda9bd603b14e27b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3372931
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
2022-01-07 14:36:30 +00:00

42 lines
1.2 KiB
JavaScript

'use strict';
const createPartialStylelintResult = require('./createPartialStylelintResult');
/** @typedef {import('stylelint').PostcssResult} PostcssResult */
/** @typedef {import('stylelint').LintResult} StylelintResult */
/**
* @param {import('stylelint').InternalApi} stylelint
* @param {PostcssResult} [postcssResult]
* @param {string} [filePath]
* @param {import('stylelint').CssSyntaxError} [cssSyntaxError]
* @return {Promise<StylelintResult>}
*/
module.exports = async function createStylelintResult(
stylelint,
postcssResult,
filePath,
cssSyntaxError,
) {
let stylelintResult = createPartialStylelintResult(postcssResult, cssSyntaxError);
const configForFile = await stylelint.getConfigForFile(filePath, filePath);
const config = configForFile === null ? {} : configForFile.config;
const file = stylelintResult.source || (cssSyntaxError && cssSyntaxError.file);
if (config.resultProcessors) {
for (const resultProcessor of config.resultProcessors) {
// Result processors might just mutate the result object,
// or might return a new one
const returned = resultProcessor(stylelintResult, file);
if (returned) {
stylelintResult = returned;
}
}
}
return stylelintResult;
};