Skip to content

Conversation

@theshadow27
Copy link

@theshadow27 theshadow27 commented Nov 27, 2025

Summary

This PR takes over #8035 which was abandoned. Thanks to @skearya for the initial implementation!

Adds the checkForEach option to the useIterableCallbackReturn rule.

When enabled, .forEach() callbacks will be checked to not return anything. When disabled (default behavior to match ESLint), the callbacks will not be checked. This option exists in the ESLint rule array-callback-return.

Changes Made

  • Added checkForEach option to useIterableCallbackReturn rule
  • Set default to false to match ESLint behavior (based on review feedback)
  • Updated documentation with examples showing the non-default behavior

Test Plan

Tests are included in the original PR and have been verified.

Closes #8024

Co-authored-by: @skearya

🤖 PR Generated with Claude Code

skearya and others added 2 commits November 27, 2025 10:57
- Change default value to false to match ESLint behavior
- Update documentation to show non-default usage examples
- Target next branch for minor release

Co-authored-by: skearya <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Nov 27, 2025

🦋 Changeset detected

Latest commit: 3735ecc

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

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

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 Nov 27, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Walkthrough

This PR adds a checkForEach option to the useIterableCallbackReturn lint rule (default: false). When checkForEach is false the rule skips forEach callbacks; when true it reports forEach callbacks that return values. Changes include: rule logic early-guard for forEach, public options struct update to include check_for_each with accessor and default, and new tests and config files for both true and false settings.

Possibly related PRs

Suggested labels

A-Project, A-Diagnostic

Suggested reviewers

  • dyc3

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a checkForEach option to the useIterableCallbackReturn rule, which is the core focus of this PR.
Description check ✅ Passed The description clearly explains the feature being added, its purpose, default behaviour to match ESLint, and references the related issue it closes.
Linked Issues check ✅ Passed The PR fully addresses issue #8024 by implementing the checkForEach option for useIterableCallbackReturn, aligning with ESLint's array-callback-return rule and setting the default to false as required.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the checkForEach option: rule logic updates, options struct modifications, documentation changes, and comprehensive test coverage.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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)
.changeset/dirty-beans-flash.md (1)

1-5: Tiny tense tweak to better match changeset style (optional)

If you want to hew closer to the “past tense for actions, present for behaviour” guidance, you could rephrase along these lines:

