Skip to content

Conversation

kedevked
Copy link
Contributor

@kedevked kedevked commented Sep 26, 2025

Summary

This Pull Request introduces a new lint rule, noRethrowWithoutCause (based on ESLint's preserve-caught-error, which discourages rethrowing a caught error without properly wrapping it in a new Error object and providing the original error as the cause property.

Addresses initial proposal and discussion from: #7469

Copy link

changeset-bot bot commented Sep 26, 2025

🦋 Changeset detected

Latest commit: 8c7bcbd

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-CLI Area: CLI A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Sep 26, 2025
@kedevked kedevked force-pushed the feature/add-no-rethrow-without-cause branch 2 times, most recently from 388088a to 51381cd Compare September 26, 2025 20:39
Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

Walkthrough

Adds a new BIOME nursery lint rule useErrorCause that enforces rethrows inside catch blocks be wrapped with a new Error whose cause references the original caught error. Adds UseErrorCauseOptions (require_catch_parameter / JSON requireCatchParameter, default true). Introduces public types and helpers (State enum, CauseValueCheckResult, is_cause_value_correct_error) and implements the Rule for JsThrowStatement. Exports the new options module from biome_rule_options. Adds test specs (valid/invalid) and option JSONs exercising requireCatchParameter: false.

Suggested reviewers

  • dyc3
  • siketyan

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly communicates the addition of the useErrorCause rule which is the main change in the pull request and follows the conventional commit format, making it clear and relevant to teammates reviewing the history.
Description Check ✅ Passed The description clearly outlines the introduction of the new lint rule, its behaviour, and the basis in an existing ESLint rule, providing context and linking to the proposal issue, which aligns with the changes in the pull request.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81f3dd6 and 8c7bcbd.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
  • GitHub Check: Check JS Files
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_analyze)

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

