1 | "use strict";
|
2 |
|
3 | const path = require(`path`);
|
4 |
|
5 | const glob = require(`glob`);
|
6 |
|
7 | const debug = require(`debug`)(`gatsby:webpack-eslint-config`);
|
8 |
|
9 | const report = require(`gatsby-cli/lib/reporter`);
|
10 |
|
11 | module.exports = directory => {
|
12 | try {
|
13 | debug(`Attempting to load package.json for eslint config check`);
|
14 |
|
15 | const pkg = require(path.resolve(directory, `package.json`));
|
16 |
|
17 | if (pkg.eslintConfig) {
|
18 | return true;
|
19 | }
|
20 | } catch (err) {
|
21 | report.error(`There was a problem processing the package.json file`, err);
|
22 | }
|
23 |
|
24 | debug(`Checking for eslint config file`);
|
25 | const eslintFiles = glob.sync(`.eslintrc?(.js|.json|.yaml|.yml)`, {
|
26 | cwd: directory
|
27 | });
|
28 |
|
29 | if (eslintFiles.length) {
|
30 | return true;
|
31 | }
|
32 |
|
33 | return false;
|
34 | };
|
35 |
|
\ | No newline at end of file |