-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathknip.ts
More file actions
128 lines (125 loc) · 6 KB
/
knip.ts
File metadata and controls
128 lines (125 loc) · 6 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import type { KnipConfig } from "knip";
const isProductionKnip = process.argv.includes("--production");
const config: KnipConfig = {
rules: {
types: "error",
// Knip can't trace enum member access (e.g. DeclarationKind.Set) as usage
enumMembers: "off",
},
// Types reachable only through tsup-emitted .d.ts surfaces (inferred return
// types of `arraySpec(...)` in spec modules) must be exported for the
// published `@bgforge/binary` typings to compile, but knip's per-workspace
// static analysis can't see them used in source. Mark such exports with a
// `@public` JSDoc tag and knip treats them as used.
tags: ["+public"],
workspaces: {
client: {
entry: [
// esbuild entry points (moved from package.json to scripts/*.sh)
"src/extension.ts",
"src/editors/binaryEditor-webview.ts",
"src/dialog-tree/dialogTree-webview.ts",
// test entry points for @vscode/test-electron
"src/test/runTest.ts",
"src/test/index.ts",
"src/test/*.test.ts",
// vitest unit tests (run via client/vitest.config.ts)
"test/*.test.ts",
],
},
server: {
// Point knip at the TypeScript source entry directly.
// The package.json "main" field targets the built JS output.
// vitest.mutation.config.ts is referenced from stryker.conf.json
// (vitest.configFile); knip's Stryker plugin resolves runner/checker
// package names but not vitest configFile paths, so list it explicitly.
entry: ["src/server.ts", "vitest.mutation.config.ts"],
// Created at runtime by enum-transform.test.ts, may exist during parallel Knip runs
ignore: [
"**/*.d.ts",
// Built JS bundles (knip 6.6+ reports these as unused files otherwise).
// Pattern is only present when build has run; knip hints "Remove from ignore"
// before build, but the ignore is still required after build.
"out/**",
// .ts symlinks created by typecheck-samples.sh, may exist during parallel runs
"test/td/*.ts",
// Bench files invoked explicitly; not reachable from server.ts entry
"test/perf/**",
...(isProductionKnip ? ["src/**", "vitest.integration.config.ts", "test/integration/**"] : []),
],
// esbuild-wasm is required at runtime: the server bundle imports
// transpilers/common/bundle.ts via filesystem path and externalises
// esbuild-wasm in scripts/build-base-server.sh, so the dep must be
// declared directly in server's package.json for strict-pnpm consumers
// to resolve `require("esbuild-wasm")` from server's node_modules at
// runtime. Knip's per-workspace static analysis can't see the import
// chain through the bundled-in non-workspace source.
ignoreDependencies: ["esbuild-wasm"],
},
"plugins/tssl-plugin": {
entry: ["src/index.ts", "test/*.test.ts"],
},
"plugins/td-plugin": {
entry: ["src/index.ts", "test/*.test.ts"],
},
"transpilers/tssl": {
entry: ["src/index.ts"],
},
"transpilers/tbaf": {
entry: ["src/index.ts"],
},
"transpilers/td": {
entry: ["src/index.ts"],
},
"transpilers/common": {
entry: [],
},
transpilers: {
entry: ["test/**/*.test.ts"],
// esbuild-wasm is listed as a runtime dependency so the published bundle can
// resolve it from node_modules (it refuses to be inlined - see tsup.config.ts).
// Knip sees no TS import within this workspace because the import lives in
// transpilers/common (a separate workspace); ignoreDependencies suppresses the
// false-positive "unused dependency" report.
// cac and diff are imported via shared/cli/cli-utils.ts, which is not part of
// any workspace; knip's per-workspace dep tracing doesn't reach across that
// non-workspace boundary, so suppress the false positive.
ignoreDependencies: ["esbuild-wasm", "cac", "diff"],
},
format: {
entry: ["test/**/*.test.ts"],
// quick-lru is reached transitively: format/src/cli.ts imports from
// ../../shared/parsers/*, and shared/parsers/parser-factory.ts imports
// quick-lru. Knip's per-workspace dep tracing can't follow imports
// across the non-workspace shared/ boundary.
// cac and diff are imported via shared/cli/cli-utils.ts, which is outside any
// workspace; knip's per-workspace dep tracing doesn't reach across that boundary.
ignoreDependencies: ["quick-lru", "cac", "diff"],
},
binary: {
entry: ["test/**/*.test.ts"],
// cac and diff are imported via shared/cli/cli-utils.ts, which lives outside any
// workspace; knip's per-workspace dep tracing doesn't reach across that boundary.
ignoreDependencies: ["cac", "diff"],
},
},
ignore: [
// tree-sitter grammars, not TypeScript
"grammars/**",
// external repositories cloned for testing
"external/**",
// standalone update scripts run via pnpm exec tsx, not imported by main code
"scripts/**",
],
ignoreDependencies: [
// icon font used via CSS classes in dialogTree.ts (e.g. "codicon codicon-references")
"@vscode/codicons",
// invoked via pnpm exec in scripts
"oxfmt",
// invoked via pnpm vsce in scripts/package.sh
"@vscode/vsce",
// loaded by remark CLI via --use in package.json scripts, not statically imported
"remark-validate-links",
],
};
export default config;