Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint setup and clean up #135

Merged
merged 2 commits into from
Jan 3, 2023
Merged

eslint setup and clean up #135

merged 2 commits into from
Jan 3, 2023

Conversation

gustavoguichard
Copy link
Contributor

I realized the eslint config was faulty, there were dependencies missing thus npm run lint was failing.

When I fixed it I also added the @typescript-eslint/consistent-type-imports rule so it will enforce the import type when it is due.

It turns out some eslint-disable comments were unnecessary, others had to be added and few other issues that came up.

I'll leave comments where actual code changes happened.

@netlify
Copy link

netlify bot commented Jan 3, 2023

Deploy Preview for remix-forms canceled.

Name Link
🔨 Latest commit 318dd32
🔍 Latest deploy log https://app.netlify.com/sites/remix-forms/deploys/63b471a9fad2040008510673

@@ -339,8 +338,7 @@ function createField<Schema extends SomeZodObject>({
radioWrapperComponent: RadioWrapper,
labelComponent: Label,
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[Input, Multiline, Select, Checkbox, Radio, RadioWrapper, Label],
[],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These variables are declared in an external scope so they never rerender the component, they are not needed here and eslint caught that.

@@ -257,6 +256,7 @@ function createForm({
radioWrapperComponent,
fieldErrorsComponent,
Error,
form.register,
Copy link
Contributor Author

@gustavoguichard gustavoguichard Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency was missing, this might result in a runtime change.
In my tests it didn't change the render count of forms with <Field component.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care too much for this linter rule but since it can help us to not miss important things adding form.register as a dependency is a small price to pay.

@@ -422,8 +422,7 @@ function createForm({
: transition.state === 'submitting'

setDisabled(shouldDisable)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [transition.state, formState])
}, [transition.state, formState, mode, isValid])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this addition makes sense as one value is a string union and the other is a boolean, if they change this code should probably re-run... any ideas?

Copy link
Contributor

@diogob diogob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gustavoguichard gustavoguichard merged commit e79a126 into main Jan 3, 2023
@gustavoguichard gustavoguichard deleted the lint-setup branch January 3, 2023 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants