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

🐛 useExhaustiveDependencies: allow effects with no dependency arrays #608

Closed
1 task done
nstepien opened this issue Oct 26, 2023 · 7 comments · Fixed by #977
Closed
1 task done

🐛 useExhaustiveDependencies: allow effects with no dependency arrays #608

nstepien opened this issue Oct 26, 2023 · 7 comments · Fixed by #977
Assignees
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@nstepien
Copy link
Contributor

nstepien commented Oct 26, 2023

Environment information

https://biomejs.dev/playground/?indentStyle=space&quoteStyle=single&trailingComma=none&code=aQBtAHAAbwByAHQAIAB7ACAAdQBzAGUARQBmAGYAZQBjAHQALAAgAHUAcwBlAEwAYQB5AG8AdQB0AEUAZgBmAGUAYwB0ACAAfQAgAGYAcgBvAG0AIAAnAHIAZQBhAGMAdAAnADsACgAKAGYAdQBuAGMAdABpAG8AbgAgAHUAcwBlAEMAdQBzAHQAbwBtAEgAbwBvAGsAKAB2AGEAbAB1AGUAOgAgAHUAbgBrAG4AbwB3AG4AKQAgAHsACgAgACAAdQBzAGUARQBmAGYAZQBjAHQAKAAoACkAIAA9AD4AIAB7AAoAIAAgACAAIABjAG8AbgBzAG8AbABlAC4AbABvAGcAKAB2AGEAbAB1AGUAKQA7AAoAIAAgAH0AKQA7AAoACgAgACAAdQBzAGUATABhAHkAbwB1AHQARQBmAGYAZQBjAHQAKAAoACkAIAA9AD4AIAB7AAoAIAAgACAAIABjAG8AbgBzAG8AbABlAC4AbABvAGcAKAB2AGEAbAB1AGUAKQA7AAoAIAAgAH0AKQA7AAoAfQAKAA%3D%3D

https://biomejs.dev/playground/?indentStyle=space&quoteStyle=single&trailingComma=none&code=aQBtAHAAbwByAHQAIAB7ACAAdQBzAGUARQBmAGYAZQBjAHQALAAgAHUAcwBlAEwAYQB5AG8AdQB0AEUAZgBmAGUAYwB0ACAAfQAgAGYAcgBvAG0AIAAnAHIAZQBhAGMAdAAnADsACgAKAGYAdQBuAGMAdABpAG8AbgAgAHUAcwBlAEMAdQBzAHQAbwBtAEgAbwBvAGsAKAB2AGEAbAB1AGUAOgAgAHUAbgBrAG4AbwB3AG4AKQAgAHsACgAgACAAdQBzAGUARQBmAGYAZQBjAHQAKAAoACkAIAA9AD4AIAB7AAoAIAAgACAAIABjAG8AbgBzAG8AbABlAC4AbABvAGcAKAB2AGEAbAB1AGUAKQA7AAoAIAAgAH0AKQA7AAoACgAgACAAdQBzAGUATABhAHkAbwB1AHQARQBmAGYAZQBjAHQAKAAoACkAIAA9AD4AIAB7AAoAIAAgACAAIABjAG8AbgBzAG8AbABlAC4AbABvAGcAKAB2AGEAbAB1AGUAKQA7AAoAIAAgAH0AKQA7AAoAfQAKAA%3D%3D

What happened?

Effect hooks with no dependency arrays are valid, in some cases we do want to run the effect on every render, or avoiding re-runs isn't important enough to add the array.

Expected result

Biome shouldn't flag these as issues.

Although maybe it could be a separate rule to enforce all effects to have a dependency arrays.
I don't know if anyone would be interested.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@unvalley unvalley added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Oct 28, 2023
@nissy-dev nissy-dev added the S-Bug-confirmed Status: report has been confirmed as a valid bug label Oct 28, 2023
@ematipico ematipico added S-Needs repro Status: needs a reproduction and removed S-Bug-confirmed Status: report has been confirmed as a valid bug labels Oct 28, 2023
@ematipico
Copy link
Member

@nstepien can you share a reproduction with eslint hooks rule?

@msdlisper
Copy link
Contributor

msdlisper commented Oct 28, 2023

@nstepien can you share a reproduction with eslint hooks rule?

https://stackblitz.com/edit/node-pxeyhl?file=src%2Findex.js
npm run lint

@nstepien
Copy link
Contributor Author

nstepien commented Oct 28, 2023

@ematipico
https://stackblitz.com/edit/node-8xjn11?file=src%2Findex.js
npm run lint
Notice that the rule does not flag hooks with no dependency arrays.

@msdlisper
The issue is that missing dependency arrays should not be flagged as problems.

@msdlisper
Copy link
Contributor

@ematipico https://stackblitz.com/edit/node-8xjn11?file=src%2Findex.js npm run lint Notice that the rule does not flag hooks with no dependency arrays.

@msdlisper The issue is that missing dependency arrays should not be flagged as problems.
Sorry made a mistake, I edit a link again, https://stackblitz.com/edit/node-pxeyhl?file=src%2Findex.js can have a try

@msdlisper
Copy link
Contributor

I have a question, is the final standard for our lint rules ESLint? For example, I think it's better to give hints for this rule, but ESLint does not report errors

@ematipico
Copy link
Member

ematipico commented Oct 30, 2023

I have a question, is the final standard for our lint rules ESLint? For example, I think it's better to give hints for this rule, but ESLint does not report errors

Generally, we should not emit false positive errors compared to the eslint rule, but emitting more information is a nice addendum that is always more than welcome.

Some members of the community suggested splitting the rule in two: #630

@ematipico ematipico added S-Bug-confirmed Status: report has been confirmed as a valid bug and removed S-Needs repro Status: needs a reproduction labels Oct 30, 2023
@kalleep
Copy link
Contributor

kalleep commented Nov 30, 2023

Hey, I can work on this and probably #651 after 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants