#21321·eslint

Bug: logical-assignment-operators never autofix introduces a setter call on a short-circuited assignment

Author: torjan0Created Sep 13, 2026Updated Sep 17, 2026
Labelsbugrule

Environment

ESLint 10.10.0 and main commit 45ad79e54a39b54b4ce8eb47e612bd2f72a7a651; Node 22.23.2; Ubuntu.

Parser

Default (Espree).

What did you do?

javascript
const { Linter } = require("eslint");
const vm = require("node:vm");
const code = "var log=[];Object.defineProperty(globalThis,'p',{get(){return 1;},set(v){log.push('set');},configurable:true}); p ||= 2; log.join(',');";
const result = new Linter().verifyAndFix(code, {
  languageOptions: { ecmaVersion: 2022, sourceType: "script" },
  rules: { "logical-assignment-operators": ["error", "never"] }
});
console.log(JSON.stringify(vm.runInNewContext(code)));
console.log(JSON.stringify(vm.runInNewContext(result.output)));

What did you expect?

Both executions should return "": the truthy getter result makes the original assignment short-circuit without calling the setter.

What actually happened?

The fix changes p ||= 2 to p = p || 2, introducing an unconditional setter call. The executions return:

""
"set"

The same effect was reproduced with ??=. These observations use fresh Node VM contexts in script mode.

Link to Minimal Reproducible Example

ESLint Playground

AI acknowledgment

GPT-6 Astra assisted; I manually reviewed this report.