Skip to content

Commit b237335

Browse files
authored
Upgrade typescript-eslint to v8 and fix lints (#2400)
upgrade ts-eslint to v8 and fix lints
1 parent 267b935 commit b237335

File tree

10 files changed

+126
-207
lines changed

10 files changed

+126
-207
lines changed

.eslintrc.cjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,29 @@ module.exports = {
4242
'@typescript-eslint/consistent-type-definitions': 'off',
4343
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
4444
'@typescript-eslint/no-empty-function': 'off',
45-
'@typescript-eslint/no-empty-interface': 'off',
4645
'@typescript-eslint/ban-ts-comment': 'off',
46+
'@typescript-eslint/no-empty-object-type': [
47+
'error',
48+
{ allowInterfaces: 'with-single-extends' },
49+
],
4750
'@typescript-eslint/no-non-null-assertion': 'off',
4851
'@typescript-eslint/no-duplicate-type-constituents': 'off',
4952
'@typescript-eslint/no-unused-vars': [
5053
'error',
51-
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
54+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
5255
],
5356

5457
// disabling the type-aware rules we don't like
5558
// https://typescript-eslint.io/getting-started/typed-linting/
5659
'@typescript-eslint/no-floating-promises': 'off',
5760
'@typescript-eslint/no-misused-promises': 'off',
58-
'@typescript-eslint/unbound-method': 'off',
5961
'@typescript-eslint/no-unsafe-argument': 'off',
6062
'@typescript-eslint/no-unsafe-assignment': 'off',
6163
'@typescript-eslint/no-unsafe-call': 'off',
6264
'@typescript-eslint/no-unsafe-member-access': 'off',
6365
'@typescript-eslint/no-unsafe-return': 'off',
66+
'@typescript-eslint/only-throw-error': 'off',
67+
'@typescript-eslint/unbound-method': 'off',
6468

6569
eqeqeq: ['error', 'always', { null: 'ignore' }],
6670
'import/no-default-export': 'error',

app/components/form/fields/NetworkInterfaceField.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ export function NetworkInterfaceField({
6161
setOldParams(value.params)
6262
}
6363

64-
newType === 'create'
65-
? onChange({ type: newType, params: oldParams })
66-
: onChange({ type: newType })
64+
if (newType === 'create') {
65+
onChange({ type: newType, params: oldParams })
66+
} else {
67+
onChange({ type: newType })
68+
}
6769
}}
6870
disabled={disabled}
6971
>

app/forms/disk-create.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ export function CreateDiskSideModalForm({
122122
onDismiss={() => onDismiss(navigate)}
123123
onSubmit={({ size, ...rest }) => {
124124
const body = { size: size * GiB, ...rest }
125-
onSubmit ? onSubmit(body) : createDisk.mutate({ query: { project }, body })
125+
if (onSubmit) {
126+
onSubmit(body)
127+
} else {
128+
createDisk.mutate({ query: { project }, body })
129+
}
126130
}}
127131
loading={createDisk.isPending}
128132
submitError={createDisk.error}

app/forms/image-upload.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,9 @@ async function readAtOffset(file: File, offset: number, length: number) {
770770
}
771771

772772
reader.onerror = (error) => {
773-
console.error(`Error reading file at offset ${offset}:`, error)
774-
reject(error)
773+
const msg = `Error reading file at offset ${offset}:`
774+
console.error(msg, error)
775+
reject(new Error(msg))
775776
}
776777
})
777778

app/layouts/RootLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ function LoadingBar() {
8888
// condition, we'd immediately kill an in-progress loading animation
8989
// that was about to finish on its own anyway.
9090
barRef.current?.classList.remove('loading', 'done')
91+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
9192
barRef.current?.scrollTop
9293

9394
// Kick off the animation

app/pages/project/instances/instance/tabs/MetricsTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export function MetricsTab() {
205205
selected={diskName}
206206
items={diskItems}
207207
onChange={(val) => {
208-
val && setDiskName(val)
208+
if (val) setDiskName(val)
209209
}}
210210
/>
211211
{dateTimeRangePicker}

app/ui/lib/AuthCodeInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const AuthCodeInput = forwardRef<AuthCodeRef, AuthCodeProps>(
124124
.map((input) => input.value)
125125
.join('')
126126
.toUpperCase()
127-
onChange && onChange(res)
127+
onChange?.(res)
128128
}
129129

130130
const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {

mock-api/msw/db.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import { commaSeries } from '~/util/str'
1919
import type { Json } from '../json-type'
2020
import { internalError } from './util'
2121

22-
const notFoundBody = { error_code: 'ObjectNotFound' } as const
23-
export type NotFound = typeof notFoundBody
2422
export const notFoundErr = (msg: string) => {
2523
const message = `not found: ${msg}`
2624
return json({ error_code: 'ObjectNotFound', message } as const, { status: 404 })

0 commit comments

Comments
 (0)