Skip to content

Commit ca84ff7

Browse files
chore: upgrade knip to v6.19+ and fix all unused export issues (#2567)
## Summary Knip can now catch unused namespace exports (`nsExports`) in addition to the standard unused export/type checks, and all existing issues are resolved — `yarn knip` exits clean. Upgraded from `^6.0.1` to `^6.19.0` (resolves to 6.20.0) and removed the stale v5 dependency that `packages/app` still carried. Removed `export` keywords from 26 values/types across all packages that were only used internally within their defining files. Two functions (`deduplicateArray`, `isValidSessionsTable`) turned out to be completely dead code and were deleted. One `jest.spyOn`-accessed re-export (`handleSendGenericWebhook`) was marked `@public` since knip can't statically detect dynamic property access. Config cleanup: removed `playwright` from `ignoreBinaries` (knip now detects the Playwright plugin natively), added `claude` to hdx-eval's `ignoreBinaries`.
1 parent 1838a58 commit ca84ff7

21 files changed

Lines changed: 333 additions & 408 deletions

File tree

‎knip.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@
2929
},
3030
"packages/hdx-eval": {
3131
"project": ["src/**/*.ts"],
32-
"ignoreDependencies": ["tsx"]
32+
"ignoreDependencies": ["tsx"],
33+
"ignoreBinaries": ["claude"]
3334
}
3435
},
3536
"ignore": [
3637
"scripts/dev-portal/**",
3738
".github/scripts/**",
3839
"docker/hyperdx/**"
3940
],
40-
"ignoreBinaries": ["make", "migrate", "playwright"],
41+
"ignoreBinaries": ["make", "migrate"],
4142
"ignoreDependencies": [
4243
"@dotenvx/dotenvx",
4344
"concurrently",
4445
"dotenv",
4546
"babel-plugin-react-compiler"
4647
],
48+
"include": ["nsExports"],
4749
"exclude": ["enumMembers", "duplicates"]
4850
}

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"eslint-plugin-security": "^3.0.1",
2525
"eslint-plugin-simple-import-sort": "^12.1.1",
2626
"husky": "^8.0.3",
27-
"knip": "^6.0.1",
27+
"knip": "^6.19.0",
2828
"lint-staged": "^13.1.2",
2929
"nx": "21.3.11",
3030
"prettier": "3.3.3",

‎packages/api/src/models/source.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { objectIdSchema } from '@/utils/zod';
1818
// ISource is a discriminated union (inherits from TSource) with team added
1919
// and connection widened to ObjectId | string for Mongoose.
2020
// Omit and & distribute over the union, preserving the discriminated structure.
21-
export const ISourceSchema = z.discriminatedUnion('kind', [
21+
const ISourceSchema = z.discriminatedUnion('kind', [
2222
LogSourceSchema.omit({ connection: true }).extend({
2323
team: objectIdSchema,
2424
connection: objectIdSchema.or(z.string()),

‎packages/api/src/tasks/checkAlerts/index.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export async function computeAliasWithClauses(
171171
return aliasMapToWithClauses(aliasMap);
172172
}
173173

174-
export class InvalidAlertError extends Error {
174+
class InvalidAlertError extends Error {
175175
constructor(message: string) {
176176
super(message);
177177
this.name = 'InvalidAlertError';
@@ -1308,7 +1308,8 @@ export const processAlert = async (
13081308
}
13091309
};
13101310

1311-
// Re-export handleSendGenericWebhook for testing
1311+
// Re-export handleSendGenericWebhook for testing (accessed via jest.spyOn)
1312+
/** @public */
13121313
export { handleSendGenericWebhook };
13131314

13141315
export interface AggregatedAlertHistory {

‎packages/api/src/utils/zod.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ export type ExternalDashboardRawSqlTileConfig = z.infer<
457457
typeof externalDashboardRawSqlTileConfigSchema
458458
>;
459459

460-
export const externalDashboardTileConfigSchema = z
460+
const externalDashboardTileConfigSchema = z
461461
.custom<
462462
ExternalDashboardRawSqlTileConfig | ExternalDashboardBuilderTileConfig
463463
>()

‎packages/app/package.json‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"test:e2e": "node scripts/run-e2e.js",
2424
"test:e2e:ci": "../../scripts/test-e2e-ci.sh",
2525
"storybook": "storybook dev -p 6006",
26-
"storybook:build": "storybook build",
27-
"knip": "knip"
26+
"storybook:build": "storybook build"
2827
},
2928
"dependencies": {
3029
"@codemirror/autocomplete": "^6.0.0",
@@ -138,7 +137,6 @@
138137
"identity-obj-proxy": "^3.0.0",
139138
"jest": "^30.2.0",
140139
"jest-environment-jsdom": "^30.2.0",
141-
"knip": "^5.33.2",
142140
"msw": "^2.3.0",
143141
"msw-storybook-addon": "^2.0.2",
144142
"postcss": "^8.5.10",

‎packages/app/src/components/DBSearchPageFilters.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ export function cleanedFacetName(key: string): string {
124124
}
125125

126126
/** Value-level pin callbacks and state (personal + shared). */
127-
export type ValuePinHandlers = {
127+
type ValuePinHandlers = {
128128
onPinClick: (value: string | boolean) => void;
129129
isPinned: (value: string | boolean) => boolean;
130130
onSharedPinClick?: (value: string | boolean) => void;
131131
isSharedPinned?: (value: string | boolean) => boolean;
132132
};
133133

134134
/** Field/group-level pin callbacks and state (personal + shared). */
135-
export type FieldPinHandlers = {
135+
type FieldPinHandlers = {
136136
onFieldPinClick?: VoidFunction;
137137
isFieldPinned?: boolean;
138138
onToggleSharedFieldPin?: VoidFunction;

‎packages/app/src/components/HeatmapSettingsDrawer.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { IconPlayerPlay } from '@tabler/icons-react';
1717

1818
import { SQLInlineEditorControlled } from '@/components/SQLEditor/SQLInlineEditor';
1919

20-
export const HeatmapSettingsSchema = z.object({
20+
const HeatmapSettingsSchema = z.object({
2121
value: z.string().trim().min(1),
2222
count: z.string().trim().optional(),
2323
scaleType: z.enum(['log', 'linear']).default('log'),

‎packages/app/src/hooks/usePatterns.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const TIMESTAMP_COLUMN_ALIAS = '__hdx_timestamp';
111111
export const SEVERITY_TEXT_COLUMN_ALIAS = '__hdx_severity_text';
112112
const STATUS_CODE_COLUMN_ALIAS = '__hdx_status_code';
113113

114-
export type SampleLog = {
114+
type SampleLog = {
115115
[PATTERN_COLUMN_ALIAS]: string;
116116
[TIMESTAMP_COLUMN_ALIAS]: string;
117117
[key: string]: any;

‎packages/app/src/theme/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type ThemeName = 'hyperdx' | 'clickstack';
4141
* Favicon configuration for a theme.
4242
* Modern best practice includes multiple formats for broad compatibility.
4343
*/
44-
export interface FaviconConfig {
44+
interface FaviconConfig {
4545
/** SVG favicon - best for modern browsers, scalable */
4646
svg: string;
4747
/** PNG 32x32 - standard fallback */

0 commit comments

Comments
 (0)