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");
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 };
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", {
26 transform: _.partial(augmentConfig.augmentConfigFull, stylelint)
28 stylelint._extendExplorer = cosmiconfig(null, {
30 transform: _.partial(augmentConfig.augmentConfigExtended, stylelint)
33 stylelint._specifiedConfigCache = new Map();
34 stylelint._postcssResultCache = new Map();
35 stylelint._createStylelintResult = _.partial(
36 createStylelintResult,
39 stylelint._getPostcssResult = _.partial(getPostcssResult, stylelint);
40 stylelint._lintSource = _.partial(lintSource, stylelint);
42 stylelint.getConfigForFile = _.partial(getConfigForFile, stylelint);
43 stylelint.isPathIgnored = _.partial(isPathIgnored, stylelint);