UNPKG

891 BJavaScriptView Raw
1const { realpathSync } = require("fs");
2const { sync: readPackage } = require("read-pkg-up");
3
4const { packageJson: pkg } = readPackage({ cwd: realpathSync(process.cwd()) });
5const hasIn = (key, name) => {
6 for (const x in pkg[key] || {}) {
7 if (x === name) return true;
8 }
9 return false;
10};
11const keys = ["dependencies", "devDependencies", "peerDependencies"];
12const hasInDeps = name => keys.some(k => hasIn(k, name));
13
14module.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};