@@ -76,8 +76,8 @@ module.exports = {
7676
7777 fixable : "code" ,
7878 messages : {
79- replaced : "Assignment (=) can be replaced with operator assignment ({{operator}}= )." ,
80- unexpected : "Unexpected operator assignment ({{operator}}= ) shorthand."
79+ replaced : "Assignment (=) can be replaced with operator assignment ({{operator}})." ,
80+ unexpected : "Unexpected operator assignment ({{operator}}) shorthand."
8181 }
8282 } ,
8383
@@ -109,11 +109,13 @@ module.exports = {
109109 const operator = expr . operator ;
110110
111111 if ( isCommutativeOperatorWithShorthand ( operator ) || isNonCommutativeOperatorWithShorthand ( operator ) ) {
112+ const replacementOperator = `${ operator } =` ;
113+
112114 if ( astUtils . isSameReference ( left , expr . left , true ) ) {
113115 context . report ( {
114116 node,
115117 messageId : "replaced" ,
116- data : { operator } ,
118+ data : { operator : replacementOperator } ,
117119 fix ( fixer ) {
118120 if ( canBeFixed ( left ) && canBeFixed ( expr . left ) ) {
119121 const equalsToken = getOperatorToken ( node ) ;
@@ -126,7 +128,7 @@ module.exports = {
126128 return null ;
127129 }
128130
129- return fixer . replaceText ( node , `${ leftText } ${ expr . operator } = ${ rightText } ` ) ;
131+ return fixer . replaceText ( node , `${ leftText } ${ replacementOperator } ${ rightText } ` ) ;
130132 }
131133 return null ;
132134 }
@@ -141,7 +143,7 @@ module.exports = {
141143 context . report ( {
142144 node,
143145 messageId : "replaced" ,
144- data : { operator }
146+ data : { operator : replacementOperator }
145147 } ) ;
146148 }
147149 }
0 commit comments