1 |
|
2 | "use strict";
|
3 |
|
4 | const micromatch = require("micromatch");
|
5 | const path = require("path");
|
6 | const slash = require("slash");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | module.exports = function(
|
12 | stylelint /*: stylelint$internalApi*/,
|
13 | filePathArg /*:: ?: string*/
|
14 | ) /*: Promise<boolean>*/ {
|
15 | const filePath = filePathArg;
|
16 |
|
17 | if (!filePath) {
|
18 | return Promise.resolve(false);
|
19 | }
|
20 |
|
21 | return stylelint.getConfigForFile(filePath).then(result => {
|
22 |
|
23 | const ignoreFiles = (result.config.ignoreFiles || []).map(slash);
|
24 |
|
25 | const absoluteFilePath = path.isAbsolute(filePath)
|
26 | ? filePath
|
27 | : path.resolve(process.cwd(), filePath);
|
28 |
|
29 | if (micromatch(absoluteFilePath, ignoreFiles).length) {
|
30 | return true;
|
31 | }
|
32 |
|
33 | return false;
|
34 | });
|
35 | };
|