Skip to content

fix(lint/js): improve diagnostics for noConstantCondition, useForOf, noRedeclare#9889

Merged
dyc3 merged 1 commit intomainfrom
dyc3/better-rule-diagnostics-2
Apr 10, 2026
Merged

fix(lint/js): improve diagnostics for noConstantCondition, useForOf, noRedeclare#9889
dyc3 merged 1 commit intomainfrom
dyc3/better-rule-diagnostics-2

Conversation

@dyc3
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 commented Apr 9, 2026

Summary

Improved the diagnostics for these rules. Split into separate PRs to hopefully make it a little more reviewable.

Generated by gpt 5.4, but I heavily guided the agent and reviewed all the new diagnostics myself, and did some manual refactors to reduce allocations.

Test Plan

snapshots

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: c7d48f7

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 Apr 9, 2026

@github-actions github-actions Bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Apr 9, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 9, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 196 skipped benchmarks1


Comparing dyc3/better-rule-diagnostics-2 (c7d48f7) with main (1c8e1ef)2

Open in CodSpeed

Footnotes

  1. 196 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.

  2. No successful run was found on main (362b638) during the generation of this report, so 1c8e1ef was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7f9b54a5-f74e-4412-9e98-353c0e43bc9f

📥 Commits

Reviewing files that changed from the base of the PR and between f44d1d9 and c7d48f7.

⛔ Files ignored due to path filters (46)
  • crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/full_support.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_checkstyle/reports_diagnostics_checkstyle_check_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_checkstyle/reports_diagnostics_checkstyle_check_command_file.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_checkstyle/reports_diagnostics_checkstyle_ci_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_checkstyle/reports_diagnostics_checkstyle_lint_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_github/reports_diagnostics_github_check_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_github/reports_diagnostics_github_ci_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_github/reports_diagnostics_github_lint_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_gitlab/reports_diagnostics_gitlab_check_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_gitlab/reports_diagnostics_gitlab_ci_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_gitlab/reports_diagnostics_gitlab_lint_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_json/reports_diagnostics_json_check_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_json/reports_diagnostics_json_check_command_file.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_json/reports_diagnostics_json_ci_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_json/reports_diagnostics_json_lint_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_junit/reports_diagnostics_junit_check_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_junit/reports_diagnostics_junit_check_command_file.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_junit/reports_diagnostics_junit_ci_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_junit/reports_diagnostics_junit_lint_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_rdjson/reports_diagnostics_rdjson_check_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_rdjson/reports_diagnostics_rdjson_check_command_file.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_rdjson/reports_diagnostics_rdjson_ci_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_rdjson/reports_diagnostics_rdjson_lint_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_sarif/reports_diagnostics_sarif_check_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_sarif/reports_diagnostics_sarif_ci_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_sarif/reports_diagnostics_sarif_lint_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_check/check_skip_parse_errors.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_check/lint_error.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_check/lint_error_without_file_paths.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_check/maximum_diagnostics.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_check/print_verbose.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_check/print_verbose_write.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_ci/ci_lint_error.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_ci/ci_skip_parse_errors.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_ci/print_verbose.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_lint/lint_error.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_lint/lint_error_without_file_paths.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_lint/lint_skip_parse_errors.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_lint/maximum_diagnostics.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_lint/print_verbose.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/noConstantCondition/invalid.jsonc.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/style/useForOf/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/invalid-declaration-merging.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/invalid-non-strict-mode.cjs.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/invalid.jsonc.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/invalid.ts.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (6)
  • .changeset/clear-bananas-lie.md
  • .changeset/plain-keys-arrive.md
  • .changeset/yellow-fans-glow.md
  • crates/biome_js_analyze/src/lint/correctness/no_constant_condition.rs
  • crates/biome_js_analyze/src/lint/style/use_for_of.rs
  • crates/biome_js_analyze/src/lint/suspicious/no_redeclare.rs
✅ Files skipped from review due to trivial changes (3)
  • .changeset/clear-bananas-lie.md
  • .changeset/plain-keys-arrive.md
  • .changeset/yellow-fans-glow.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_js_analyze/src/lint/suspicious/no_redeclare.rs
  • crates/biome_js_analyze/src/lint/correctness/no_constant_condition.rs

Walkthrough

Updated diagnostic messages for three linter rules in the analyzer: useForOf, noConstantCondition, and noRedeclare. Each rule’s primary diagnostic text was rewritten and supplemental .note(...) guidance was added to clarify the issue and remediation. Three new Changeset files were added to .changeset/ declaring patch releases for @biomejs/biome that document these diagnostics improvements.

Suggested labels

A-Diagnostic

Suggested reviewers

  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: improving diagnostics for three specific linter rules (noConstantCondition, useForOf, noRedeclare).
Description check ✅ Passed The description clearly explains the motivation (improving diagnostics), mentions the split into separate PRs for reviewability, discloses AI assistance (GPT-5.4 with manual guidance and review), and references the test plan.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dyc3/better-rule-diagnostics-2

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

Copy link
Copy Markdown
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.

A suggestion for the future, when you have these kinds of PRs. I found really useful having a commit for each change.

In this case, have a commit for each diagnostic you update (together with changeset and snapshot). Coding agents are good at that too.

Comment thread crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/full_support.snap Outdated
@dyc3 dyc3 force-pushed the dyc3/better-rule-diagnostics-2 branch from c89f59e to f44d1d9 Compare April 10, 2026 18:02
@dyc3 dyc3 force-pushed the dyc3/better-rule-diagnostics-2 branch from f44d1d9 to c7d48f7 Compare April 10, 2026 18:08
@dyc3
Copy link
Copy Markdown
Contributor Author

dyc3 commented Apr 10, 2026

FYI @ematipico , updated the subsequent PRs in the stack with 1 commit per rule change.

@dyc3 dyc3 merged commit 7ae83f2 into main Apr 10, 2026
19 checks passed
@dyc3 dyc3 deleted the dyc3/better-rule-diagnostics-2 branch April 10, 2026 18:21
@github-actions github-actions Bot mentioned this pull request Apr 10, 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 L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants