Skip to content

Commit 0b6c765

Browse files
committed
linting
1 parent 383ff45 commit 0b6c765

File tree

26 files changed

+2020
-2085
lines changed

26 files changed

+2020
-2085
lines changed

.eslintrc.cjs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ const config = {
2626
'next/core-web-vitals',
2727
'prettier',
2828
],
29-
ignorePatterns: ['node_modules', '*.stories.*', '*.test.*', 'public', '.eslintrc.cjs',],
29+
ignorePatterns: [
30+
'node_modules',
31+
'*.stories.*',
32+
'*.test.*',
33+
'public',
34+
'.eslintrc.cjs',
35+
],
3036
rules: {
31-
"@next/next/no-img-element": "off",
32-
"import/no-anonymous-default-export": "off",
33-
"@typescript-eslint/consistent-type-definitions": ['error', 'type'],
37+
'@next/next/no-img-element': 'off',
38+
'import/no-anonymous-default-export': 'off',
39+
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
3440
'no-process-env': 'error',
3541
'no-console': 'error',
3642
'@typescript-eslint/consistent-type-imports': [
@@ -43,14 +49,15 @@ const config = {
4349
'@typescript-eslint/no-unused-vars': [
4450
'error',
4551
{
52+
caughtErrors: 'none',
4653
argsIgnorePattern: '^_',
4754
},
4855
],
49-
"@typescript-eslint/no-misused-promises": [
50-
"error",
56+
'@typescript-eslint/no-misused-promises': [
57+
'error',
5158
{
52-
"checksVoidReturn": false
53-
}
59+
checksVoidReturn: false,
60+
},
5461
],
5562
'no-unreachable': 'error',
5663
},

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"WillLuke.nextjs.addTypesOnSave": true,
88
"WillLuke.nextjs.hasPrompted": true,
99
"editor.codeActionsOnSave": {
10-
"source.organizeImports": "always"
10+
"source.organizeImports": "always",
11+
"source.fixAll": "always",
1112
}
1213
}

actions/activityFeed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function addEvent(
1919
safeRevalidateTag('activityFeed');
2020

2121
return { success: true, error: null };
22-
} catch (error) {
22+
} catch (_error) {
2323
return { success: false, error: 'Failed to add event' };
2424
}
2525
}

