Skip to content

fix(noUndeclaredVariables): fix false positives for functions and variables defined in vue <script setup> components#9283

Merged
dyc3 merged 3 commits intomainfrom
dyc3/no-undeclared-vars-functions-and-vars
Mar 2, 2026
Merged

fix(noUndeclaredVariables): fix false positives for functions and variables defined in vue <script setup> components#9283
dyc3 merged 3 commits intomainfrom
dyc3/no-undeclared-vars-functions-and-vars

Conversation

@dyc3
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 commented Mar 1, 2026

Summary

In Vue <script setup> components things defined in the top level scope become available in the template section of the component.

Test Plan

Added snapshot tests

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 1, 2026

🦋 Changeset detected

Latest commit: bf1ea4a

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

Copy link
Copy Markdown
Contributor Author

dyc3 commented Mar 1, 2026

@dyc3 dyc3 changed the title fix(noUndeclaredVariables): fix false positives for vue <script setup> components fix(noUndeclaredVariables): fix false positives for functions and variables defined in vue <script setup> components Mar 1, 2026
@github-actions github-actions Bot added the A-Project Area: project label Mar 1, 2026
@dyc3 dyc3 force-pushed the dyc3/no-undeclared-vars-functions-and-vars branch from 4f8f323 to 71662a6 Compare March 1, 2026 18:28
@github-actions github-actions Bot added A-CLI Area: CLI A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Mar 1, 2026
@dyc3 dyc3 force-pushed the dyc3/no-undeclared-vars-functions-and-vars branch from 71662a6 to 1e02bc7 Compare March 1, 2026 18:31
@dyc3 dyc3 marked this pull request as ready for review March 1, 2026 18:31
Comment on lines +348 to +360
&& binding
.declaration()
.map(|d| d.parent_binding_pattern_declaration().unwrap_or(d))
.is_some_and(|d| {
matches!(
d,
AnyJsBindingDeclaration::JsShorthandNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsDefaultImportSpecifier(_)
| AnyJsBindingDeclaration::JsNamespaceImportSpecifier(_)
| AnyJsBindingDeclaration::JsVariableDeclarator(_)
)
});
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not having this condition resulted in some regressions in other CLI tests. Not ideal IMO, but it requires more scrutiny.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d247c0 and bf1ea4a.

📒 Files selected for processing (1)
  • .changeset/better-pets-judge.md

Walkthrough

This PR adds a changeset entry and a new CLI test for Vue SFCs using <script setup>, tightens suppression logic in the no-unused-variables rule so only certain embedded import/variable bindings are treated as defined, and expands embedded-bindings extraction to register functions, classes, TypeScript declarations and namespace imports. Several helper registration methods and tests for these cases were added.

Possibly related PRs

Suggested reviewers

  • ematipico
  • unvalley
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the fix for false positives in noUndeclaredVariables rule for Vue <script setup> components, directly matching the changeset's primary purpose.
Description check ✅ Passed The PR description clearly explains the motivation (Vue <script setup> scope availability) and test approach (snapshot tests), directly relating to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dyc3/no-undeclared-vars-functions-and-vars

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/better-pets-judge.md:
- Line 5: The changeset message currently references "noUnusedVariables" but the
PR and CLI test mention "noUndeclaredVariables"; update the changeset text to
explicitly list the correct rule name(s) — e.g., change "Fixed
noUnusedVariables..." to mention "noUndeclaredVariables" if that’s the actual
fix, or to mention both "noUnusedVariables" and "noUndeclaredVariables" if both
were changed — and ensure the wording matches the PR scope and test names
exactly so release notes are accurate.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e43e730 and 1e02bc7.

⛔ Files ignored due to path filters (1)
  • crates/biome_cli/tests/snapshots/main_cases_vue_cross_language_rules/no_undeclared_variables_script_setup_with_functions_and_vars.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (5)
  • .changeset/better-pets-judge.md
  • crates/biome_cli/tests/cases/mod.rs
  • crates/biome_cli/tests/cases/vue_cross_language_rules.rs
  • crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
  • crates/biome_service/src/workspace/document/services/embedded_bindings.rs

Comment thread .changeset/better-pets-judge.md Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 1, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 156 skipped benchmarks1


Comparing dyc3/no-undeclared-vars-functions-and-vars (bf1ea4a) with main (e43e730)

Open in CodSpeed

Footnotes

  1. 156 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Comment thread .changeset/better-pets-judge.md Outdated
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
@dyc3 dyc3 merged commit 071c700 into main Mar 2, 2026
17 of 18 checks passed
@dyc3 dyc3 deleted the dyc3/no-undeclared-vars-functions-and-vars branch March 2, 2026 13:16
@github-actions github-actions Bot mentioned this pull request Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants