3 /*:: type postcssType = {
15 const _ = require("lodash");
16 const createStylelint = require("./createStylelint");
17 const path = require("path");
18 const postcss /*: postcssType*/ = require("postcss");
19 //'block-no-empty': bool || Array
20 /*:: type OptionsT = {
22 extends?: Array<string>,
23 plugins?: Array<string>,
26 configBasedir?: string;
28 defaultSeverity?: string;
30 ignoreDisables?: boolean;
32 pluginFunctions?: Object;
33 plugins?: Array<string>;
38 /*:: type rootParamT = {
58 /*:: type resultParamT = {
61 plugins: Array<Object>,
81 defaultSeverity?: string,
83 ignoreDisables?: boolean,
94 postcssPlugin: string,
95 postcssVersion: string,
99 /*:: type postcssPromise = Promise<?{ config: stylelint$config, filepath: string }>*/
101 module.exports = postcss.plugin("stylelint", function(
102 options /*: OptionsT*/
104 options = options || {};
106 const tailoredOptions /*: Object*/ = options.rules
107 ? { config: options }
109 const stylelint /*: stylelint$internalApi*/ = createStylelint(
114 return (root/*: rootParamT*/, result/*: resultParamT*/)/*: Promise<any>*/ => {
115 let filePath = options.from || _.get(root, "source.input.file");
116 if (filePath !== undefined && !path.isAbsolute(filePath)) {
117 filePath = path.join(process.cwd(), filePath);
120 return stylelint._lintSource({
122 existingPostcssResult: result