chore(eslint): enable @eslint-react/use-state rule - #1059
Merged
carlosthe19916 merged 5 commits intoJul 13, 2026
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnables the @eslint-react/use-state ESLint rule by removing its override and updating React useState usage patterns to use lazy initializers where computation or object construction occurs, while explicitly suppressing the rule for a deliberate tuple-based useState usage in usePersistentState. Sequence diagram for lazy useState initialization after enabling eslint-react-use-statesequenceDiagram
participant useSelectionState
participant React
participant doSelect
useSelectionState->>React: useState(() => doSelect(isEqual, items, initialSelected)
alt [initial render]
React->>doSelect: doSelect(isEqual, items, initialSelected)
doSelect-->>React: selected
React-->>useSelectionState: selectedSet, setSelectedSet
else [subsequent renders]
React-->>useSelectionState: selectedSet, setSelectedSet
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1059 +/- ##
==========================================
+ Coverage 53.30% 53.36% +0.06%
==========================================
Files 270 270
Lines 5878 5877 -1
Branches 1845 1844 -1
==========================================
+ Hits 3133 3136 +3
+ Misses 2441 2437 -4
Partials 304 304
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
carlosthe19916
marked this pull request as draft
May 27, 2026 12:14
Use lazy initial state for useState calls that involve function calls or object construction to prevent re-computation on every render. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
carlosthe19916
force-pushed
the
hotfix/enable-use-state
branch
from
June 1, 2026 11:18
f2e3c60 to
c6e0986
Compare
# Conflicts: # client/src/app/pages/home/watched-sboms-provider.tsx
carlosthe19916
marked this pull request as ready for review
July 1, 2026 11:35
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
usePersistentState, consider wrapping theReact.useState(defaultValue)tuple in a small helper (e.g.createPersistentState(defaultValue)) or a dedicated type alias so the intentional tuple shape is clearer and the eslint-disable comment is less surprising to future readers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `usePersistentState`, consider wrapping the `React.useState(defaultValue)` tuple in a small helper (e.g. `createPersistentState(defaultValue)`) or a dedicated type alias so the intentional tuple shape is clearer and the eslint-disable comment is less surprising to future readers.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
carlosthe19916
enabled auto-merge
July 2, 2026 09:33
# Conflicts: # eslint.config.mjs
…tfix/enable-use-state
stanislavsemeniuk
approved these changes
Jul 13, 2026
kahboom
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@eslint-react/use-stateoverride from ESLint config() => ...) foruseStatecalls that involve function calls or object construction to prevent re-computation on every renderusePersistentStateTest plan
npm run lintpasses with 0 warnings🤖 Generated with Claude Code
Summary by Sourcery
Enable the @eslint-react/use-state rule and update state initialization patterns to comply with it.
Enhancements:
Build: