Repository navigation
Expand file tree
/
Copy pathknip.ts
More file actions
156 lines (155 loc) · 6.91 KB
/
Copy pathknip.ts
File metadata and controls
156 lines (155 loc) · 6.91 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import type {KnipConfig} from 'knip'
const config = {
workspaces: {
'.': {},
'bench-site': {
// app.ts is the browser entry, bundled by esbuild via build.ts (knip
// can't see esbuild entrypoints on its own)
entry: ['src/app.ts'],
project: ['src/**/*.ts'],
ignoreDependencies: ['wrangler'],
},
docs: {
ignoreDependencies: ['mikro', 'wrangler'],
},
'packages/@mikrojs/firmware': {
// esbuild is consumed by CMake only (the runtime bundle); knip sees the
// others through src/cli.ts and the tests.
ignoreDependencies: ['esbuild'],
// The ota_host .build/ tree is scratch the gunzip host test generates
// (gitignored); knip still walks it once the test has run, so the ignore
// is only redundant on a clean checkout.
ignore: ['components/mikrojs/test/ota_host/.build/**'],
},
'examples/sleep': {
// Each app/*.ts file is a stand-alone entry — users pick one with
// `mikro dev app/<name>.ts`. Without this, only `main` from
// package.json counts as an entry and the rest get flagged as
// "unused".
entry: ['app/*.ts'],
},
'dev/module-costs': {
// Every test/*.test.ts is a `mikro test` entry (one per builtin, run on
// the device or simulator), not imported by anything.
entry: ['test/*.test.ts'],
},
'dev/npm-packages': {
// test/*.test.ts is a `mikro test` entry. Both language files are entries
// too: they are picked with import(), which knip does not follow.
entry: ['test/*.test.ts', 'app/lang/*.ts'],
},
'dev/npm-packages-uptime': {
// formats/*.ts is reached through the wildcard export, not an import path.
entry: ['formats/*.ts'],
},
'dev/watchdog': {
// One entry per watchdog, picked with `pnpm dev:<name>`; same shape as
// examples/sleep.
entry: ['app/*.ts'],
},
'packages/mikro': {
// boards.config.ts: `mikro fw build` loads the generic boards' config.
entry: ['src/cli/cli.ts', 'src/_exports/*.ts', 'boards.config.ts'],
project: ['src/**/*.{ts,tsx}'],
// @mikrojs/quickjs: native addon resolved at runtime
// terser, @swc/core: optional minifiers loaded dynamically via importOptional()
ignoreDependencies: ['@mikrojs/quickjs', 'terser', '@swc/core', 'tsx'],
},
'packages/@mikrojs/analyze-imports': {
ignore: ['test/unit/**', 'test/symlink/**', 'dist/**'],
},
'packages/create-mikro': {
// eslint, prettier, typescript-eslint, @mikrojs/eslint-plugin are
// invoked by scaffold.test.ts via node_modules/.bin paths (to lint
// and format-check scaffolded projects), not via JS imports — knip
// can't see them.
ignoreDependencies: ['@mikrojs/eslint-plugin', 'eslint', 'prettier', 'typescript-eslint'],
},
'packages/@repo/releaser': {
// bin/releaser.js is auto-detected from package.json bin. The .ts is
// invoked via tsx from the shim and dispatches to all command modules.
entry: ['bin/releaser.ts'],
project: ['src/**/*.ts', 'bin/**/*.ts'],
},
scripts: {
// trust-setup.ts is invoked from the root `trust:setup` script via
// shebang; knip can't see the entry through the package.json reference.
entry: ['trust-setup.ts'],
},
esp32: {
// @mikrojs/firmware is consumed by CMakeLists.txt (project.cmake,
// component discovery), which knip can't see — no JS imports.
ignoreDependencies: ['@mikrojs/firmware'],
},
'examples/drivers/chip-temperature': {
// The peer dependency, declared locally as the package-json lint rule asks.
// The C++ uses it through the firmware build, not a JS import.
ignoreDependencies: ['@mikrojs/firmware'],
},
'packages/@mikrojs/native': {
// bundle-runtime.js + generate-symbol-map.js are invoked by CMake during
// the firmware build (see @mikrojs/firmware/components/mikrojs/CMakeLists.txt
// for the symbol-map invocation), not via JS imports — so knip can't
// see them and we declare them as entries explicitly. gen-checkin-fixtures.js
// is the same: CMakeLists.txt runs it for the host test build, and so is
// gen-schema-fixtures.js. modules-list.js is run by both CMake builds at
// configure time to derive the builtin module lists from runtime/modules.json.
entry: [
'scripts/bundle-runtime.js',
'scripts/generate-symbol-map.js',
'scripts/gen-checkin-fixtures.js',
'scripts/gen-schema-fixtures.js',
'scripts/modules-list.js',
],
ignore: ['runtime/**'],
// node-addon-api, @mikrojs/quickjs: resolved by CMake/node-gyp, not by JS imports
// terser, @swc/core: optional minifiers loaded dynamically in bundle-runtime.js
// @mikrojs/schema is imported only by runtime/schema/__test__, which the
// `ignore` above hides from knip.
ignoreDependencies: [
'node-addon-api',
'@mikrojs/quickjs',
'terser',
'@swc/core',
'@mikrojs/schema',
],
},
'packages/@mikrojs/schema': {
// schema.test-d.ts is a vitest typecheck suite, run via typecheck.include
// in this package's vitest config rather than imported by anything, so
// knip sees no consumer.
ignore: ['src/**/*.test-d.ts'],
},
},
ignore: [
'taze.config.ts',
'packages/@mikrojs/quickjs/deps/**',
// Types for plain JS exports: TypeScript reads each next to the .js file
// the export names, so nothing imports them by name
'packages/@mikrojs/native/cmake.d.ts',
'packages/@mikrojs/quickjs/index.d.ts',
// todo: ideally we should run knip here too, but not sure how
'packages/create-mikro/src/templates/**',
// mikro.config.ts is discovered at runtime by the CLI, not imported
'**/mikro.config.ts',
// config schemas are value-imported only by mikro.config.ts (ignored
// above) and type-imported by app code, so knip sees no consumer
'examples/*/app/ota.config.ts',
// sim stubs are loaded dynamically by mikro sim dev, not imported
'**/*.stub.ts',
],
ignoreDependencies: ['unbarrelify', 'taze'],
// zizmor and gcovr are installed system-wide (brew/uv/pipx), not via npm.
// xdg-open is OS-provided, used by coverage:lib:open. strip and cc are
// toolchain binaries shelled out to from backfill.ts and quickjs postinstall.
// idf.py and eim come with ESP-IDF and EIM; `mikro idf` runs them.
ignoreBinaries: ['cmake', 'ctest', 'zizmor', 'gcovr', 'xdg-open', 'strip', 'cc', 'idf.py', 'eim'],
// backfill.ts runs the memory_bench binary it just built by path; knip reports
// the path prefix as an unresolved import.
ignoreUnresolved: ['packages/'],
// Knip can't trace `import * as` namespace member access or type-only re-exports
// through barrel files. All remaining "unused" exports/types have been manually
// verified as used.
exclude: ['exports', 'types'],
} satisfies KnipConfig
export default config