Skip to content

Commit c72d7ba

Browse files
chore: resolve remaining knip issues (#1991)
## Summary Resolve all remaining knip issues — removes unused exports/types, adds missing direct dependencies, deletes dead code, and updates knip config. **Dependency fixes:** - Root: swapped unused `eslint-config-next`/`eslint-plugin-react-hooks` for actually-imported `@eslint/js`, `typescript-eslint`, `tslib` - App: added directly-used transitive deps (`@codemirror/*`, `react-resizable`, `postcss-simple-vars`, `rimraf`, `serve`, `@next/eslint-plugin-next`, `eslint-plugin-react`); removed unused `@storybook/react` **Dead code removal:** - Removed ~100 unused exports/types across api and app packages (removed `export` keyword where used locally, deleted entirely where not) - Fixed duplicate `DBRowTableIconButton` default+named export; updated consumers to use named import **knip.json updates:** - Added `fixtures.ts` entry point and `opamp/**` ignore for api package - Excluded `enumMembers` and `duplicates` issue types - Enabled `ignoreExportsUsedInFile` ### How to test locally or on Vercel 1. `yarn install && yarn knip` — should produce zero output 2. `make ci-lint` — all packages pass 3. `make ci-unit` — all unit tests pass
1 parent acd117a commit c72d7ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+427
-640
lines changed

knip.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
]
1313
},
1414
"packages/api": {
15-
"entry": ["src/index.ts", "src/tasks/index.ts", "scripts/*.ts"],
15+
"entry": [
16+
"src/index.ts",
17+
"src/tasks/index.ts",
18+
"scripts/*.ts",
19+
"src/fixtures.ts"
20+
],
1621
"project": ["src/**/*.ts"],
17-
"ignoreDependencies": ["pino-pretty", "aws4"]
22+
"ignoreDependencies": ["pino-pretty", "aws4"],
23+
"ignore": ["src/opamp/**", "src/utils/logParser.ts"]
1824
},
1925
"packages/common-utils": {
2026
"entry": ["src/**/*.ts", "!src/__tests__/**", "!src/**/*.test.*"],
@@ -26,5 +32,6 @@
2632
"concurrently",
2733
"dotenv",
2834
"babel-plugin-react-compiler"
29-
]
35+
],
36+
"exclude": ["enumMembers", "duplicates"]
3037
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"devDependencies": {
1010
"@changesets/cli": "^2.26.2",
1111
"@dotenvx/dotenvx": "^1.51.1",
12+
"@eslint/js": "^9.39.1",
1213
"@types/ungap__structured-clone": "^1.2.0",
1314
"@ungap/structured-clone": "^1.3.0",
1415
"babel-plugin-react-compiler": "^1.0.0",
@@ -17,18 +18,18 @@
1718
"dotenv-cli": "^8.0.0",
1819
"dotenv-expand": "^12.0.1",
1920
"eslint": "^9.39.1",
20-
"eslint-config-next": "16.0.7",
2121
"eslint-config-prettier": "^9.1.0",
2222
"eslint-plugin-n": "^16.4.0",
2323
"eslint-plugin-prettier": "^5.2.1",
24-
"eslint-plugin-react-hooks": "^7.0.1",
2524
"eslint-plugin-security": "^3.0.1",
2625
"eslint-plugin-simple-import-sort": "^12.1.1",
2726
"husky": "^8.0.3",
2827
"knip": "^6.0.1",
2928
"lint-staged": "^13.1.2",
3029
"nx": "21.3.11",
31-
"prettier": "3.3.3"
30+
"prettier": "3.3.3",
31+
"tslib": "^2.6.0",
32+
"typescript-eslint": "^8.46.0"
3233
},
3334
"scripts": {
3435
"setup": "yarn install && husky install",

packages/api/src/controllers/ai.ts

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function normalizeParsedDate(parsed?: chrono.ParsedComponents): Date | null {
190190
return parsedDate;
191191
}
192192

193-
export function parseTimeRangeInput(
193+
function parseTimeRangeInput(
194194
str: string,
195195
isUTC: boolean = false,
196196
): [Date | null, Date | null] {
@@ -216,70 +216,14 @@ export function parseTimeRangeInput(
216216
}
217217
}
218218

219-
export const LIVE_TAIL_TIME_QUERY = 'Live Tail';
220-
221-
export const RELATIVE_TIME_OPTIONS: ([string, string] | 'divider')[] = [
222-
// ['Last 15 seconds', '15s'],
223-
// ['Last 30 seconds', '30s'],
224-
// 'divider',
225-
['Last 1 minute', '1m'],
226-
['Last 5 minutes', '5m'],
227-
['Last 15 minutes', '15m'],
228-
['Last 30 minutes', '30m'],
229-
['Last 45 minutes', '45m'],
230-
'divider',
231-
['Last 1 hour', '1h'],
232-
['Last 3 hours', '3h'],
233-
['Last 6 hours', '6h'],
234-
['Last 12 hours', '12h'],
235-
'divider',
236-
['Last 1 days', '1d'],
237-
['Last 2 days', '2d'],
238-
['Last 7 days', '7d'],
239-
['Last 14 days', '14d'],
240-
['Last 30 days', '30d'],
241-
];
242-
243-
export const DURATION_OPTIONS = [
244-
'30s',
245-
'1m',
246-
'5m',
247-
'15m',
248-
'30m',
249-
'1h',
250-
'3h',
251-
'6h',
252-
'12h',
253-
];
254-
255-
export const DURATIONS: Record<string, any> = {
256-
'30s': { seconds: 30 },
257-
'1m': { minutes: 1 },
258-
'5m': { minutes: 5 },
259-
'15m': { minutes: 15 },
260-
'30m': { minutes: 30 },
261-
'1h': { hours: 1 },
262-
'3h': { hours: 3 },
263-
'6h': { hours: 6 },
264-
'12h': { hours: 12 },
265-
};
266-
267-
export const dateParser = (input?: string) => {
268-
if (!input) {
269-
return null;
270-
}
271-
const parsed = chrono.casual.parse(input)[0];
272-
return normalizeParsedDate(parsed?.start);
273-
};
274-
275219
// TODO: Dedup from DBSearchPageFilters
276220
function isFieldPrimary(tableMetadata: TableMetadata | undefined, key: string) {
277221
return tableMetadata?.primary_key?.includes(key);
278222
}
279223

280224
// TODO: Dedup w/ app/src/utils.ts
281225
// Date formatting
282-
export const mergePath = (path: string[], jsonColumns: string[] = []) => {
226+
const mergePath = (path: string[], jsonColumns: string[] = []) => {
283227
const [key, ...rest] = path;
284228
if (rest.length === 0) {
285229
return key;

packages/api/src/controllers/user.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ export function findUserByEmail(email: string) {
1616
return User.findOne({ email: email.toLowerCase() });
1717
}
1818

19-
export async function findUserByEmailInTeam(
20-
email: string,
21-
team: string | ObjectId,
22-
) {
23-
// Case-insensitive email search - lowercase the email since User model stores emails in lowercase
24-
return User.findOne({ email: email.toLowerCase(), team });
25-
}
26-
2719
export function findUsersByTeam(team: string | ObjectId) {
2820
return User.find({ team }).sort({ createdAt: 1 });
2921
}

packages/api/src/middleware/cors.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import cors from 'cors';
22

33
import { FRONTEND_URL } from '@/config';
44

5-
export const noCors = cors();
6-
75
export default cors({ credentials: true, origin: FRONTEND_URL });

packages/api/src/models/presetDashboardFilter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import mongoose, { Schema } from 'mongoose';
77

88
import type { ObjectId } from '.';
99

10-
export interface IPresetDashboardFilter
11-
extends Omit<PresetDashboardFilter, 'source'> {
10+
interface IPresetDashboardFilter extends Omit<PresetDashboardFilter, 'source'> {
1211
_id: ObjectId;
1312
team: ObjectId;
1413
source: ObjectId;

packages/api/src/models/teamInvite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import mongoose, { Schema } from 'mongoose';
22
import ms from 'ms';
33

4-
export interface ITeamInvite {
4+
interface ITeamInvite {
55
createdAt: Date;
66
email: string;
77
name?: string;

packages/api/src/tasks/checkAlerts/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const formatValueToMatchThreshold = (
119119
}).format(value);
120120
};
121121

122-
export const notifyChannel = async ({
122+
const notifyChannel = async ({
123123
channel,
124124
message,
125125
}: {

packages/api/src/utils/common.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type Json =
1010
| Json[]
1111
| { [key: string]: Json };
1212

13-
export const useTry = <T>(fn: () => T): [null | Error | unknown, null | T] => {
13+
const useTry = <T>(fn: () => T): [null | Error | unknown, null | T] => {
1414
let output: null | T = null;
1515
let error: null | Error | unknown = null;
1616
try {
@@ -42,9 +42,6 @@ export const truncateString = (str: string, length: number) => {
4242
return str;
4343
};
4444

45-
export const sleep = (ms: number) =>
46-
new Promise(resolve => setTimeout(resolve, ms));
47-
4845
export const convertMsToGranularityString = (ms: number): Granularity => {
4946
const granularitySizeSeconds = Math.ceil(ms / 1000);
5047

packages/api/src/utils/errors.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,6 @@ export class Api404Error extends BaseError {
5050
}
5151
}
5252

53-
export class Api401Error extends BaseError {
54-
constructor(name: string) {
55-
super(name, StatusCode.UNAUTHORIZED, true, 'Unauthorized');
56-
}
57-
}
58-
59-
export class Api403Error extends BaseError {
60-
constructor(name: string) {
61-
super(name, StatusCode.FORBIDDEN, true, 'Forbidden');
62-
}
63-
}
64-
65-
export class Api409Error extends BaseError {
66-
constructor(name: string) {
67-
super(name, StatusCode.CONFLICT, true, 'Conflict');
68-
}
69-
}
70-
7153
export const isOperationalError = (error: Error) => {
7254
if (error instanceof BaseError) {
7355
return error.isOperational;

0 commit comments

Comments
 (0)