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

Avoid non-autofixable ESLint errors in code generated around dbAuth #6061

Merged
merged 12 commits into from
Apr 27, 2023

Conversation

Philzen
Copy link
Contributor

@Philzen Philzen commented Jul 27, 2022

While upgrading to v2.0.0 and running the yarn rw lint --fix command, i bumped into one unfixable "error" and warning each. The error makes the command return an error code (=fail) and thus degrade the smoothness of the DX.

Issues:

…/api/src/functions/auth.ts
  105:49  error  'userAttributes' is defined but never used. Allowed unused args must match /^_/u  @typescript-eslint/no-unused-vars

→ fixed in 21c4121

…/web/src/pages/ResetPasswordPage/ResetPasswordPage.tsx
  39:6  warning  React Hook useEffect has missing dependencies: 'resetToken' and 'validateResetToken'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

→ fixed in 6f86667


Although it is too late for folks with an existing codebase on the upgrade path to v2.0.0, new RedwoodJS users may benefit from these changes as code generated for dbAuth won't show any ESLint errors.

@nx-cloud
Copy link

nx-cloud bot commented Jul 27, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 6cf7230. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 14 targets

Sent with 💌 from NxCloud.

@netlify
Copy link

netlify bot commented Jul 27, 2022

Deploy Preview for redwoodjs-docs canceled.

Name Link
🔨 Latest commit 6cf7230
🔍 Latest deploy log https://app.netlify.com/sites/redwoodjs-docs/deploys/62f41a92937c120008389826

@Philzen Philzen changed the title Avoid non-autofixable eslint errors in code generated around dbAuth Avoid non-autofixable ESLint errors in code generated around dbAuth Jul 27, 2022
@jtoar jtoar assigned jtoar and unassigned noire-munich Jul 28, 2022
Copy link
Contributor

@jtoar jtoar left a comment

Choose a reason for hiding this comment

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

Quick comment about the react-hooks rule. Maybe we should fix that one instead?

@Philzen
Copy link
Contributor Author

Philzen commented Aug 8, 2022

While finalizing this i briefly went through the other files – some of them i never looked at before b/c the stuff i initially wanted to fix in this PR were errors in my project, which doesn't (a) use strict mode and (b) doesn't use webAuthn, which just landed.

Regarding (a) i comitted another quick fix that i found in 94adc37, which adds to #5491
Regarding (b) i found an interesting catch 22 that i didn't want to blindly fix but rather filed this issue so the author can decide: #6171

@Philzen Philzen force-pushed the fix-eslint-errors branch from 94adc37 to b0ffe26 Compare August 9, 2022 00:45
@Philzen Philzen requested a review from Tobbe August 9, 2022 00:55
@Philzen Philzen force-pushed the fix-eslint-errors branch 3 times, most recently from ea8e9f3 to e8c4784 Compare August 9, 2022 04:15
@jtoar jtoar added the release:fix This PR is a fix label Aug 9, 2022
@Philzen Philzen requested a review from jtoar August 9, 2022 15:56
@Philzen
Copy link
Contributor Author

Philzen commented Aug 10, 2022

Just a CI side-note: is there a reason i cannot see my changes in the netlify preview deploy?

https://deploy-preview-6045--redwoodjs-docs.netlify.app/docs/tutorial/chapter6/comments-schema

@Philzen Philzen force-pushed the fix-eslint-errors branch from bb83b3e to 0fb0909 Compare August 10, 2022 14:18
@Tobbe
Copy link
Member

Tobbe commented Aug 10, 2022

@Philzen You need to switch from v2.2 to Canary in the dropdown up top

@Philzen
Copy link
Contributor Author

Philzen commented Aug 10, 2022

@Philzen You need to switch from v2.2 to Canary in the dropdown up top

🤦

Duh, it's too hot. Thanks.

@Philzen Philzen force-pushed the fix-eslint-errors branch from 0fb0909 to 76b7c22 Compare August 10, 2022 20:14
@Philzen Philzen force-pushed the fix-eslint-errors branch from 76b7c22 to 77d432f Compare August 10, 2022 20:44
@Philzen Philzen force-pushed the fix-eslint-errors branch from 77d432f to 84f2089 Compare August 10, 2022 20:44
@Philzen Philzen requested a review from Tobbe August 10, 2022 20:48
@Philzen Philzen force-pushed the fix-eslint-errors branch from 84f2089 to 0206348 Compare August 10, 2022 20:51
@Philzen Philzen force-pushed the fix-eslint-errors branch from 0206348 to 6cf7230 Compare August 10, 2022 20:52
@Tobbe Tobbe self-assigned this Aug 13, 2022
@cannikin
Copy link
Member

There's some additional variables added to the useEffect on the Reset Password page...did you test this to make sure it didn't introduce any additional re-renders or anything weird?

@dac09 are you okay with adding lint/TS override comments in generated code? I remember someone being particularly adverse to shipping code with those in there, and I'm 60% sure it was you?

@Philzen
Copy link
Contributor Author

Philzen commented Aug 19, 2022

There's some additional variables added to the useEffect on the Reset Password page...did you test this to make sure it didn't introduce any additional re-renders or anything weird?

@cannikin i admit i did not test it but merely followed the advice i was given. Personally, i'd prefer adding // eslint-disable-line react-hooks/exhaustive-deps as it clearly communicates that those dependencies were left out by the developer intentionally – same goes for #6171

@dac09 are you okay with adding lint/TS override comments in generated code? I remember someone being particularly adverse to shipping code with those in there, and I'm 60% sure it was you?

Actually, there already are numerous occasions of these kinds of comments in the code-base, particularly in templates (just make a full-text-search for "no-unused-vars"). I could even find an occasion of // eslint-disable-next-line react-hooks/rules-of-hooks in

// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
i18n.changeLanguage(context.globals.locale)
}, [context.globals.locale])

Maybe the core team could re-discuss this and come to a consensus? If comments were deemed OK, i could also immediately fix #6171 as part of this PR.

@Philzen Philzen mentioned this pull request Aug 19, 2022
1 task
@Tobbe
Copy link
Member

Tobbe commented Apr 9, 2023

I found this old PR. It had a bunch of merge conflicts that couldn't be automatically resolved by GH, so I fixed those.
Some of the fixes initially proposed by this PR had already been fixed by other PRs, so this one is now a bit smaller than what it was.

There's some additional variables added to the useEffect on the Reset Password page...did you test this to make sure it didn't introduce any additional re-renders or anything weird?

The additions are correct. If for example resetToken changes for some reason, we want the useEffect to re-evaluate. And if it doesn't change (which it most likely won't) the useEffect will only run once, just like with an empty dependency array.

@dac09 are you okay with adding lint/TS override comments in generated code? I remember someone being particularly adverse to shipping code with those in there, and I'm 60% sure it was you?

We're only making existing comments more specific, not adding any new ones. Personally I'd prefer a different solution to the problem, so we could get rid of the comments entirely, but that's for another PR 🙂

@thedavidprice
Copy link
Contributor

@Tobbe did you want this one to go in? I just triggered CI as I assume it was failing due to the flaky tests we resolved last week.

@Tobbe Tobbe merged commit a970fae into redwoodjs:main Apr 27, 2023
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone Apr 27, 2023
@Tobbe
Copy link
Member

Tobbe commented Apr 27, 2023

@thedavidprice Thanks for the ping!

@jtoar jtoar modified the milestones: next-release, v5.0.0 Apr 27, 2023
Copy link
Contributor

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix This PR is a fix
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants