Open dgattey opened 3 years ago
+1 I'm trying to use this package without Polaris as a replacement for react-hook-form and I'm facing the same problem too. Did you find any workarounds in the meantime? Apart from the obvious advice of turning @typescript-eslint/unbound-method off.
Overview
Thanks for a great set of packages! I started using
@shopify/react-form
today with Polaris. Works really well for our use case, but we have a small problem with types.Our Typescript + ESLint config has
@typescript-eslint/unbound-method
on by default. For some reason, this code causes that rule to trigger - just the use ofuseForm
and passingformFields
andonSubmit
into it is enough. Most of this is just setup code to show how we're usinguseForm
- the real meat is the hook call itself that triggers the warning.I think the issue stems from this definition for Form and any like it, because you don't use arrow types, thus capturing this, instead of something like
validate: () => FormError[]
. Via https://stackoverflow.com/questions/62864908/how-to-prevent-typescript-eslint-unbound-method-errors-on-non-class-typescrip, that seems to be a common cause of this ESLint rule trigger.Would it be possible to change the type definitions to not capture self, unless there's a reason to be capturing self in those contexts? Thanks a ton!
Consuming repo
(Private source repo), but the above is enough to trigger the rule
Area
Area: <area>
labels to this issueScope
Is this issue related to a specific package?
Package: <package_name>
label.Checklist