Skip to content

chore: add react hooks rules eslint plugin #5209

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

christjt
Copy link
Contributor

@christjt christjt commented Jul 1, 2025

Type of change

Chore

Description 📝

Enable lint plugin for react hooks rules

@christjt christjt requested a review from a team as a code owner July 1, 2025 12:36
Copy link

codecov bot commented Jul 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.71%. Comparing base (3f55655) to head (97ef981).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5209      +/-   ##
==========================================
+ Coverage   60.64%   60.71%   +0.07%     
==========================================
  Files        1145     1145              
  Lines       81747    81613     -134     
  Branches     7014     7006       -8     
==========================================
- Hits        49575    49553      -22     
+ Misses      31989    31845     -144     
- Partials      183      215      +32     
Files with missing lines Coverage Δ
...-tree-view/storybook-cad/cad-tree-view.stories.tsx 0.00% <ø> (ø)
...nts/src/components/Architecture/CommandButtons.tsx 65.90% <ø> (-0.39%) ⬇️
...nts/src/components/Architecture/DropdownButton.tsx 93.16% <ø> (-0.12%) ⬇️
...ents/src/components/Architecture/RevealButtons.tsx 1.44% <ø> (+0.36%) ⬆️
...components/src/components/Architecture/Toolbar.tsx 18.30% <ø> (+3.86%) ⬆️
.../src/components/Architecture/TreeViewContainer.tsx 4.54% <ø> (+1.51%) ⬆️
...Reveal3DResourcesList/hooks/useAllResourcesList.ts 0.00% <ø> (ø)
...ents/RuleBasedOutputs/RuleBasedOutputsSelector.tsx 0.00% <ø> (ø)
...tputs/hooks/useExtractTimeseriesIdsFromRuleSet.tsx 0.00% <ø> (ø)
react-components/src/hooks/network/getModels.ts 4.34% <ø> (+0.50%) ⬆️
... and 1 more

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

nilscognite
nilscognite previously approved these changes Jul 2, 2025
Copy link
Contributor

@nilscognite nilscognite left a comment

Choose a reason for hiding this comment

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

Looks like a good refactor and safer code!

@@ -87,7 +87,7 @@ const DropdownElement = ({
</Button>
</CogsTooltip>
)}>
{command.children.map((child) => createMenuItem(child, setOpen))}
{command.children.map((child) => CreateMenuItem(child, setOpen))}
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem righ to me - CreateMenuItem contains a hook call, and when we call the component like a function like this, the hook will be counted as part of the parent components' hook. That means that if the number or order of commands change for some reason, the number of hook calls in this component will change, and React may explode

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that this may be the case in other components in this PR as well

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.

4 participants