1 | const { realpathSync } = require("fs");
|
2 | const { sync: readPackage } = require("read-pkg-up");
|
3 |
|
4 | const { packageJson: pkg } = readPackage({ cwd: realpathSync(process.cwd()) });
|
5 | const hasIn = (key, name) => {
|
6 | for (const x in pkg[key] || {}) {
|
7 | if (x === name) return true;
|
8 | }
|
9 | return false;
|
10 | };
|
11 | const keys = ["dependencies", "devDependencies", "peerDependencies"];
|
12 | const hasInDeps = name => keys.some(k => hasIn(k, name));
|
13 |
|
14 | module.exports = {
|
15 | extends: [
|
16 | "./",
|
17 | hasInDeps("flow-bin") && "./flowtype",
|
18 | hasInDeps("react") && "./react",
|
19 | ].filter(Boolean),
|
20 | overrides: [
|
21 | hasInDeps("jest") && {
|
22 | files: [
|
23 | "*.{test,spec}.{js,ts,jsx,tsx}",
|
24 | "**/__tests__/**/*.{js,ts,jsx,tsx}",
|
25 | ],
|
26 | extends: "./jest",
|
27 | },
|
28 | hasInDeps("typescript") && {
|
29 | files: ["*.{ts,tsx}"],
|
30 | extends: "./typescript-without-type",
|
31 | },
|
32 | ].filter(Boolean),
|
33 | };
|