.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / createStylelint.js
1 /* @flow */
2 "use strict";
3 const _ = require("lodash");
4 const augmentConfig = require("./augmentConfig");
5 const cosmiconfig = require("cosmiconfig");
6 const createStylelintResult = require("./createStylelintResult");
7 const getConfigForFile = require("./getConfigForFile");
8 const getPostcssResult = require("./getPostcssResult");
9 const isPathIgnored = require("./isPathIgnored");
10 const lintSource = require("./lintSource");
11
12 // The stylelint "internal API" is passed among functions
13 // so that methods on a stylelint instance can invoke
14 // each other while sharing options and caches
15 module.exports = function(
16   options /*: stylelint$options*/
17 ) /*: stylelint$internalApi*/ {
18   options = options || {};
19   const stylelint /*: Object*/ = { _options: options };
20
21   // Two separate explorers so they can each have their own transform
22   // function whose results are cached by cosmiconfig
23   stylelint._fullExplorer = cosmiconfig("stylelint", {
24     argv: false,
25     rcExtensions: true,
26     transform: _.partial(augmentConfig.augmentConfigFull, stylelint)
27   });
28   stylelint._extendExplorer = cosmiconfig(null, {
29     argv: false,
30     transform: _.partial(augmentConfig.augmentConfigExtended, stylelint)
31   });
32
33   stylelint._specifiedConfigCache = new Map();
34   stylelint._postcssResultCache = new Map();
35   stylelint._createStylelintResult = _.partial(
36     createStylelintResult,
37     stylelint
38   );
39   stylelint._getPostcssResult = _.partial(getPostcssResult, stylelint);
40   stylelint._lintSource = _.partial(lintSource, stylelint);
41
42   stylelint.getConfigForFile = _.partial(getConfigForFile, stylelint);
43   stylelint.isPathIgnored = _.partial(isPathIgnored, stylelint);
44
45   return stylelint;
46 };