Skip to content

fix(rule-of-hooks): handle var decl with destructuring#1416

Merged
kt3k merged 2 commits intodenoland:mainfrom
kt3k:fix-rules-of-hooks-var-decl-other
Feb 14, 2025
Merged

fix(rule-of-hooks): handle var decl with destructuring#1416
kt3k merged 2 commits intodenoland:mainfrom
kt3k:fix-rules-of-hooks-var-decl-other

Conversation

@kt3k
Copy link
Member

@kt3k kt3k commented Feb 14, 2025

This PR fixes a case of rule-of-hooks. Currently the example below doesn't produce lint diagnostics because of the handling of var declaration:

function Foo() {
  if (cond) {
    const [state, setState] = useState(0);
  }
}

This PR fixes the above case.

@CLAassistant
Copy link

CLAassistant commented Feb 14, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

LGTM, nice catch

@kt3k kt3k merged commit 05b9f04 into denoland:main Feb 14, 2025
6 checks passed
@kt3k kt3k deleted the fix-rules-of-hooks-var-decl-other branch February 14, 2025 08:15
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.

3 participants