-Closes [#8024](...). Adds the `checkForEach` option to ...
+Closed [#8024](...). Biome now supports the `checkForEach` option in ...

No functional impact, just polish.

crates/biome_rule_options/src/use_iterable_callback_return.rs (1)

6-20: Option wiring looks good; suggest clarifying the field doc

The struct shape and helper method align nicely with the options/merge guidelines: Option<bool> plus a defaulted accessor keeps config merging sane.

You might make the field doc spell out both branches a bit more explicitly:

-    /// When set to `false`, rule will skip reporting `forEach` callbacks that return a value.
+    /// When `true`, the rule reports `forEach` callbacks that return a value.
+    /// When `false` or unset, such callbacks are ignored (default behaviour).

That makes it obvious how “unset” maps onto the effective value.

Based on learnings, this matches the recommended pattern for rule options.

📜 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 a248e88 and 63e7080.

⛔ Files ignored due to path filters (2)
  • 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 (3)
  • .changeset/dirty-beans-flash.md (1 hunks)
  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs (2 hunks)
  • crates/biome_rule_options/src/use_iterable_callback_return.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: Write changeset descriptions that are concise, use past tense for actions, use present tense for Biome behavior, and include code examples for new rules and formatter changes
Use only #### or ##### headers in changeset descriptions to avoid breaking the CHANGELOG and upstream tools

Files:

  • .changeset/dirty-beans-flash.md
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files using just format before committing

Files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use the dbg!() macro for debugging in Rust code, and run tests with --show-output flag to see debug output

Files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
🧠 Learnings (15)
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule option fields should be wrapped in 'Option<_>' to properly track set and unset options during configuration merging

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule option structs must derive 'Deserializable', 'Serialize', 'Deserialize', and optionally 'JsonSchema' traits with serde attributes

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule option fields should use 'Box<[Box<str>]>' instead of 'Vec<String>' for array types to save memory

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-27T15:53:30.817Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T15:53:30.817Z
Learning: Applies to **/crates/biome_analyze/**/*.rs : Update inline rustdoc documentation for rules, assists, and their options when implementing new features or changes

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : The rule option serde configuration must include 'rename_all = "camelCase"' to match biome.json naming conventions

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule option structs must implement the 'biome_deserialize::Merge' trait to handle merging shared and user configurations

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : The rule option serde configuration must include 'deny_unknown_fields' to raise errors for extraneous fields in configuration

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Use 'let else' pattern to reduce code branching when the rule's run function returns 'Vec'

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule options must be defined in the `biome_rule_options` crate in a file matching the rule name (e.g., 'use_this_convention.rs' for rule `useThisConvention`)

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Avoid deep indentation in rule implementations by using Rust helper functions like 'map', 'filter', and 'and_then' instead of nested if-let statements

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rule documentation must have a '## Options' section after the '## Examples' section if the rule supports options, with each option having its own h3 header

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Code blocks in documentation marked with 'options' should contain only rule-specific options in JSON/JSONC format, while 'full_options' contains complete biome.json configuration

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules should only have severity set to 'error' if they report hard errors, dangerous code, or accessibility issues; use 'warn' for possibly erroneous code; use 'info' for stylistic suggestions

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules should be implemented with the 'impl Rule for RuleName' trait, including 'run' function that returns signals and optional 'diagnostic' and 'action' functions

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules ported from other ecosystems should include a 'sources' field in the 'declare_lint_rule!' macro with RuleSource metadata (e.g., '::ESLint')

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
🔇 Additional comments (2)
crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs (2)

83-112: Options docs are clear and match the new behaviour

Nice job wiring the checkForEach section and examples – the narrative around the non‑default true case and the JSON snippet both line up with the runtime semantics.

Based on learnings, this ticks the “document rule options inline” box.


161-163: Early guard for forEach correctly honours checkForEach

The short‑circuit on forEach when checkForEach is false/unset cleanly preserves the old default while letting the map‑driven logic handle the enabled case. No concerns here.

@theshadow27
Copy link
Author

@ematipico do you want tests (crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/ etc) for this? Otherwise I will leave it as-is with just the previous comments addressed.

@dyc3
Copy link
Contributor

dyc3 commented Nov 27, 2025

Yes, there do need to be tests for this.

- Improved changeset wording per style guide
- Clarified option field documentation
- Added test cases for checkForEach option (true/false)

Note: Test snapshots will need to be generated when CI runs
as local Rust toolchain is not available
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

♻️ Duplicate comments (1)
crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.js (1)

1-32: Test coverage looks comprehensive.

Good coverage of forEach behaviors: explicit returns, implicit returns, conditional returns, plus negative cases (no return, void return, empty return).

🧹 Nitpick comments (1)
.changeset/dirty-beans-flash.md (1)

5-5: Consider punctuation and example.

The static analysis tool correctly suggests adding a comma after "By default". Whilst optional for options documentation, a brief code example showing the non-default checkForEach: true usage would help users discover this feature.

Apply this diff:

-Fixed [#8024](https://github.com/biomejs/biome/issues/8024). The rule [`useIterableCallbackReturn`](https://biomejs.dev/linter/rules/use-iterable-callback-return/) now supports a `checkForEach` option. When set to `true`, the rule checks `forEach()` callbacks for returning values. By default (`false`), `forEach()` callbacks are not checked, matching ESLint's behavior.
+Fixed [#8024](https://github.com/biomejs/biome/issues/8024). The rule [`useIterableCallbackReturn`](https://biomejs.dev/linter/rules/use-iterable-callback-return/) now supports a `checkForEach` option. When set to `true`, the rule checks `forEach()` callbacks for returning values. By default, (`false`), `forEach()` callbacks are not checked, matching ESLint's behavior.
+
+```json
+{
+  "linter": {
+    "rules": {
+      "suspicious": {
+        "useIterableCallbackReturn": {
+          "level": "error",
+          "options": { "checkForEach": true }
+        }
+      }
+    }
+  }
+}
+```
📜 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 63e7080 and fe4cc92.

📒 Files selected for processing (6)
  • .changeset/dirty-beans-flash.md (1 hunks)
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json (1 hunks)
  • crates/biome_rule_options/src/use_iterable_callback_return.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files using just format before committing

Files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use the dbg!() macro for debugging in Rust code, and run tests with --show-output flag to see debug output

Files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: Write changeset descriptions that are concise, use past tense for actions, use present tense for Biome behavior, and include code examples for new rules and formatter changes
Use only #### or ##### headers in changeset descriptions to avoid breaking the CHANGELOG and upstream tools

Files:

  • .changeset/dirty-beans-flash.md
🧠 Learnings (20)
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/specs/**/options.json : Create an `options.json` file (formatted as `biome.json`) in test specification folders to apply non-default formatting options to all test files in that folder

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/tests/specs/**/*.{js,ts,tsx,jsx,json,css,graphql} : Test files should use 'invalid' or 'valid' prefixes to indicate whether they contain code reported by the rule

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.js
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.js
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Code blocks in documentation marked with 'options' should contain only rule-specific options in JSON/JSONC format, while 'full_options' contains complete biome.json configuration

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/tests/specs/**/*.{js,ts,tsx,jsx,json,css,graphql} : Test files for rules should be placed inside 'tests/specs/' directory organized by group and rule name (e.g., 'tests/specs/nursery/myRuleName/')

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.js
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 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/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : The 'language' field in 'declare_lint_rule!' should be set to the specific JavaScript dialect (jsx, ts, tsx) if the rule only applies to that dialect, otherwise use 'js'

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
📚 Learning: 2025-11-27T15:53:30.817Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T15:53:30.817Z
Learning: Applies to **/crates/biome_analyze/**/*.rs : Update inline rustdoc documentation for rules, assists, and their options when implementing new features or changes

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule options must be defined in the `biome_rule_options` crate in a file matching the rule name (e.g., 'use_this_convention.rs' for rule `useThisConvention`)

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules ported from other ecosystems should include a 'sources' field in the 'declare_lint_rule!' macro with RuleSource metadata (e.g., '::ESLint')

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : The rule option serde configuration must include 'deny_unknown_fields' to raise errors for extraneous fields in configuration

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-21T01:10:53.059Z
Learnt from: dyc3
Repo: biomejs/biome PR: 8171
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:125-137
Timestamp: 2025-11-21T01:10:53.059Z
Learning: In the Biome codebase, each lint rule has its own options type declaration (e.g., `type Options = RuleNameOptions`) as part of the codegen process, even if the options struct is empty or unused. This is standard practice and should not be flagged as an issue.

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
📚 Learning: 2025-09-25T12:32:59.003Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7593
File: crates/biome_service/src/workspace/server.rs:1306-1306
Timestamp: 2025-09-25T12:32:59.003Z
Learning: In the biomejs/biome project, do not flag compilation errors during code review as they are handled by the existing test infrastructure and CI. Focus on other code quality aspects instead.

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules should only have severity set to 'error' if they report hard errors, dangerous code, or accessibility issues; use 'warn' for possibly erroneous code; use 'info' for stylistic suggestions

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule option fields should be wrapped in 'Option<_>' to properly track set and unset options during configuration merging

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule option fields should use 'Box<[Box<str>]>' instead of 'Vec<String>' for array types to save memory

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule option structs must derive 'Deserializable', 'Serialize', 'Deserialize', and optionally 'JsonSchema' traits with serde attributes

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule option structs must implement the 'biome_deserialize::Merge' trait to handle merging shared and user configurations

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : The rule option serde configuration must include 'rename_all = "camelCase"' to match biome.json naming conventions

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Use 'let else' pattern to reduce code branching when the rule's run function returns 'Vec'

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Avoid deep indentation in rule implementations by using Rust helper functions like 'map', 'filter', and 'and_then' instead of nested if-let statements

Applied to files:

  • crates/biome_rule_options/src/use_iterable_callback_return.rs
🪛 LanguageTool
.changeset/dirty-beans-flash.md

[uncategorized] ~5-~5: Did you mean: “By default,”?
Context: ...Each() callbacks for returning values. By default (false), forEach()` callbacks are no...

(BY_DEFAULT_COMMA)

🔇 Additional comments (4)
crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json (1)

1-15: LGTM!

Configuration correctly sets checkForEach: false to test the default behavior where forEach callbacks aren't checked.

crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json (1)

1-15: LGTM!

Configuration correctly sets checkForEach: true to test the non-default behavior where forEach callbacks are checked.

crates/biome_rule_options/src/use_iterable_callback_return.rs (1)

6-21: Well-structured option implementation!

Correctly uses Option<bool> for configuration merging, includes appropriate serde attributes, provides a sensible default (false), and documents the behavior clearly. The accessor method properly handles the unwrap-or-default pattern.

crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.js (1)

1-32: Based on the learnings provided and the unavailability of the codebase for verification, I can assess the review comment based on documented conventions:

The learnings clearly state that "Test files should use 'invalid' or 'valid' prefixes to indicate whether they contain code reported by the rule." The file checkForEachFalse.js contains a mix of both valid (forEach cases) and invalid (map/filter/every cases) test scenarios, which appears to violate this convention.

However, since I cannot access the codebase to verify whether this is an intentional exception for option-specific test files or if similar patterns exist elsewhere in the project, I cannot definitively resolve whether this is a genuine issue or expected behavior.

Test file naming may violate convention—verify intended pattern.

This file contains both valid forEach callbacks (not reported) and invalid map/filter/every callbacks (should be reported), mixing two categories in one file. Per project conventions, test files should use invalid or valid prefixes to indicate their contents. Either rename this file to clarify its scope or split it into separate invalid_checkForEachFalse.js and valid_checkForEachFalse.js files if both test types are needed.

theshadow27 and others added 2 commits November 27, 2025 16:28
- Split mixed test files into separate invalid/valid files
- All test files now follow the established naming convention
- Tests with options use invalidXxx.js and validXxx.js pattern
This addresses @coderabbitai's comment about test file naming conventions.

The initial implementation used invalid/valid prefixes for option test files
(e.g., invalidCheckForEachFalse.js), which caused test failures because the
test framework expects option-based tests WITHOUT these prefixes.

After analyzing the codebase patterns (especially those by dyc3 and ematipico),
the correct convention for option-based tests is:
- Option test files should NOT use invalid/valid prefixes
- They should describe the configuration (e.g., checkForEachFalse.js)
- They can contain both valid and invalid test cases within the same file

This is different from the base invalid.js/valid.js files which test the
default rule behavior. Option test files test specific configurations and
their naming reflects the option being tested, not the validity of cases.

Tests are now passing locally with this corrected naming convention.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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 2a6a5f4 and 44142b9.

⛔ Files ignored due to path filters (3)
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/invalid.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json (1 hunks)
🧰 Additional context used
🧠 Learnings (12)
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/specs/**/options.json : Create an `options.json` file (formatted as `biome.json`) in test specification folders to apply non-default formatting options to all test files in that folder

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/tests/specs/**/*.{js,ts,tsx,jsx,json,css,graphql} : Test files should use 'invalid' or 'valid' prefixes to indicate whether they contain code reported by the rule

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.js
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.js
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/tests/specs/**/*.{js,ts,tsx,jsx,json,css,graphql} : Test files for rules should be placed inside 'tests/specs/' directory organized by group and rule name (e.g., 'tests/specs/nursery/myRuleName/')

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.js
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.js
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Code blocks in documentation marked with 'options' should contain only rule-specific options in JSON/JSONC format, while 'full_options' contains complete biome.json configuration

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-11-21T01:10:53.059Z
Learnt from: dyc3
Repo: biomejs/biome PR: 8171
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:125-137
Timestamp: 2025-11-21T01:10:53.059Z
Learning: In the Biome codebase, each lint rule has its own options type declaration (e.g., `type Options = RuleNameOptions`) as part of the codegen process, even if the options struct is empty or unused. This is standard practice and should not be flagged as an issue.

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : The 'language' field in 'declare_lint_rule!' should be set to the specific JavaScript dialect (jsx, ts, tsx) if the rule only applies to that dialect, otherwise use 'js'

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Rule options must be defined in the `biome_rule_options` crate in a file matching the rule name (e.g., 'use_this_convention.rs' for rule `useThisConvention`)

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 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/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-09-25T12:32:59.003Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7593
File: crates/biome_service/src/workspace/server.rs:1306-1306
Timestamp: 2025-09-25T12:32:59.003Z
Learning: In the biomejs/biome project, do not flag compilation errors during code review as they are handled by the existing test infrastructure and CI. Focus on other code quality aspects instead.

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules ported from other ecosystems should include a 'sources' field in the 'declare_lint_rule!' macro with RuleSource metadata (e.g., '::ESLint')

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json
  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : The rule option serde configuration must include 'rename_all = "camelCase"' to match biome.json naming conventions

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
📚 Learning: 2025-11-24T18:04:42.160Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:42.160Z
Learning: Applies to crates/biome_analyze/**/biome_*_analyze/lib/src/**/!(mod).rs : Rules should only have severity set to 'error' if they report hard errors, dangerous code, or accessibility issues; use 'warn' for possibly erroneous code; use 'info' for stylistic suggestions

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json
🔇 Additional comments (3)
crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.options.json (1)

1-15: LGTM!

The test configuration correctly enables the checkForEach option.

crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachFalse.options.json (1)

1-15: LGTM!

The explicit false value is helpful for test clarity, even though it matches the default.

crates/biome_js_analyze/tests/specs/suspicious/useIterableCallbackReturn/checkForEachTrue.js (1)

1-29: Test cases are correct, but verify the filename convention.

The test logic properly validates that forEach returns are flagged when checkForEach is true, and correctly identifies valid cases (no return value or empty return for control flow). As with checkForEachFalse.js, verify whether the test framework accepts this naming pattern for files containing both valid and invalid cases.

@theshadow27
Copy link
Author

Yes, there do need to be tests for this.

Tests added and passing locally.

Thanks for your patience and support

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 28, 2025

CodSpeed Performance Report

Merging #8289 will not alter performance

Comparing theshadow27:feat/check-for-each (3735ecc) with next (a248e88)

Summary

✅ 58 untouched
⏩ 95 skipped1

Footnotes

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

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Everything except the docs look good to me. They need to be updated to reflect the new failure. See the rule check CI failure.

The forEach example was expecting a diagnostic but with checkForEach defaulting to false,
it no longer triggers. Changed the example to use filter() which always requires proper
return behavior.
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/suspicious/use_iterable_callback_return.rs (1)

46-48: Option docs are clear; consider tying the forEach sentence to the option

The new ## Options / checkForEach docs are clear and follow the lint doc guidelines (examples + config snippet); nice work.

Very minor: the earlier line “A return value is disallowed in the method forEach.” now only strictly applies when checkForEach is true. You might tweak it to say “when checkForEach is enabled” or move that sentence under the option section to avoid confusing readers skimming only the top.

Also applies to: 83-112

📜 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 44142b9 and 3735ecc.

⛔ Files ignored due to path filters (2)
  • 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 (1)
  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the dbg!() macro for debugging output during testing, and pass the --show-output flag to cargo to view debug output
Use cargo t or cargo test to run tests; for a single test, pass the test name after the test command
Use snapshot testing with the insta crate; run cargo insta accept, cargo insta reject, or cargo insta review to manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Use just f (alias for just format) to format Rust and TOML files before committing

Files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
🧠 Learnings (10)
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Document rules with a one-line brief description in the first paragraph of the doc comment, followed by detailed paragraphs, `## Examples` section with `### Invalid` and `### Valid` subsections, and optional `## Options` section

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Rule diagnostics must explain to the user what the error is, why it is triggered, and what should be done to fix it following the three pillars: (1) what the error is, (2) why the error is triggered, (3) what the user should do

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-28T09:08:10.077Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.077Z
Learning: Applies to .changeset/**/*.md : For new lint rules, show an example of an invalid case in an inline code snippet or code block; for rule changes, demonstrate what is now invalid or valid; for formatter changes, use a `diff` code block

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : In rule documentation code blocks, mark invalid examples with the `expect_diagnostic` property and valid examples without it; each invalid example must emit exactly one diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Set rule severity to `error` for correctness/security/a11y rules, `warn` for suspicious/performance rules, `info` for style/complexity rules, and `info` for actions

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `action` function must return a `JsRuleAction` (or equivalent language-specific action type) with category `ctx.action_category(ctx.category(), ctx.group())` and applicability from `ctx.metadata().applicability()`

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnsafe` prefix for rules that report code leading to runtime failures (e.g., `noUnsafeOptionalChaining`)

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Code actions must specify a `fix_kind` field in the `declare_lint_rule!` macro as either `FixKind::Safe` or `FixKind::Unsafe` to indicate whether fixes always preserve program behavior

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : For rules ported from other ecosystems like ESLint or Clippy, add a `sources` field with `RuleSource` metadata using `.same()` for identical behavior or `.inspired()` for different behavior

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs
🔇 Additional comments (2)
crates/biome_js_analyze/src/lint/suspicious/use_iterable_callback_return.rs (2)

61-63: Updated invalid example now matches the rule’s intent

Swapping the second invalid example to filter keeps the “missing required return” story without involving forEach, which plays nicely with the new option. Looks solid.


161-163: Early-return guard correctly encodes the default behaviour

The short-circuit on forEach when check_for_each() is false cleanly restores ESLint’s default of not checking forEach while still letting the existing method metadata handle the true case. Logic looks sound.

@skearya
Copy link

skearya commented Nov 29, 2025

been busy, thanks for picking this up 🙏

@theshadow27
Copy link
Author

Ugh just noticed the CI failed again on lint. Claude wasn't able to run the linter locally and guessed. I'll try harder, sorry!

Comment on lines +97 to +109
/// ```js,expect_diagnostic,use_options
/// [1, 2, 3].forEach((el) => {
/// return el * 2;
/// });
/// ```
///
/// ```json,use_options
/// {
/// "options": {
/// "checkForEach": true
/// }
/// }
/// ```
Copy link
Member

Choose a reason for hiding this comment

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

Just need to swap the blocks, and it should work

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.

4 participants