-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathknip.js
More file actions
144 lines (141 loc) · 4.99 KB
/
Copy pathknip.js
File metadata and controls
144 lines (141 loc) · 4.99 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
// @ts-check
// Patterns suffixed with `!` are the ones used in production mode (`knip --production`), which only
// analyzes the code we ship. Patterns without the suffix are dev-only: Knip automatically negates
// them in production mode. See https://knip.dev/features/production-mode
const srcEntry = 'src/**/*.{js,ts,cts}!';
const dtsEntry = '*.d.ts!';
const testEntry = 'test/**/*.test.{js,ts}';
// `project` defines the files Knip analyzes, so it is where files are excluded from the analysis
// altogether (`ignore` only suppresses issues in files that are still analyzed).
// See https://knip.dev/guides/configuring-project-files
const project = [
'**/*!',
// Fixtures and hosted test apps are standalone projects of their own
'!**/{test,e2e}/**/{fixtures,_temp-fixtures}/**',
'!test/hosted/hosted-astro-project/**',
// Tests are part of the analysis, but never of the production graph
'!test/**!',
'!e2e/**!',
];
/** @type {import('knip').KnipConfig} */
export default {
tags: ['-lintignore'],
ignoreWorkspaces: [
'examples/**',
'**/{test,e2e}/**/{fixtures,_temp-fixtures}/**',
'benchmark/**',
'packages/language-tools/**/*',
// Standalone projects living inside packages
'packages/astro/performance/**',
'**/test/hosted/hosted-astro-project/**',
],
workspaces: {
'.': {
ignoreDependencies: [
'@astrojs/check', // Used by the build script but not as a standard module import
'bgproc', // Used by agents, documented in the AGENTS.md file
],
// In smoke tests, we checkout to the docs repo so those binaries are not present in this project
// vsce and ovsx are only used in CI for publishing, and due to how we have to publish the VS Code extension have
// to be installed in the vscode package, but knip is expecting them to be in the root node_modules
ignoreBinaries: ['docgen', 'docgen:errors', 'playwright', 'vsce', 'ovsx'],
entry: ['.agents/evals/*.ts'],
// The root workspace ships nothing, so none of its files are part of the production graph
project: ['**/*', '!triage/**', '!.github/scripts/**'],
},
// Internal tooling package: it publishes nothing, so all of its commands are entry points
scripts: {
entry: ['*.js!', '{deps,smoke}/*.js!'],
},
'packages/*': {
entry: [srcEntry, dtsEntry, testEntry],
project,
},
'packages/astro': {
entry: [
// Can't be detected automatically since it's only in package.json#files
'templates/**/*!',
srcEntry,
dtsEntry,
testEntry,
'test/types/**/*',
'e2e/**/*.test.{js,ts}',
'test/units/teardown.ts',
// Image services
'test/test-image-service.ts',
'test/test-remote-image-service.ts',
// Can't detect this file when using inside a vite plugin
'src/vite-plugin-app/createAstroServerApp.ts!',
],
project,
ignore: [
// This export is resolved dynamically in packages/astro/src/vite-plugin-app/index.ts
'src/vite-plugin-app/createExports.ts',
],
// Those deps are used in tests but only referenced as strings
ignoreDependencies: [
'rehype-autolink-headings',
'rehype-slug',
'rehype-toc',
'remark-code-titles',
'@types/http-cache-semantics',
// Optional peer dep: dynamically imported in config validation for the legacy
// remark/rehype pipeline. Knip flags it because it's referenced from source.
'@astrojs/markdown-remark',
],
},
'packages/astro-prism': {
entry: [srcEntry, dtsEntry, testEntry],
project,
ignoreUnresolved: ['#prism-loadLanguages'],
},
'packages/integrations/*': {
entry: [srcEntry, dtsEntry, testEntry],
project,
},
'packages/integrations/cloudflare': {
entry: [srcEntry, dtsEntry, testEntry],
project,
// False positive because of cloudflare:workers
ignoreDependencies: ['cloudflare'],
},
'packages/integrations/netlify': {
entry: [srcEntry, dtsEntry, testEntry],
project,
// Runtime dependency of the Netlify Blobs session driver, which the adapter enables but
// never imports by name
ignoreDependencies: ['@netlify/blobs'],
},
'packages/integrations/solid': {
entry: [srcEntry, dtsEntry, testEntry],
project,
// It's an optional peer dep (triggers a warning) but it's fine in this case
ignoreDependencies: ['solid-devtools'],
},
'packages/integrations/svelte': {
entry: [srcEntry, dtsEntry, testEntry],
project,
// Used in testing-library compatibility tests but not directly imported
ignoreDependencies: ['@testing-library/svelte'],
},
'packages/integrations/mdx': {
entry: [srcEntry, dtsEntry, testEntry],
project,
// Optional peer dep: type-only imports for narrowing the `satteri()` processor.
// Knip flags it because the peer is referenced from source; the runtime stays gated by name-check.
ignoreDependencies: ['@astrojs/markdown-satteri'],
},
'packages/markdown/remark': {
entry: [srcEntry, dtsEntry, testEntry],
project,
},
'packages/markdown/satteri': {
entry: [srcEntry, dtsEntry, testEntry],
project,
},
'packages/upgrade': {
entry: ['src/index.ts!', testEntry],
project,
},
},
};