Skip to content

Commit 97d4414

Browse files
justin808claude
andauthored
Fix Knip configuration after monorepo restructure (#2041)
## Summary Fixes the failing "Detect dead code" CI job on master after the monorepo restructure. ## Problem After moving packages to `packages/react-on-rails` and `packages/react-on-rails-pro`, Knip was detecting false positives: - `jest.config.base.js` marked as unused (but it's used by both packages) - Test dependencies in root `package.json` marked as unused (shared by child workspaces) - `mock-fs` dependencies in Pro package marked as unused - Some dependencies marked as unused that are now properly detected ## Changes 1. **Added `jest.config.base.js` as entry point** - This shared Jest config is imported by both packages 2. **Removed `nps` from ignoreBinaries** - No longer referenced in package.json scripts 3. **Added test dependencies to root ignoreDependencies**: - `@testing-library/dom`, `@testing-library/jest-dom`, `@testing-library/react` - `@types/react-dom`, `create-react-class`, `jest-fetch-mock` - `prop-types`, `react`, `react-dom`, `redux` 4. **Added Pro package ignoreDependencies**: `@types/mock-fs`, `mock-fs` 5. **Removed now-detected dependencies** from spec/dummy ## Testing CI will validate the fix by running `yarn run knip --exclude binaries`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated dependency checking configuration to exclude test-related packages from checks across multiple workspaces. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude <[email protected]>
1 parent 276507d commit 97d4414

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)