-
-
Notifications
You must be signed in to change notification settings - Fork 634
Expand file tree
/
Copy pathknip.ts
More file actions
209 lines (204 loc) · 7.83 KB
/
knip.ts
File metadata and controls
209 lines (204 loc) · 7.83 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import type { KnipConfig } from 'knip';
const config: KnipConfig = {
// ! at the end means files are used in production
workspaces: {
// Root workspace - manages the monorepo and global tooling
'.': {
entry: ['eslint.config.ts', 'jest.config.base.js', 'benchmarks/k6.ts'],
project: ['*.{js,mjs,ts}'],
ignoreBinaries: [
// Has to be installed globally
'yalc',
// Pro package binaries used in Pro workflows
'playwright',
'e2e-test',
// Local binaries
'bin/.*',
],
ignore: ['react_on_rails_pro/**', 'react_on_rails/vendor/**'],
ignoreDependencies: [
// Required for TypeScript compilation, but we don't depend on Turbolinks itself.
'@types/turbolinks',
// The Knip ESLint plugin fails to detect these are transitively required by a config,
// though we don't actually use its rules anywhere.
'@babel/eslint-parser',
'@babel/preset-react',
'eslint-config-shakacode',
'eslint-plugin-jsx-a11y',
'eslint-plugin-react',
'eslint-plugin-react-hooks',
// These are used as transitive dependencies and missing from package.json
'@eslint/eslintrc',
'@eslint/js',
// used by Jest
'jsdom',
'jest-junit',
// This is an optional peer dependency because users without RSC don't need it
// but Knip doesn't like such dependencies to be referenced directly in code
'react-on-rails-rsc',
// SWC transpiler dependencies used by Shakapacker in dummy apps
'@swc/core',
'swc-loader',
// Used via nps (package-scripts.yml) which knip doesn't fully analyze
'nps',
// Used for package validation but not directly imported
'@arethetypeswrong/cli',
'publint',
],
},
// React on Rails core package workspace
'packages/react-on-rails': {
entry: [
'src/ReactOnRails.full.ts!',
'src/ReactOnRails.client.ts!',
'src/base/full.rsc.ts!',
'src/context.ts!',
],
project: ['src/**/*.[jt]s{x,}!', 'tests/**/*.[jt]s{x,}', '!lib/**'],
ignore: [
// Jest setup and test utilities - not detected by Jest plugin in workspace setup
'tests/jest.setup.js',
// Build output directories that should be ignored
'lib/**',
],
ignoreDependencies: [],
},
// React on Rails Pro Node Renderer package workspace
'packages/react-on-rails-pro-node-renderer': {
entry: [
'src/ReactOnRailsProNodeRenderer.ts!',
'src/default-node-renderer.ts!',
'src/integrations/*.ts!',
// Export disableHttp2 for test utilities
'src/worker.ts!',
// License validator: reset() is used in tests, getLicenseStatus/LicenseStatus imported by master.ts
'src/shared/licenseValidator.ts!',
],
project: ['src/**/*.[jt]s{x,}!', 'tests/**/*.[jt]s{x,}', '!lib/**'],
ignore: [
// Build output directories that should be ignored
'lib/**',
// Test fixtures
'tests/fixtures/**',
// Test helper utilities
'tests/helper.ts',
'tests/httpRequestUtils.ts',
],
ignoreDependencies: [
// Optional dependencies used in integrations
'@honeybadger-io/js',
'@sentry/*',
// Jest reporter used in CI
'jest-junit',
],
},
// React on Rails Pro package workspace
'packages/react-on-rails-pro': {
entry: [
'src/ReactOnRails.node.ts!',
'src/ReactOnRails.full.ts!',
'src/ReactOnRails.client.ts!',
'src/ReactOnRailsRSC.ts!',
'src/registerServerComponent/client.tsx!',
'src/registerServerComponent/server.tsx!',
'src/registerServerComponent/server.rsc.ts!',
'src/wrapServerComponentRenderer/server.tsx!',
'src/wrapServerComponentRenderer/server.rsc.tsx!',
'src/RSCRoute.tsx!',
'src/ServerComponentFetchError.ts!',
'src/getReactServerComponent.server.ts!',
'src/transformRSCNodeStream.ts!',
'src/tanstack-router.ts!',
],
project: ['src/**/*.[jt]s{x,}!', 'tests/**/*.[jt]s{x,}', '!lib/**'],
ignore: [
'tests/emptyForTesting.js',
// Jest setup and test utilities - not detected by Jest plugin in workspace setup
'tests/jest.setup.js',
'tests/utils/removeRSCStackFromAllChunks.ts',
// Build output directories that should be ignored
'lib/**',
// Pro features exported for external consumption
'src/streamServerRenderedReactComponent.ts:transformRenderStreamChunksToResultObject',
'src/streamServerRenderedReactComponent.ts:streamServerRenderedComponent',
'src/ServerComponentFetchError.ts:isServerComponentFetchError',
'src/RSCRoute.tsx:RSCRouteProps',
'src/streamServerRenderedReactComponent.ts:StreamingTrackers',
],
},
'react_on_rails/spec/dummy': {
entry: [
'app/assets/config/manifest.js!',
'client/app/packs/**/*.js!',
// Not sure why this isn't detected as a dependency of client/app/packs/server-bundle.js
'client/app/generated/server-bundle-generated.js!',
'config/webpack/{production,development,test}.js',
// Declaring this as webpack.config instead doesn't work correctly
'config/webpack/webpack.config.js',
// SWC configuration for Shakapacker
'config/swc.config.js',
// Playwright E2E test configuration and tests
'e2e/playwright.config.js',
'e2e/playwright/e2e/**/*.spec.js',
// CI workflow files that reference package.json scripts
'../../../.github/workflows/playwright.yml',
],
ignore: [
'**/app-react16/**/*',
// Bundled gems should not be analyzed by Knip
'vendor/bundle/**',
// Test files that shouldn't be treated as entry points
'tests/**',
'spec/**',
// Config files that require dependencies not in workspace root
'babel.config.js',
// Playwright support files and helpers - generated by cypress-on-rails gem
'e2e/playwright/support/**',
// Components and files used dynamically by React on Rails (registered at runtime)
'client/app/actions/**',
'client/app/components/**',
'client/app/routes/**',
'client/app/startup/**',
'client/app/store/**',
// ReScript entry files that import compiled .res.js files (compiled at build time)
'client/app/packs/rescript-components.js',
],
project: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!', 'config/webpack/*.js'],
paths: {
'Assets/*': ['client/app/assets/*'],
},
ignoreBinaries: [
// Has to be installed globally
'yalc',
// Local binaries
'bin/.*',
],
ignoreDependencies: [
// There's no ReScript plugin for Knip
'@rescript/react',
// The Babel plugin fails to detect it
'babel-plugin-transform-react-remove-prop-types',
// Required by @babel/plugin-transform-runtime for polyfills (used by webpack)
'@babel/runtime',
// Used in webpack server config for CSS extraction
'mini-css-extract-plugin',
// Webpack config merge helper is used in the dummy app config, but not detected reliably by Knip.
'webpack-merge',
// This one is weird. It's long-deprecated and shouldn't be necessary.
// Probably need to update the Webpack config.
'node-libs-browser',
// The below dependencies are not detected by the Webpack plugin
// due to the config issue.
'expose-loader',
'file-loader',
'imports-loader',
'null-loader',
'sass-resources-loader',
'style-loader',
'url-loader',
],
},
},
ignoreExportsUsedInFile: true,
};
export default config;