-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathknip.config.js
More file actions
88 lines (81 loc) · 2.34 KB
/
knip.config.js
File metadata and controls
88 lines (81 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// @ts-check
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { entryPoints } from "./config/entryPoints.js";
const packageJSON = JSON.parse(readFileSync("package.json", "utf-8"));
const packageEntries = entryPoints.map(({ dirs }) =>
join("src", ...dirs, "index.ts")
);
const scriptEntries = Array.from(
Object.values(packageJSON.scripts)
.join("\n")
.matchAll(/(config\/.*?\.[jt]s)/g)
)
.map((match) => match[1])
.filter((value, index, arr) => index === arr.indexOf(value));
/** @type{import('knip').KnipConfig}*/
const config = {
exclude: ["optionalPeerDependencies", "unresolved"],
entry: /**@type {string[]}*/ ([])
.concat(packageEntries)
.concat(scriptEntries)
.concat([
"src/cache/inmemory/fixPolyfills.native.ts",
"src/react/types/types.documentation.ts",
"eslint-local-rules/index.mjs",
"codegen/local-state/index.ts",
"codegen/local-state/config.ts",
"codegen/local-state/plugin.ts",
"codegen/local-state/visitor.ts",
"scripts/codemods/ac3-to-ac4/src/util/getAllExports.ts",
]),
project: [
"src/**/*.ts{,x}",
"config/*.{,c}[jt]s",
"eslint-local-rules/*.[jt]s",
],
ignore: [
"integration-tests/**/*",
".yalc/**/*",
"config/schema.package.json.ts",
"src/config/jest/resolver.ts",
"config/listImports.ts",
"scripts/codemods/**/__testfixtures__/**/*",
// Exports `KeyOptions` used in `matchers/index.d.ts`, but can't pick it up
"src/testing/matchers/toHaveFragmentWatchesOn.ts",
],
ignoreBinaries: ["jq"],
ignoreDependencies: [
/@actions\/.*/,
/@size-limit\/.*/,
"size-limit-apollo-plugin",
/eslint-.*/,
// used by `recast`
"@babel/parser",
// called in a script, but with `xargs`
"tsx",
// TS types referenced by "rollup-plugin-terser"
"terser",
// used as a reporter by the `test:coverage` script
"jest-junit",
"@mdx-js/language-service",
],
jest: {
config: "config/jest.config.js",
entry: [
"src/config/jest/setup.ts",
"src/testing/matchers/index.d.ts",
"**/__tests__/**/*.[jt]s?(x)",
"**/*.test.[jt]s?(x)",
"src/**/__benches__/*.bench.ts",
],
},
typescript: {
config: [
"tsconfig.json",
"eslint-local-rules/tsconfig.json",
"config/tsconfig.json",
],
},
};
export default config;