Skip to content

Commit

Permalink
Upgrade typescript-eslint to v8 and fix lints (#2400)
Browse files Browse the repository at this point in the history
upgrade ts-eslint to v8 and fix lints
  • Loading branch information
david-crespo authored Aug 28, 2024
1 parent 267b935 commit b237335
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 207 deletions.
10 changes: 7 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,29 @@ module.exports = {
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-object-type': [
'error',
{ allowInterfaces: 'with-single-extends' },
],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-duplicate-type-constituents': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
],

// disabling the type-aware rules we don't like
// https://typescript-eslint.io/getting-started/typed-linting/
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/unbound-method': 'off',

eqeqeq: ['error', 'always', { null: 'ignore' }],
'import/no-default-export': 'error',
Expand Down
8 changes: 5 additions & 3 deletions app/components/form/fields/NetworkInterfaceField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ export function NetworkInterfaceField({
setOldParams(value.params)
}

newType === 'create'
? onChange({ type: newType, params: oldParams })
: onChange({ type: newType })
if (newType === 'create') {
onChange({ type: newType, params: oldParams })
} else {
onChange({ type: newType })
}
}}
disabled={disabled}
>
Expand Down
6 changes: 5 additions & 1 deletion app/forms/disk-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ export function CreateDiskSideModalForm({
onDismiss={() => onDismiss(navigate)}
onSubmit={({ size, ...rest }) => {
const body = { size: size * GiB, ...rest }
onSubmit ? onSubmit(body) : createDisk.mutate({ query: { project }, body })
if (onSubmit) {
onSubmit(body)
} else {
createDisk.mutate({ query: { project }, body })
}
}}
loading={createDisk.isPending}
submitError={createDisk.error}
Expand Down
5 changes: 3 additions & 2 deletions app/forms/image-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,9 @@ async function readAtOffset(file: File, offset: number, length: number) {
}

reader.onerror = (error) => {
console.error(`Error reading file at offset ${offset}:`, error)
reject(error)
const msg = `Error reading file at offset ${offset}:`
console.error(msg, error)
reject(new Error(msg))
}
})

Expand Down
1 change: 1 addition & 0 deletions app/layouts/RootLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function LoadingBar() {
// condition, we'd immediately kill an in-progress loading animation
// that was about to finish on its own anyway.
barRef.current?.classList.remove('loading', 'done')
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
barRef.current?.scrollTop

// Kick off the animation
Expand Down
2 changes: 1 addition & 1 deletion app/pages/project/instances/instance/tabs/MetricsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export function MetricsTab() {
selected={diskName}
items={diskItems}
onChange={(val) => {
val && setDiskName(val)
if (val) setDiskName(val)
}}
/>
{dateTimeRangePicker}
Expand Down
2 changes: 1 addition & 1 deletion app/ui/lib/AuthCodeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const AuthCodeInput = forwardRef<AuthCodeRef, AuthCodeProps>(
.map((input) => input.value)
.join('')
.toUpperCase()
onChange && onChange(res)
onChange?.(res)
}

const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand Down
2 changes: 0 additions & 2 deletions mock-api/msw/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import { commaSeries } from '~/util/str'
import type { Json } from '../json-type'
import { internalError } from './util'

const notFoundBody = { error_code: 'ObjectNotFound' } as const
export type NotFound = typeof notFoundBody
export const notFoundErr = (msg: string) => {
const message = `not found: ${msg}`
return json({ error_code: 'ObjectNotFound', message } as const, { status: 404 })
Expand Down
Loading

0 comments on commit b237335

Please sign in to comment.