Skip to content

Commit

Permalink
bump eslint + remove any's
Browse files Browse the repository at this point in the history
  • Loading branch information
talentlessguy committed Dec 1, 2024
1 parent b2640cc commit 3dda281
Show file tree
Hide file tree
Showing 11 changed files with 440 additions and 547 deletions.
2 changes: 1 addition & 1 deletion components/src/components/atoms/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
$shadow={shadow}
$shape={shape}
$size={size}
as={asProp as any}
as={asProp}
disabled={disabled}
href={href}
ref={ref}
Expand Down
4 changes: 2 additions & 2 deletions components/src/components/atoms/ScrollBox/ScrollBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ describe('<ScrollBox />', () => {
expectLine('bottom', false)
})
it('should show most recent intersection if multiple updates', () => {
let cb: (entries: any) => void
mockIntersectionObserverCls.mockImplementation((callback: any) => {
let cb: (entries: Pick<IntersectionObserverEntry, 'isIntersecting' | 'target' | 'time'>[]) => void
mockIntersectionObserverCls.mockImplementation((callback: typeof cb) => {
cb = callback
return {
observe: mockObserve,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Props = {
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>
DropdownChild: React.FC<{
setIsOpen: (isOpen: boolean) => void
item: React.ReactElement<React.PropsWithRef<any>>
item: React.ReactElement<React.PropsWithRef<unknown>>
}>
cancelLabel?: string
}
Expand Down
4 changes: 2 additions & 2 deletions components/src/components/molecules/Input/Input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('<Input />', () => {
})

it('should pass a ref down', async () => {
const ref = { current: null } as React.RefObject<any>
const ref = { current: null } as React.RefObject<HTMLInputElement>
render(
<Input label="Funding Goal" placeholder="10" ref={ref} units="ETH" />,
)
Expand All @@ -40,7 +40,7 @@ describe('<Input />', () => {
})

it('should fire onChange if clear button is pressed', async () => {
const ref = { current: null } as React.RefObject<any>
const ref = { current: null } as React.RefObject<HTMLInputElement>
const handleOnChange = vi.fn()
render(
<Input
Expand Down
5 changes: 3 additions & 2 deletions components/src/components/molecules/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ export const Select = React.forwardRef<HTMLInputElement, SelectProps>(

const selectedOption = options?.find(o => o.value === value) || null

const changeSelectedOption = (option?: SelectOptionProps, event?: any) => {
const changeSelectedOption = (option?: SelectOptionProps, event?: React.SyntheticEvent<HTMLElement>) => {
if (option?.disabled) return
if (option?.value === CREATE_OPTION_VALUE) {
onCreate?.(queryValue)
Expand All @@ -594,6 +594,7 @@ export const Select = React.forwardRef<HTMLInputElement, SelectProps>(
setValue(option?.value)
if (event) {
const nativeEvent = event.nativeEvent || event
// @ts-expect-error use of Function.constructor
const clonedEvent = new nativeEvent.constructor(
nativeEvent.type,
nativeEvent,
Expand Down Expand Up @@ -673,7 +674,7 @@ export const Select = React.forwardRef<HTMLInputElement, SelectProps>(
} while (visibleOptions[nextIndex])
}

const selectHighlightedIndex = (event: any) => {
const selectHighlightedIndex = (event: React.KeyboardEvent<HTMLDivElement> | React.KeyboardEvent<HTMLInputElement>) => {
const option = visibleOptions[highlightedIndex]
if (option) changeSelectedOption(option, event)
handleReset()
Expand Down
2 changes: 1 addition & 1 deletion components/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export const shortenAddress = (
return `${address.slice(0, leftSlice)}...${address.slice(-rightSlice)}`
}

export const getTestId = (props: any, fallback: string): string => {
export const getTestId = (props: Record<string, unknown>, fallback: string): string => {
return props['data-testid'] ? String(props['data-testid']) : fallback
}
13 changes: 8 additions & 5 deletions components/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@ export type PartialMockedFunction<T extends (...args: unknown[]) => unknown> = (
export const mockFunction = <T extends (...args: unknown[]) => unknown>(func: T) =>
func as unknown as MockedFunction<PartialMockedFunction<T>>

type Entry = Pick<IntersectionObserverEntry, 'isIntersecting' | 'target' | 'time'>

export const makeMockIntersectionObserver
= (
mockIntersectionObserverCls: MockedFunction<any>,
mockIntersectionObserverCls: MockedFunction<(callback: (entries: Entry[]) => void) => Pick<IntersectionObserver, 'observe' | 'disconnect'>>,
mockObserve: MockedFunction<(t: Element) => void>,
mockDisconnect: MockedFunction<any>,
mockDisconnect: MockedFunction<() => void>,
) =>
(intersectTop: boolean, intersectBottom: boolean) => {
let cb: (entries: any) => void
mockIntersectionObserverCls.mockImplementation((callback: any) => {
let cb: (entries: Entry[]) => void
mockIntersectionObserverCls.mockImplementation((callback) => {
cb = callback
return {
observe: mockObserve,
disconnect: mockDisconnect,
}
} as Pick<IntersectionObserver, 'observe' | 'disconnect'>
})
const els: HTMLElement[] = []
// @ts-expect-error mock interface
window.IntersectionObserver = mockIntersectionObserverCls

mockObserve.mockImplementation((el) => {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/components/SearchIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import * as Components from '@ensdomains/thorin'
import { iconGrid } from './SearchIcons.css'

const icons = Object.entries(Components as Record<string, any>)
const icons = Object.entries(Components)
.filter(([k]) => k.includes('SVG'))
.map(([name, Component]) => ({ name, Component }))
.sort((a, b) => (a.name > b.name ? 1 : -1))
Expand Down Expand Up @@ -105,7 +105,7 @@ export const SearchIcons = () => {
>
<IconGridFlex>
<ComponentContainer>
{React.createElement(x.Component as any, { height: 16, width: 16 })}
{React.createElement(x.Component as React.FunctionComponent<React.SVGAttributes<SVGSVGElement>>, { height: 16, width: 16 })}
</ComponentContainer>
<IconNameContainer>
<Typography
Expand Down
4 changes: 2 additions & 2 deletions docs/src/playroom/PlayroomState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ const makeStoreConsumer = (
store: Store,
setStore: (newStore: Store) => void,
) => {
const setDefaultState = (key: string, value: any) =>
const setDefaultState = (key: string, value: unknown) =>
defaultState.set(key, value)

const getState = (key: string) => store.get(key) ?? defaultState.get(key)

const setState = curry((key: string, value: any) =>
const setState = curry((key: string, value: unknown) =>
setStore(new Map(store.set(key, unwrapValue(value)))),
)

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
]
},
"devDependencies": {
"@eslint-react/eslint-plugin": "^1.15.2",
"@eslint-react/eslint-plugin": "^1.17.2",
"@eslint/compat": "^1.2.2",
"@eslint/js": "^9.14.0",
"@next/eslint-plugin-next": "^14.2.17",
"@next/eslint-plugin-next": "^15.0.3",
"@size-limit/preset-big-lib": "^11.1.6",
"@stylistic/eslint-plugin": "^2.10.1",
"@stylistic/eslint-plugin": "^2.11.0",
"@stylistic/stylelint-config": "^2.0.0",
"@types/dedent": "^0.7.2",
"@vitest/coverage-v8": "^2.1.4",
"dedent": "^1.5.3",
"eslint": "^9.14.0",
"eslint": "^9.16.0",
"globals": "^15.12.0",
"husky": "^7.0.4",
"lint-staged": "^11.2.6",
Expand All @@ -54,7 +54,7 @@
"stylelint": "^16.10.0",
"stylelint-config-recommended": "^14.0.1",
"typescript": "5.7.2",
"typescript-eslint": "^8.13.0",
"typescript-eslint": "^8.16.0",
"utility-types": "^3.11.0"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 3dda281

Please sign in to comment.