chore(eslint): enable @eslint-react/use-state rule#1059
Draft
carlosthe19916 wants to merge 4 commits into
Draft
Conversation
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>
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnables the @eslint-react/use-state rule by removing its override in ESLint config and updating React useState usages to follow the rule, primarily by switching to lazy initializers for expensive or non-primitive initial state and suppressing it once for an intentional tuple usage. Sequence diagram for lazy React.useState initialization after ESLint rule enablementsequenceDiagram
participant React
participant useSelectionState
participant doSelect
React->>useSelectionState: render component
useSelectionState->>React: React.useState(() => doSelect(isEqual, items, initialSelected))
React->>doSelect: doSelect(isEqual, items, initialSelected) [initial render]
doSelect-->>React: selectedSet
React-->>useSelectionState: [selectedSet, setSelectedSet]
React->>useSelectionState: re-render component
useSelectionState->>React: React.useState(() => doSelect(isEqual, items, initialSelected))
React-->>useSelectionState: [selectedSet, setSelectedSet] [initializer not re-executed]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1059 +/- ##
==========================================
+ Coverage 50.68% 50.69% +0.01%
==========================================
Files 253 253
Lines 5499 5503 +4
Branches 1660 1660
==========================================
+ Hits 2787 2790 +3
- Misses 2440 2442 +2
+ Partials 272 271 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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: