+
Skip to content

Conversation

harxki
Copy link
Contributor

@harxki harxki commented Jul 25, 2025

Summary

Closes #6795

The noUnassignedVariables rule was incorrectly flagging variables used in JSX ref attributes as
unassigned. This occurred because JSX ref attributes were not being recognized as write references in the
semantic analyzer.

This PR fixes the issue by adding proper detection for JSX ref attribute usage, ensuring that variables
assigned to ref props are correctly tracked as write references.

Test Plan

Added test cases in crates/biome_js_analyze/tests/specs/nursery/noUnassignedVariables/valid.jsx to verify
that JSX ref attributes are correctly handled:

export const Bug = () => {
    let value;
    return <div ref={value} />
}

The snapshot test confirms that no diagnostic is generated for this valid usage pattern.

Docs

no-unassigned-variables

Copy link

changeset-bot bot commented Jul 25, 2025

🦋 Changeset detected

Latest commit: ed3684f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Jul 25, 2025
@harxki harxki force-pushed the fix/no-unassigned-variable-jsx-ref branch 2 times, most recently from 6766466 to 05c4ee5 Compare July 25, 2025 06:12
@harxki harxki force-pushed the fix/no-unassigned-variable-jsx-ref branch from 05c4ee5 to cd7b464 Compare July 25, 2025 08:17
@harxki harxki force-pushed the fix/no-unassigned-variable-jsx-ref branch from cd7b464 to ed3684f Compare July 25, 2025 10:50
@siketyan
Copy link
Member

Hmm, I don't think this PR causes the test failure, it can be a flaky test. Let's ignore it for now.

@harxki
Copy link
Contributor Author

harxki commented Jul 25, 2025

Thanks for confirming! I'll mark this as ready for review then.

@harxki harxki marked this pull request as ready for review July 25, 2025 23:56
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Thank you

@ematipico ematipico merged commit 4021165 into biomejs:main Jul 28, 2025
12 of 13 checks passed
@github-actions github-actions bot mentioned this pull request Jul 28, 2025
@timtucker-dte
Copy link

With the "fix", this now flags use of JSX refs under noParameterAssign

@chibicode
Copy link

@timtucker-dte can confirm, posted here #6795 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

noUnassignedVariables doesn't understand JSX ref=

5 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载