Enable react-hooks/rules-of-hooks as an error - #5243
Open
tomsmith8 wants to merge 1 commit into
Open
Conversation
Hoist hooks above early returns in ScreenshotModal, ClarifyingQuestionsPreview and WorkflowVersionList, and rename the memo-wrapped LineComponent inner function so the rule recognises it as a component.
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
react-hooks/rules-of-hookswas set to"off"ineslint.config.mjs, which let a conditionaluseMemoship inRecursionBox(since fixed). This turns the rule back on as an error and fixes the 12 existing violations sonpm run lintpasses.Changes
react-hooks/rules-of-hooksfromofftoerrorin the global rules block. The test-file override that disables the rule for__tests__and*.test.*is unchanged.useEffectand its derived index values above theif (!screenshot) return nullguard. The effect now bails when there is no screenshot, matching the previous behaviour.answersandshowReviewstate, the submit-button ref, and its focus effect above the empty-questions early return.expandedGroupsstate above the empty-list early return.groupWorkflowVersionsalready handles an empty array._LineComponenttoLineComponentBase. The leading underscore made the rule treat it as a plain function rather than a component.displayNameand the memo export are unchanged.Verification
npm run lint: 0 errors (265 pre-existing warnings, unchanged).npx tsc --noEmit: no errors in the touched files.