Skip to content

Commit 317cdb3

Browse files
committed
Add eslint-plugin-react-hooks and fix lint errors
1 parent e88ac6a commit 317cdb3

23 files changed

+98
-67
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"devDependencies": {
2525
"@changesets/cli": "^2.22.0",
2626
"eslint": "^7.32.0",
27+
"eslint-plugin-react-hooks": "^5.1.0",
2728
"prettier": "^2.5.1",
2829
"rimraf": "^5.0.0",
2930
"turbo": "^1.10.14"

packages/react/.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env node */
22
module.exports = {
3-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
3+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended', 'prettier'],
44
ignorePatterns: ['**/dist/*'],
55
parser: '@typescript-eslint/parser',
66
plugins: ['@typescript-eslint', 'react-refresh'],

packages/react/src/components/Checklist/CarouselEmblaWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function CarouselEmblaWrapper({
6969
setHasNext(emblaApi.canScrollNext())
7070
setHasPrev(emblaApi.canScrollPrev())
7171
})
72-
}, [emblaApi])
72+
}, [emblaApi, hasNext, hasPrev])
7373

7474
useEffect(() => {
7575
// check if hasCompletedInitialSort. If not then sort the steps from not completed not skipped to completed/skipped
@@ -91,7 +91,7 @@ export function CarouselEmblaWrapper({
9191
setStepOrder(steps.map((step) => step.id))
9292
}
9393
}
94-
}, [])
94+
}, [flow.steps, sort, stepOrder])
9595

9696
const completedSteps = flow.getNumberOfCompletedSteps()
9797
const availableSteps = flow.getNumberOfAvailableSteps()

packages/react/src/components/ClientPortal/ClientPortal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export interface ClientPortalProps {
66
}
77

88
export function ClientPortal({ children, container = 'body' }: ClientPortalProps) {
9-
return children != null ? useClientPortal(children, container) : null
9+
return useClientPortal(children, container)
1010
}

packages/react/src/components/Form/FormStep.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function FormStep({
9292
}, {})
9393
)
9494
}
95-
}, [fieldDatas])
95+
}, [fieldDatas, formContext])
9696

9797
useEffect(() => {
9898
if (
@@ -102,7 +102,7 @@ export function FormStep({
102102
) {
103103
formContext.trigger()
104104
}
105-
}, [step.id])
105+
}, [fieldDatas, formContext, step.id])
106106

107107
const [isSubmitting, setIsSubmitting] = useState(false)
108108

@@ -136,7 +136,7 @@ export function FormStep({
136136

137137
useEffect(() => {
138138
formContext.clearErrors()
139-
}, [step])
139+
}, [formContext, step])
140140

141141
return (
142142
<>

packages/react/src/components/Form/fields/BaseField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as styles from './BaseField.styles'
88
export interface FieldProps {
99
value: string
1010
onChange: (value: string) => void
11-
[key: string]: any
11+
[key: string]: unknown
1212
}
1313

1414
interface BaseFieldProps extends FormFieldProps {

packages/react/src/components/Form/fields/CheckboxField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as baseStyles from '@/components/Form/fields/BaseField.styles'
1111
export function CheckboxField(props: FormFieldProps) {
1212
const {
1313
field: { onChange, value },
14-
fieldData: { options, label, id = [] },
14+
fieldData: { label, id = [] },
1515
} = props
1616

1717
return (
@@ -32,7 +32,7 @@ export function CheckboxField(props: FormFieldProps) {
3232
justifyContent="center"
3333
alignItems="center"
3434
display="flex"
35-
// @ts-ignore
35+
// @ts-expect-error :hover type isn't in style props yet
3636
backgroundColor:hover="neutral.900"
3737
part="field-checkbox"
3838
id={id as string}

packages/react/src/components/Form/fields/SelectMultipleField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as baseStyles from '@/components/Form/fields/BaseField.styles'
1111

1212
export function SelectMultipleField(props: FormFieldProps) {
1313
const {
14-
field: { onChange, value },
14+
field: { onChange },
1515
fieldData: { options = [] },
1616
} = props
1717

packages/react/src/components/Form/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface FormFieldData extends ValidationRules {
4747
multiple?: boolean
4848
props?: Record<string, string | number | boolean | undefined>
4949
// allow any other custom properties
50-
[key: string]: any
50+
[key: string]: unknown
5151
}
5252

5353
// TODO: Wire UseControllerReturn into this type

packages/react/src/components/Hint/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function Hint({
103103
} else if (!autoScroll) {
104104
setScrollComplete(true)
105105
}
106-
}, [autoScroll, refs.reference.current])
106+
}, [autoScroll, refs.reference, scrollComplete])
107107

108108
if (refs.reference.current == null || !scrollComplete || !isVisible) {
109109
return null

0 commit comments

Comments
 (0)