Skip to content

Commit f43efce

Browse files
justin808claude
andcommitted
Fix Knip configuration after monorepo restructure
After the monorepo restructure that moved packages to packages/react-on-rails and packages/react-on-rails-pro, Knip was detecting false positives for unused files and dependencies. Changes: - Add jest.config.base.js as entry point (used by both packages) - Remove 'nps' from ignoreBinaries (no longer in package.json scripts) - Add test dependencies to root ignoreDependencies (shared by child workspaces) - Add mock-fs dependencies to Pro package ignoreDependencies - Remove dependencies that are now properly detected (@babel/runtime, mini-css-extract-plugin, css-loader, sass, sass-loader) This fixes the failing "Detect dead code" CI job on master. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 276507d commit f43efce

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

knip.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ const config: KnipConfig = {
55
workspaces: {
66
// Root workspace - manages the monorepo and global tooling
77
'.': {
8-
entry: ['eslint.config.ts'],
8+
entry: ['eslint.config.ts', 'jest.config.base.js'],
99
project: ['*.{js,mjs,ts}'],
1010
ignoreBinaries: [
1111
// Has to be installed globally
1212
'yalc',
13-
// Used in package.json scripts (devDependency, so unlisted in production mode)
14-
'nps',
1513
// Pro package binaries used in Pro workflows
1614
'playwright',
1715
'e2e-test',
@@ -41,6 +39,17 @@ const config: KnipConfig = {
4139
// SWC transpiler dependencies used in dummy apps
4240
'@swc/core',
4341
'swc-loader',
42+
// Test dependencies used by child workspaces (packages/react-on-rails, packages/react-on-rails-pro)
43+
'@testing-library/dom',
44+
'@testing-library/jest-dom',
45+
'@testing-library/react',
46+
'@types/react-dom',
47+
'create-react-class',
48+
'jest-fetch-mock',
49+
'prop-types',
50+
'react',
51+
'react-dom',
52+
'redux',
4453
],
4554
},
4655

@@ -89,6 +98,11 @@ const config: KnipConfig = {
8998
'src/RSCRoute.tsx:RSCRouteProps',
9099
'src/streamServerRenderedReactComponent.ts:StreamingTrackers',
91100
],
101+
ignoreDependencies: [
102+
// Test dependencies used only in tests
103+
'@types/mock-fs',
104+
'mock-fs',
105+
],
92106
},
93107
'spec/dummy': {
94108
entry: [
@@ -124,9 +138,6 @@ const config: KnipConfig = {
124138
'bin/.*',
125139
],
126140
ignoreDependencies: [
127-
// Build-time dependencies not detected by Knip in any mode
128-
'@babel/runtime',
129-
'mini-css-extract-plugin',
130141
// There's no ReScript plugin for Knip
131142
'@rescript/react',
132143
// The Babel plugin fails to detect it
@@ -136,13 +147,10 @@ const config: KnipConfig = {
136147
'node-libs-browser',
137148
// The below dependencies are not detected by the Webpack plugin
138149
// due to the config issue.
139-
'css-loader',
140150
'expose-loader',
141151
'file-loader',
142152
'imports-loader',
143153
'null-loader',
144-
'sass',
145-
'sass-loader',
146154
'sass-resources-loader',
147155
'style-loader',
148156
'url-loader',

0 commit comments

Comments
 (0)