1 | 'use strict';
|
2 |
|
3 | const augmentConfig = require('./augmentConfig');
|
4 | const createStylelintResult = require('./createStylelintResult');
|
5 | const getConfigForFile = require('./getConfigForFile');
|
6 | const getPostcssResult = require('./getPostcssResult');
|
7 | const isPathIgnored = require('./isPathIgnored');
|
8 | const lintSource = require('./lintSource');
|
9 | const { cosmiconfig } = require('cosmiconfig');
|
10 |
|
11 | const IS_TEST = process.env.NODE_ENV === 'test';
|
12 | const STOP_DIR = IS_TEST ? process.cwd() : undefined;
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function createStylelint(options = {}) {
|
25 | const cwd = options.cwd || process.cwd();
|
26 |
|
27 |
|
28 |
|
29 | const stylelint = { _options: { ...options, cwd } };
|
30 |
|
31 | stylelint._extendExplorer = cosmiconfig('', {
|
32 | transform: augmentConfig.augmentConfigExtended(cwd),
|
33 | stopDir: STOP_DIR,
|
34 | });
|
35 |
|
36 | stylelint._specifiedConfigCache = new Map();
|
37 | stylelint._postcssResultCache = new Map();
|
38 | stylelint._createStylelintResult = createStylelintResult.bind(null, stylelint);
|
39 | stylelint._getPostcssResult = getPostcssResult.bind(null, stylelint);
|
40 | stylelint._lintSource = lintSource.bind(null, stylelint);
|
41 |
|
42 | stylelint.getConfigForFile = getConfigForFile.bind(null, stylelint);
|
43 | stylelint.isPathIgnored = isPathIgnored.bind(null, stylelint);
|
44 |
|
45 | return stylelint;
|
46 | }
|
47 |
|
48 | module.exports = (createStylelint);
|