Skip to content

Commit ddffa8a

Browse files
authoredJul 10, 2021
Update: Indicating the operator in question (#14764)
1 parent bba714c commit ddffa8a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎lib/rules/operator-assignment.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ module.exports = {
7676

7777
fixable: "code",
7878
messages: {
79-
replaced: "Assignment can be replaced with operator assignment.",
80-
unexpected: "Unexpected operator assignment shorthand."
79+
replaced: "Assignment (=) can be replaced with operator assignment ({{operator}}=).",
80+
unexpected: "Unexpected operator assignment ({{operator}}=) shorthand."
8181
}
8282
},
8383

@@ -113,6 +113,7 @@ module.exports = {
113113
context.report({
114114
node,
115115
messageId: "replaced",
116+
data: { operator },
116117
fix(fixer) {
117118
if (canBeFixed(left) && canBeFixed(expr.left)) {
118119
const equalsToken = getOperatorToken(node);
@@ -139,7 +140,8 @@ module.exports = {
139140
*/
140141
context.report({
141142
node,
142-
messageId: "replaced"
143+
messageId: "replaced",
144+
data: { operator }
143145
});
144146
}
145147
}
@@ -155,6 +157,7 @@ module.exports = {
155157
context.report({
156158
node,
157159
messageId: "unexpected",
160+
data: { operator: node.operator },
158161
fix(fixer) {
159162
if (canBeFixed(node.left)) {
160163
const firstToken = sourceCode.getFirstToken(node);

0 commit comments

Comments
 (0)
Please sign in to comment.