@kedevked kedevked force-pushed the feature/add-no-rethrow-without-cause branch from 51381cd to 87f4646 Compare September 26, 2025 20:44
@kedevked kedevked changed the title feat: Port preserve-caught-error from eslint (#7469) feat: add noRethrowWithoutCause Rule Sep 26, 2025
Copy link

codspeed-hq bot commented Sep 26, 2025

CodSpeed Performance Report

Merging #7602 will not alter performance

Comparing kedevked:feature/add-no-rethrow-without-cause (8c7bcbd) with main (d6da4d5)

Summary

✅ 53 untouched
⏩ 85 skipped1

Footnotes

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

Copy link
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: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c294644 and 87f4646.

⛔ Files ignored due to path filters (10)
  • crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs is excluded by !**/migrate/eslint_any_rule_to_biome.rs and included by **
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_js_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/valid.js.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (10)
  • .changeset/dull-yaks-poke.md (1 hunks)
  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/valid.js (1 hunks)
  • crates/biome_rule_options/src/lib.rs (1 hunks)
  • crates/biome_rule_options/src/no_rethrow_without_cause.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js
  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.js
  • crates/biome_rule_options/src/no_rethrow_without_cause.rs
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js
  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
**/tests/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place test files under a tests/ directory in each crate

Files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: In changeset files, only use #### or ##### headers; avoid other header levels
Changeset descriptions should use past tense for what you did (e.g., "Added...")
Describe current Biome behavior in present tense within changesets (e.g., "Biome now supports...")
For bug fixes in changesets, start with a link to the issue (e.g., "Fixed #1234: ...")
When referencing rules or assists in changesets, include links to their documentation pages
Include a minimal code block in the changeset when applicable to demonstrate the change
End every sentence in the changeset description with a period

Files:

  • .changeset/dull-yaks-poke.md
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • crates/biome_rule_options/src/no_rethrow_without_cause.rs
  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
  • crates/biome_rule_options/src/lib.rs
🧠 Learnings (10)
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Options types must implement serialization/deserialization and schema support using derives: `Serialize`, `Deserialize`, `Deserializable`, and `#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]`

Applied to files:

  • crates/biome_rule_options/src/no_rethrow_without_cause.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Define per-rule options types in `biome_rule_options` crate (one file per rule, e.g., `lib/use_my_rule.rs`)

Applied to files:

  • crates/biome_rule_options/src/no_rethrow_without_cause.rs
  • crates/biome_rule_options/src/lib.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/**/src/{lint,assist}/**/*.rs : In declare_lint_rule! macros, set `version: "next"` for new or updated rules

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/**/src/{lint,assist}/**/*.rs : When deprecating a rule, add `deprecated: "<reason>"` to `declare_lint_rule!`

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/{lint,assist}/**/*.rs : When banning globals (e.g., `noConsoleLog`), check the semantic model to avoid false positives from locally shadowed bindings

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/**/src/{lint,assist}/**/*.rs : If a rule returns a code action (implements `action`), add `fix_kind` in `declare_lint_rule!` and use `ctx.metadata().applicability()` when building the action

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/**/src/{lint,assist}/**/*.rs : Code blocks in rule docs must specify language; invalid snippets require `expect_diagnostic`; use `options`/`full_options`/`use_options` markers as appropriate

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/specs/html/**/options.json : When non-default formatting options are needed for a test group, place an options.json (biome.json format) alongside the .html files in that folder

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/**/tests/specs/**/*.jsonc : Snapshot test `.jsonc` files must contain an array of code snippets (strings); these run in script mode (no ESM syntax)

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
PR: biomejs/biome#7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (25)
  • GitHub Check: Check Dependencies
  • GitHub Check: Documentation
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test Node.js API
  • GitHub Check: Check JS Files
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: autofix

"noRethrowWithoutCause": {
"level": "error",
"options": {
"requireCatchParameter": false
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix the invalid options toggle.
Both requireCatchParameter option files currently set the flag to false, so the “invalid” suite never runs with the stricter configuration we’re supposedly checking. Let’s switch this one back to true so the unhappy-path specs actually do some work, rather than sipping tea with the happy-path crowd.

-                        "requireCatchParameter": false
+                        "requireCatchParameter": true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"requireCatchParameter": false
"requireCatchParameter": true
🤖 Prompt for AI Agents
In
crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
around line 9, the requireCatchParameter flag is incorrectly set to false which
prevents the “invalid” suite from exercising the stricter rule; edit this JSON
file to set "requireCatchParameter": true so the invalid tests run with the
intended stricter configuration.

@kedevked kedevked force-pushed the feature/add-no-rethrow-without-cause branch from a87dec4 to fe19426 Compare September 28, 2025 13:16
Copy link
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: 0

🧹 Nitpick comments (2)
crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs (2)

175-177: Consider flipping the condition for clarity

The double negative (!options.require_catch_parameter) makes this a bit harder to follow. Consider checking the positive condition first.

-            if !options.require_catch_parameter {
-                return None;
-            }
+            if options.require_catch_parameter {
+                // This is the case `catch {}`.
+                // Any `throw` inside is a problem.
+                return Some(State::NoErrorBinding(throw_statement.range()));
+            }
-            // This is the case `catch {}`.
-            // Any `throw` inside is a problem.
-            Some(State::NoErrorBinding(throw_statement.range()))
+            None

139-164: Consider extracting the cause validation logic

The nested logic for checking the cause property is quite deep and could benefit from extraction into a helper function for better readability and testability.

You could extract this into a helper function like has_valid_cause_property(obj_expr: &JsObjectExpression, catch_error_name: &str) -> bool to make the main logic cleaner.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 87f4646 and fe19426.

⛔ Files ignored due to path filters (10)
  • crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs is excluded by !**/migrate/eslint_any_rule_to_biome.rs and included by **
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_js_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/valid.js.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (10)
  • .changeset/dull-yaks-poke.md (1 hunks)
  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/valid.js (1 hunks)
  • crates/biome_rule_options/src/lib.rs (1 hunks)
  • crates/biome_rule_options/src/no_rethrow_without_cause.rs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • crates/biome_rule_options/src/no_rethrow_without_cause.rs
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/valid.js
  • .changeset/dull-yaks-poke.md
🧰 Additional context used
📓 Path-based instructions (4)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js
**/tests/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place test files under a tests/ directory in each crate

Files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/invalid.js
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
  • crates/biome_rule_options/src/lib.rs
🧠 Learnings (8)
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/**/tests/specs/**/*.jsonc : Snapshot test `.jsonc` files must contain an array of code snippets (strings); these run in script mode (no ESM syntax)

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/specs/html/**/options.json : When non-default formatting options are needed for a test group, place an options.json (biome.json format) alongside the .html files in that folder

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
PR: biomejs/biome#7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.valid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/**/src/{lint,assist}/**/*.rs : In declare_lint_rule! macros, set `version: "next"` for new or updated rules

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/**/src/{lint,assist}/**/*.rs : When deprecating a rule, add `deprecated: "<reason>"` to `declare_lint_rule!`

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/{lint,assist}/**/*.rs : When banning globals (e.g., `noConsoleLog`), check the semantic model to avoid false positives from locally shadowed bindings

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/**/src/{lint,assist}/**/*.rs : If a rule returns a code action (implements `action`), add `fix_kind` in `declare_lint_rule!` and use `ctx.metadata().applicability()` when building the action

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Define per-rule options types in `biome_rule_options` crate (one file per rule, e.g., `lib/use_my_rule.rs`)

Applied to files:

  • crates/biome_rule_options/src/lib.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs (1)
crates/biome_analyze/src/rule.rs (3)
  • recommended (554-557)
  • sources (569-572)
  • same (241-246)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (25)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test Node.js API
  • GitHub Check: Check JS Files
  • GitHub Check: autofix
🔇 Additional comments (3)
crates/biome_js_analyze/tests/specs/nursery/noRethrowWithoutCause/requireCatchParameter.invalid.options.json (1)

9-9: Set the invalid config back to requireCatchParameter true.
With this flag stuck on false, the “invalid” suite never actually tests the stricter catch-parameter requirement, so regressions can wander in unchallenged. Let’s flip it back to true so the unhappy path does its job.

-                        "requireCatchParameter": false
+                        "requireCatchParameter": true
crates/biome_js_analyze/src/lint/nursery/no_rethrow_without_cause.rs (2)

56-62: LGTM! Well-structured rule declaration

Good use of the declare_lint_rule! macro with appropriate metadata. The ESLint source reference is properly configured.

Based on learnings


115-118: Direct rethrow still slips past the rule

When the catch block does a plain throw err;, we're returning None and not flagging it as a violation. This means direct rethrows go undetected, which defeats the purpose of the lint rule. We should emit State::WithoutCause for any non-new expression instead of bailing out.

Apply this fix to catch direct rethrows:

                    let Some(new_expression) = thrown_expression.as_js_new_expression() else {
-                        // Not a `new` expression, so the rule does not apply. This handles `throw e;` cases.
-                        return None;
+                        return Some(State::WithoutCause(throw_statement.range()));
                    };

@siketyan
Copy link
Member

Personally I would suggest useErrorCause as the rule name, which is shorter and much clear. I am open to hear other opinions!

@kedevked kedevked force-pushed the feature/add-no-rethrow-without-cause branch from e0d5184 to 03285cd Compare October 3, 2025 22:01
@kedevked kedevked changed the title feat: add noRethrowWithoutCause Rule feat: add useErrorCause Rule Oct 3, 2025
@kedevked
Copy link
Contributor Author

kedevked commented Oct 3, 2025

Personally I would suggest useErrorCause as the rule name, which is shorter and much clear. I am open to hear other opinions!

Done

@dyc3
Copy link
Contributor

dyc3 commented Oct 4, 2025

I would suggest useErrorCause as the rule name

I concur, that's better than the ones i suggested in the original issue

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.

The implementation looks good, however, the documentation and tests need some work. I pointed out the areas to address

---
"@biomejs/biome": patch
---
Added the lint rule `useErrorCause`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Added the lint rule `useErrorCause`.
Added the nursery lint rule `useErrorCause`.

- `requireCatchParameter`: (default: `true`)
- When `true`, the rule requires that `catch` clauses have a parameter. If a `throw` statement appears inside a `catch` clause without a parameter, it will be flagged.

#### Invalid
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#### Invalid
**Invalid examples**:

}
```

#### Valid
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#### Valid
**Valid examples:**

}
```

#### `requireCatchParameter: false`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#### `requireCatchParameter: false`
**Valid example** when `requireCatchParameter` is `false`:

Comment on lines +54 to +55
/// ```
///
Copy link
Member

Choose a reason for hiding this comment

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

The documentation doesn't explain and test the option requireCatchParameter. See the format for options: https://github.com/biomejs/biome/blob/main/crates/biome_analyze/CONTRIBUTING.md#general-structure

@@ -0,0 +1,13 @@

Copy link
Member

Choose a reason for hiding this comment

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

Notice that this doesn't emit any diagnostics. Add /* should emit diagnostics */ at the beginning of the file and fix the issue

@@ -0,0 +1,42 @@

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// should generate diagnostics

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
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: 2

♻️ Duplicate comments (2)
crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1)

161-164: Critical: Direct rethrows are not being flagged.

The code returns None for non-new expressions, which means direct rethrows like throw err; won't emit diagnostics. This contradicts the rule's core purpose: ensuring errors are wrapped with a cause.

A past review comment indicated this was addressed in commit fe19426, but the current code still has the problematic pattern. The test file requireCatchParameter.invalid.js expects these cases to emit diagnostics, creating an inconsistency.

Apply this diff to flag direct rethrows:

 let Some(new_expression) = thrown_expression.as_js_new_expression() else {
-    // Not a `new` expression, so the rule does not apply. This handles `throw e;` cases.
-    return None;
+    return Some(State::WithoutCause(throw_statement.range()));
 };
crates/biome_js_analyze/tests/specs/nursery/useErrorCause/requireCatchParameter.invalid.js (1)

1-1: Minor wording inconsistency.

The comment says "should generate diagnostics", but the past review comment requested "should emit diagnostics". Whilst functionally equivalent, consistency with the requested wording would be clearer.

Apply this diff:

-/* should generate diagnostics */
+/* should emit diagnostics */
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03285cd and 27f1fb7.

⛔ Files ignored due to path filters (5)
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useErrorCause/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useErrorCause/requireCatchParameter.invalid.js.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (4)
  • .changeset/dull-yaks-poke.md (1 hunks)
  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/useErrorCause/invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/useErrorCause/requireCatchParameter.invalid.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_js_analyze/tests/specs/nursery/useErrorCause/invalid.js
  • .changeset/dull-yaks-poke.md
🧰 Additional context used
📓 Path-based instructions (5)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
  • crates/biome_js_analyze/tests/specs/nursery/useErrorCause/requireCatchParameter.invalid.js
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
  • crates/biome_js_analyze/tests/specs/nursery/useErrorCause/requireCatchParameter.invalid.js
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Before committing, format Rust and TOML files (e.g., via just f/just format)

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and options via inline rustdoc in Rust source

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
**/tests/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place test files under a tests/ directory in each crate

Files:

  • crates/biome_js_analyze/tests/specs/nursery/useErrorCause/requireCatchParameter.invalid.js
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • UseErrorCauseOptions (8253-8258)
🔇 Additional comments (1)
crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1)