app/dashboard/_components/InterviewsTable/ActionsDropdown.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Interview } from '@prisma/client';
44
import type { Row } from '@tanstack/react-table';
55
import { MoreHorizontal } from 'lucide-react';
66
import Link from 'next/link';
7+
import { objectHash } from 'ohash';
78
import { useState } from 'react';
89
import { DeleteInterviewsDialog } from '~/app/dashboard/interviews/_components/DeleteInterviewsDialog';
910
import { ExportInterviewsDialog } from '~/app/dashboard/interviews/_components/ExportInterviewsDialog';
@@ -39,7 +40,7 @@ export const ActionsDropdown = ({ row }: { row: Row<Interview> }) => {
3940
return (
4041
<>
4142
<ExportInterviewsDialog
42-
key={selectedInterviews?.toString()}
43+
key={objectHash(selectedInterviews)}
4344
open={showExportModal}
4445
handleCancel={handleResetExport}
4546
interviewsToExport={selectedInterviews!}

app/dashboard/_components/InterviewsTable/InterviewsTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import { HardDriveUpload } from 'lucide-react';
4+
import { objectHash } from 'ohash';
45
import { use, useMemo, useState } from 'react';
56
import { ActionsDropdown } from '~/app/dashboard/_components/InterviewsTable/ActionsDropdown';
67
import { InterviewColumns } from '~/app/dashboard/_components/InterviewsTable/Columns';
@@ -60,7 +61,7 @@ export const InterviewsTable = ({
6061
return (
6162
<>
6263
<ExportInterviewsDialog
63-
key={selectedInterviews?.toString()}
64+
key={objectHash(selectedInterviews)}
6465
open={showExportModal}
6566
handleCancel={handleResetExport}
6667
interviewsToExport={selectedInterviews!}

components/ProtocolImport/JobReducer.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import trackEvent from '~/lib/analytics';
22

3-
const importStatuses = [
4-
'Queued',
5-
'Extracting protocol',
6-
'Validating protocol',
7-
'Uploading assets',
8-
'Writing to database',
9-
'Complete',
10-
] as const;
11-
12-
type ImportStatus = (typeof importStatuses)[number];
3+
type ImportStatus =
4+
| 'Queued'
5+
| 'Extracting protocol'
6+
| 'Validating protocol'
7+
| 'Uploading assets'
8+
| 'Writing to database'
9+
| 'Complete';
1310

1411
type ErrorState = {
1512
title: string;

components/ui/use-toast.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@ type ToasterToast = ToastProps & {
1414
icon?: React.ReactNode;
1515
};
1616

17-
const actionTypes = {
18-
ADD_TOAST: 'ADD_TOAST',
19-
UPDATE_TOAST: 'UPDATE_TOAST',
20-
DISMISS_TOAST: 'DISMISS_TOAST',
21-
REMOVE_TOAST: 'REMOVE_TOAST',
22-
} as const;
23-
2417
let count = 0;
2518

2619
function genId() {
2720
count = (count + 1) % Number.MAX_VALUE;
2821
return count.toString();
2922
}
3023

31-
type ActionType = typeof actionTypes;
24+
type ActionType = {
25+
ADD_TOAST: 'ADD_TOAST';
26+
UPDATE_TOAST: 'UPDATE_TOAST';
27+
DISMISS_TOAST: 'DISMISS_TOAST';
28+
REMOVE_TOAST: 'REMOVE_TOAST';
29+
};
3230

3331
type Action =
3432
| {
@@ -187,4 +185,4 @@ function useToast() {
187185
};
188186
}
189187

190-
export { useToast, };
188+
export { useToast };

fresco.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export const PROTOCOL_EXTENSION = '.netcanvas' as const;
1+
export const PROTOCOL_EXTENSION = '.netcanvas';
22
export const APP_SUPPORTED_SCHEMA_VERSIONS = [7];
33
// If unconfigured, the app will shut down after 2 hours (7200000 ms)
4-
export const UNCONFIGURED_TIMEOUT = 7200000 as const;
4+
export const UNCONFIGURED_TIMEOUT = 7200000;
55

66
// Display options for dates: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#using_options
77
export const dateOptions: Intl.DateTimeFormatOptions = {

lib/cache.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import { revalidateTag, unstable_cache } from 'next/cache';
22

3-
const CACHE_TAGS = [
4-
'activityFeed',
5-
'appSettings',
6-
'getInterviews',
7-
'summaryStatistics',
8-
'getParticipants',
9-
'getInterviewById',
10-
'getProtocols',
11-
'getInterviewsForExport',
12-
'getProtocolsByHash',
13-
'getExistingAssetIds',
14-
'interviewCount',
15-
'protocolCount',
16-
'participantCount',
17-
] as const;
3+
type StaticTag =
4+
| 'activityFeed'
5+
| 'appSettings'
6+
| 'getInterviews'
7+
| 'summaryStatistics'
8+
| 'getParticipants'
9+
| 'getInterviewById'
10+
| 'getProtocols'
11+
| 'getInterviewsForExport'
12+
| 'getProtocolsByHash'
13+
| 'getExistingAssetIds'
14+
| 'interviewCount'
15+
| 'protocolCount'
16+
| 'participantCount';
1817

19-
type StaticTag = (typeof CACHE_TAGS)[number];
2018
type DynamicTag = `${StaticTag}-${string}`;
2119

2220
type CacheTag = StaticTag | DynamicTag;

lib/data-table/types.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { type Prisma } from '@prisma/client';
22
import * as z from 'zod';
3-
import { numberEnum } from '~/schemas/participant';
43

54
export type Option = {
65
label: string;
@@ -68,12 +67,10 @@ export const FilterParam = z.object({
6867
});
6968
export type FilterParam = z.infer<typeof FilterParam>;
7069

71-
const SearchParamsSchema = z.object({
72-
page: z.number(),
73-
perPage: numberEnum(pageSizes),
74-
sort: z.enum(sortOrder),
75-
sortField: z.enum(sortableFields),
76-
filterParams: z.array(FilterParam).nullable(),
77-
});
78-
79-
export type SearchParams = z.infer<typeof SearchParamsSchema>;
70+
export type SearchParams = {
71+
page: number;
72+
perPage: number;
73+
sort: (typeof sortOrder)[number];
74+
sortField: (typeof sortableFields)[number];
75+
filterParams: FilterParam[] | null;
76+
};

0 commit comments

Comments
 (0)