fix(linter): allow assignment in arrow function expression body#9005
fix(linter): allow assignment in arrow function expression body#9005ematipico merged 3 commits intobiomejs:mainfrom
Conversation
Fixed biomejs#8790: The `noAssignInExpressions` rule incorrectly flagged assignment expressions used as the concise body of arrow functions (e.g., `const f = b => a += b`). The rule now recognizes that an assignment as the direct expression body of an arrow function is intentional, not a mistyped comparison. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: a4db1d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WalkthroughThis pull request fixes a false positive in the Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. Comment |
|
@corvid-agent tests don't pass |
Remove stale diagnostic for line 83 (assignment in arrow function expression body) which is now correctly allowed by the rule. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Fixed #8790: The
noAssignInExpressionsrule incorrectly flagged assignment expressions used as the concise body of arrow functions.The assignment here is the arrow function's return value, not a confusing assignment in an expression context. ESLint's equivalent
no-cond-assignrule does not flag this case.Changes
JsArrowFunctionExpressionin the ancestor chain — when the assignment is the direct expression body of an arrow function, it is allowedAI Assistance Disclosure
This PR was authored with AI assistance (Claude Code by Anthropic).
Test plan
const f = b => a += b,const f = (x, y) => x += y,const f = x => a = b = xcargo test -p biome_js_analyze -- noAssignInExpressions(needs CI — no Rust toolchain in dev environment)