64-100: Excellent documentation of the requireCatchParameter option.

The option is now thoroughly documented with clear examples showing both the default behaviour and how to disable it. This addresses the previous review feedback.

Comment on lines 3 to 30
try {
throw new Error("Original error");
} catch (err) {
throw err;
}


try {
throw new Error("Original error");
} catch (err) {
throw new Error("Wrapper error");
}


try {
throw new Error("Original error");
} catch (err) {
throw new Error(`Failed: ${err.message}`);
}


try {
throw new Error("Original error");
} catch (err) {
if (true) {
throw err;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Test expectations don't match implementation behaviour.

Lines 6 and 28 contain direct rethrows (throw err;), which the test expects to flag. However, the current implementation at lines 161-164 of use_error_cause.rs returns None for non-new expressions, so these cases won't emit diagnostics.

This contradicts both the rule's purpose and a past review comment that claimed this was fixed in commit fe19426. Either the implementation needs fixing (which it does), or these test cases should be moved to a valid file.

@kedevked kedevked requested a review from ematipico October 11, 2025 14:53
@kedevked kedevked force-pushed the feature/add-no-rethrow-without-cause branch from dced3c4 to 4183114 Compare October 11, 2025 15:00
Copy link
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: 0

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1)

11-15: Consider clarifying the rule description.

The phrasing "Disallow rethrowing caught errors without wrapping them" might suggest direct rethrows (throw err;) are forbidden, but the rule actually only checks wrapped errors. Consider: "When rethrowing a caught error by wrapping it in a new Error, ensure the original error is preserved using the cause property."

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4183114 and 466faf7.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Before committing, format Rust and TOML files (e.g., via just f/just format)

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and options via inline rustdoc in Rust source

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • UseErrorCauseOptions (8273-8278)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: End-to-end tests
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
  • GitHub Check: Check JS Files
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_analyze)
🔇 Additional comments (8)
crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (8)

