diff --git a/lib/rules/no-ref-as-operand.js b/lib/rules/no-ref-as-operand.js index fb5dc0881..00cdbed09 100644 --- a/lib/rules/no-ref-as-operand.js +++ b/lib/rules/no-ref-as-operand.js @@ -131,8 +131,11 @@ module.exports = { reportIfRefWrapped(node) }, // refValue+=1, refValue-=1, foo+=refValue, foo-=refValue - /** @param {Identifier} node */ + /** @param {Identifier & {parent: AssignmentExpression}} node */ 'AssignmentExpression>Identifier'(node) { + if (node.parent.operator === '=' && node.parent.left !== node) { + return + } reportIfRefWrapped(node) }, // refValue || other, refValue && other. ignore: other || refValue diff --git a/tests/lib/rules/no-ref-as-operand.js b/tests/lib/rules/no-ref-as-operand.js index 50cfd3249..2a6293485 100644 --- a/tests/lib/rules/no-ref-as-operand.js +++ b/tests/lib/rules/no-ref-as-operand.js @@ -121,6 +121,16 @@ tester.run('no-ref-as-operand', rule, { const count = ref count++ `, + ` + import { ref } from 'vue' + const count = ref(0) + foo = count + `, + ` + import { ref } from 'vue' + const count = ref(0) + const foo = count + `, { code: `