Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Netail
Copy link
Member

@Netail Netail commented Oct 24, 2025

Summary

Port Eslint's no-plusplus

Test Plan

Docs

@changeset-bot
Copy link

changeset-bot bot commented Oct 24, 2025

🦋 Changeset detected

Latest commit: 53cbe69

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 Oct 24, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 24, 2025

CodSpeed Performance Report

Merging #7859 will not alter performance

Comparing Netail:feat/no-increment-decrement (53cbe69) with main (eae6d1c)1

Summary

✅ 53 untouched
⏩ 85 skipped2

Footnotes

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

  2. 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

This pull request introduces the noIncrementDecrement nursery lint rule for JavaScript. The implementation adds the rule logic that flags unary increment (++) and decrement (--) operators, with an option to allow them in for-loop afterthoughts. It includes the rule configuration struct with serialisation support, comprehensive test coverage for both valid and invalid scenarios, and a changeset documenting the patch bump. The rule references ESLint's no-plusplus for parity.

Suggested reviewers

  • dyc3
  • ematipico
  • arendjr

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 PR title "feat(lint): implement noIncrementDecrement" directly and clearly describes the primary change in the changeset. The entire pull request is focused on implementing a new lint rule with this exact name, as evidenced by the new rule implementation files, test cases, and options configuration. The title uses proper conventional commit formatting and avoids vague language, making it immediately clear to reviewers scanning the history what has been added.
Description Check ✅ Passed The PR description's Summary section clearly states "Port Eslint's no-plusplus", which is directly related to the changeset. The raw_summary confirms this PR implements the noIncrementDecrement rule by porting ESLint's no-plusplus rule. Whilst the Test Plan and Docs sections contain only placeholder comments, the Summary provides sufficient context about what the PR accomplishes, and the evaluation criteria indicate that level of detail is not important as long as the description relates to the changeset.
✨ 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 44911bb and 53cbe69.

⛔ Files ignored due to path filters (3)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (6)
  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/invalid.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/valid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/valid.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files before committing (e.g., via just f)

Files:

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

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and their options with inline rustdoc in the Rust source

Files:

  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs
🧠 Learnings (2)
📚 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/noIncrementDecrement/allowForLoopAfterthought/valid.options.json
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/invalid.options.json
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : In declare_lint_rule! macros, set version: "next"

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs
🧬 Code graph analysis (2)
crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (2)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoIncrementDecrementOptions (8263-8268)
crates/biome_analyze/src/rule.rs (1)
  • same (246-251)
crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js (2)
crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/invalid.js (5)
  • foo (1-1)
  • bar (4-4)
  • i (7-7)
  • i (11-11)
  • i (15-15)
crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/valid.js (4)
  • foo (2-2)
  • bar (5-5)
  • i (8-8)
  • i (12-12)
⏰ 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). (12)
  • GitHub Check: autofix
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Check JS Files
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_configuration)
🔇 Additional comments (10)
crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (5)

1-8: LGTM!

Imports are appropriate for the rule implementation.


9-140: Well-documented rule with comprehensive examples.

The rustdoc clearly explains the rationale (ASI hazards) and covers both basic and option-driven usage. Version is correctly set to "next".


142-144: LGTM!

Node union correctly covers both pre-update (++x, --x) and post-update (x++, x--) expressions.


146-177: LGTM!

Rule implementation is clean and correct. Early return for allowed for-loop afterthoughts, and diagnostic message clearly explains the issue and alternative.


179-198: Excellent fix for the comma-sequence handling issue!

The recursive approach correctly handles nested expressions:

  • For i++, j--, it walks from i++JsSequenceExpressionJsForStatement and verifies the sequence is the update.
  • Parenthesised expressions are also handled.
  • Correctly rejects i++ inside function calls or other non-afterthought positions.

This addresses the previously flagged critical issue about comma-separated for-loop updates.

crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/valid.options.json (1)

1-15: LGTM!

Configuration correctly enables allowForLoopAfterthoughts for testing valid afterthought scenarios.

crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/invalid.options.json (1)

1-15: LGTM!

Configuration correctly enables allowForLoopAfterthoughts for testing invalid cases (operators outside afterthoughts).

crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/valid.js (1)

1-20: Comprehensive test coverage for valid afterthought scenarios.

Excellent variety: simple updates, comma sequences, nested parentheses, and complex expression combinations. These correctly exercise the recursive afterthought detection logic.

crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthought/invalid.js (1)

1-29: Well-crafted test cases for invalid operator usage.

Good coverage of edge cases:

  • Operators outside for-loops
  • Operators in wrong for-loop clause (initialiser, condition)
  • Operators in loop body
  • Operators nested in expressions within afterthoughts (lines 27, 29)

These correctly test that the rule only allows operators directly in the afterthought, not arbitrarily nested.

crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js (1)

1-25: LGTM!

Covers essential invalid cases: standalone operators (pre/post increment/decrement) and for-loop scenarios. These should all trigger diagnostics without the allowForLoopAfterthoughts option.


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 (5)
.changeset/cool-drinks-dress.md (1)

1-5: Polish wording; confirm version bump.

Tiny grammar fix and clearer split into two sentences. Also, is “patch” the intended bump for introducing a new rule?

-Added the nursery rule [`noIncrementDecrement`](https://biomejs.dev/linter/rules/no-increment-decrement/), disallows the usage of the unary operators ++ and --.
+Added the nursery rule [`noIncrementDecrement`](https://biomejs.dev/linter/rules/no-increment-decrement/). It disallows the usage of the unary operators ++ and --.

As per coding guidelines

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

1-9: Options struct looks solid; add a top-level rustdoc.

Serde/camelCase and deny_unknown_fields are spot-on. Consider a brief struct doc for rustdoc.

-#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
+#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
+/// Options for the `noIncrementDecrement` rule.
 pub struct NoIncrementDecrementOptions {

Based on learnings

crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js (1)

1-21: Add a couple more invalid shapes (properties/indexing).

To harden coverage, add cases like:

const obj = { c: 0 }; obj.c++;
const arr = [0]; arr[0]++;
(getter()).field--;

These ensure member/indexed updates also trigger diagnostics.

crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.js (1)

18-21: Please add a valid multi-afterthought example with the option.

Include this to ensure comma/sequence updates are accepted:

// Valid
for (let i = 0, j = 10; i < j; i++, j--) {
	doSomething(i, j);
}
crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (1)

166-180: Optional: offer a quick fix to += 1 / -= 1.

Consider adding a safe code action to replace x++x += 1 and --xx -= 1, preserving pre/post semantics where feasible.

📜 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 ee2f5bf and c12501c.

⛔ Files ignored due to path filters (9)
  • 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/noIncrementDecrement/allowForLoopAfterthoughts.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/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 (8)
  • .changeset/cool-drinks-dress.md (1 hunks)
  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/valid.js (1 hunks)
  • crates/biome_rule_options/src/lib.rs (1 hunks)
  • crates/biome_rule_options/src/no_increment_decrement.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: In changesets, only use #### or ##### headers; other header levels are not allowed
Changesets should cover user-facing changes only; internal changes do not need changesets
Use past tense for what you did and present tense for current Biome behavior in changesets
When fixing a bug in a changeset, start with an issue link (e.g., “Fixed #1234: …”)
When referencing a rule or assist in a changeset, include a link to its page on the website
Include code blocks in changesets when applicable to illustrate changes
End every sentence in a changeset with a period

Files:

  • .changeset/cool-drinks-dress.md
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/no_increment_decrement.rs
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.js
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/valid.js
  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.options.json
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Format Rust files before committing (e.g., via just f which formats Rust)
Document rules, assists, and options with inline rustdoc in source

Files:

  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/no_increment_decrement.rs
  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs
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/noIncrementDecrement/allowForLoopAfterthoughts.js
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/valid.js
  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.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/noIncrementDecrement/allowForLoopAfterthoughts.js
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.options.json
🧠 Learnings (5)
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Place per-rule options types in biome_rule_options crate under lib/, one file per rule

Applied to files:

  • crates/biome_rule_options/src/lib.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Derive Serialize, Deserialize, and Deserializable for rule options; add #[serde(rename_all = "camelCase", deny_unknown_fields, default)]

Applied to files:

  • crates/biome_rule_options/src/no_increment_decrement.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : When schema feature is enabled, derive schemars::JsonSchema for options and related enums

Applied to files:

  • crates/biome_rule_options/src/no_increment_decrement.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : In declare_lint_rule! macros, set version: "next"

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs
📚 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/noIncrementDecrement/allowForLoopAfterthoughts.options.json
🧬 Code graph analysis (2)
crates/biome_rule_options/src/no_increment_decrement.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoIncrementDecrementOptions (8263-8268)
crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoIncrementDecrementOptions (8263-8268)
⏰ 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: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Check JS Files
  • GitHub Check: Bench (biome_configuration)
🔇 Additional comments (5)
crates/biome_rule_options/src/lib.rs (1)

107-107: Alphabetical placement looks right; please regen.

Module sits correctly between no_important_styles and no_inferrable_types. As this file is generated, ensure the codegen source emits this too to avoid drift.

crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/valid.js (1)

1-16: Nice baseline coverage.

Covers non-diagnostic update patterns well. No changes requested.

crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.options.json (1)

1-15: Config wiring looks correct.

Key matches the camelCase option and the rule path. All good.

crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (2)

87-131: Docs and behaviour must align.

The docs list for (let i = 0, j = l; i < l; i++, j--) {} as valid with the option, which conflicts with current run() logic. After applying the fix above, the example will match behaviour.


152-164: Fix has a scope issue: would incorrectly allow nested operators.

The proposed ancestors() check is too broad. It would allow j = i++ in the afterthought, but the existing test (allowForLoopAfterthoughts.js line 8) expects that to error.

The option should allow only standalone ++/-- in afterthoughts, not nested in assignments. The fix should either:

  • Check if parent is a SequenceExpression (the specific case for i++, j--), or
  • Only allow direct children of the update expression

Add the sequence test case for (...; ...; i++, j--) to confirm the fix works without breaking the assignment case.

@Netail Netail force-pushed the feat/no-increment-decrement branch from c12501c to cafbc37 Compare October 24, 2025 23:47
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 c12501c and cafbc37.

⛔ Files ignored due to path filters (9)
  • 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/noIncrementDecrement/allowForLoopAfterthoughts.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/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 (8)
  • .changeset/cool-drinks-dress.md (1 hunks)
  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/valid.js (1 hunks)
  • crates/biome_rule_options/src/lib.rs (1 hunks)
  • crates/biome_rule_options/src/no_increment_decrement.rs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/valid.js
🚧 Files skipped from review as they are similar to previous changes (5)
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.js
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noIncrementDecrement/allowForLoopAfterthoughts.options.json
  • crates/biome_rule_options/src/lib.rs
  • .changeset/cool-drinks-dress.md
🧰 Additional context used
📓 Path-based instructions (3)
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_rule_options/src/no_increment_decrement.rs
  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Format Rust files before committing (e.g., via just f which formats Rust)
Document rules, assists, and options with inline rustdoc in source

Files:

  • crates/biome_rule_options/src/no_increment_decrement.rs
  • crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs
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/no_increment_decrement.rs
🧠 Learnings (1)
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Derive Serialize, Deserialize, and Deserializable for rule options; add #[serde(rename_all = "camelCase", deny_unknown_fields, default)]

Applied to files:

  • crates/biome_rule_options/src/no_increment_decrement.rs
🧬 Code graph analysis (2)
crates/biome_rule_options/src/no_increment_decrement.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoIncrementDecrementOptions (8263-8268)
crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoIncrementDecrementOptions (8263-8268)
⏰ 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). (14)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: End-to-end tests
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check JS Files
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: autofix
🔇 Additional comments (4)
crates/biome_rule_options/src/no_increment_decrement.rs (1)

1-9: LGTM!

The options struct is correctly implemented with all required derives and serde attributes. Matches the retrieved learnings and coding guidelines perfectly.

crates/biome_js_analyze/src/lint/nursery/no_increment_decrement.rs (3)

1-8: LGTM!

Imports are clean and appropriate for the rule implementation.


142-144: LGTM!

Node union correctly captures both pre and post update expressions.


166-181: LGTM!

Diagnostic message is clear and provides helpful alternatives. The note about automatic semicolon insertion explains the rationale well.

@Netail Netail force-pushed the feat/no-increment-decrement branch from cafbc37 to 44911bb Compare October 25, 2025 00:07
@dyc3
Copy link
Contributor

dyc3 commented Oct 25, 2025

I kinda like eslint's original name, which for us would be noPlusPlus. No strong feelings tho

@Netail
Copy link
Member Author

Netail commented Oct 25, 2025

I kinda like eslint's original name, which for us would be noPlusPlus. No strong feelings tho

I liked it too, but kind of hints towards only ++, while it also covers --


noPlusPlusMinMin HAHAHA xd

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.

Looking good, nice and simple :)

Comment on lines +7 to +8
/// Allows unary operators ++ and -- in the afterthought (final expression) of a for loop.
pub allow_for_loop_afterthoughts: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

We generally don't add options for new rules, because we want to have concrete use cases and/or actual user demand.

What's the source rule's default behavior for this? I would imagine it would be true. In any case we should adhere to the default behavior of the eslint rule.

Copy link
Member Author

@Netail Netail Oct 27, 2025

Choose a reason for hiding this comment

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

The option originates from the Eslint rule, which by default uses false. The implementation into biome is written in a way it uses unset/null as false, so false as default as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Even if the source rule has options, we still generally don't implement options on the first iteration of a rule.

But this is not necessarily a hard rule. I can see that the actual logic of this option is pretty trivial so I'm fine with leaving it in here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahhh okay, TIL. Thanks :)

@Netail Netail merged commit c600618 into biomejs:main Oct 28, 2025
20 checks passed
@Netail Netail deleted the feat/no-increment-decrement branch October 28, 2025 15:43
@github-actions github-actions bot mentioned this pull request Oct 28, 2025
Conaclos pushed a commit that referenced this pull request Nov 1, 2025
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.

2 participants