1-9: Imports look good.

Clean set of imports for the rule implementation.


124-133: State enum is well-designed.

Clear variants for each diagnostic scenario, with appropriate range tracking.


152-168: Scope checking logic is sound.

Correctly identifies nested functions, methods, and classes to avoid false positives when throw statements are in independent error contexts.


178-181: Direct rethrow handling is correct.

Returning None for direct rethrows (throw err;) is appropriate, as this rule focuses on wrapped errors. The inline comment clearly explains the intent.


202-230: Property iteration handles edge cases defensively.

The loop continues when finding an incorrect cause to check for potential duplicates, which prevents crashes on malformed code.


241-247: Option handling is correct.

The requireCatchParameter check properly gates the NoErrorBinding diagnostic, allowing empty catch blocks when the option is disabled.


250-293: Diagnostics are clear and helpful.

The messages guide users to fix the issue, and ShadowedCause helpfully shows where the original binding is declared.


301-324: Binding validation logic is solid and edge-case tests cover both err.message (property-access) and mismatched identifier (error) scenarios.

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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 466faf7 and e5f65f7.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Before committing, format Rust and TOML files (e.g., via just f/just format)

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and options via inline rustdoc in Rust source

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • UseErrorCauseOptions (8273-8278)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Check JS Files
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
🔇 Additional comments (5)
crates/biome_js_analyze/src/lint/nursery/use_error_cause.rs (5)

1-9: LGTM – imports are appropriate.

Standard dependencies for a semantic lint rule.


10-121: Well-documented rule with clear examples.

The option documentation (lines 76-112) properly addresses the earlier review feedback.


123-132: State enum variants are appropriate.


177-180: Verify whether direct rethrows should be flagged.

A past review comment (marked as addressed in commit fe19426) indicated that throw err; should return State::WithoutCause rather than None, yet the current code still returns None. This means direct rethrows go unflagged.

If the rule's intent is to require wrapping all rethrows (not just detecting missing cause in wrapped throws), this is a critical regression. If direct rethrows are intentionally allowed, the past review comment was incorrect.

Could you clarify the intended behaviour and verify whether the fix was inadvertently reverted?


249-292: Diagnostic messages are clear and helpful.

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

Labels

A-CLI Area: CLI A-Diagnostic Area: diagnostocis 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.

4 participants