Skip to content

Commit

Permalink
Update: Indicating the operator in question (#14764)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsmithkc committed Jul 10, 2021
1 parent bba714c commit ddffa8a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/rules/operator-assignment.js
Expand Up @@ -76,8 +76,8 @@ module.exports = {

fixable: "code",
messages: {
replaced: "Assignment can be replaced with operator assignment.",
unexpected: "Unexpected operator assignment shorthand."
replaced: "Assignment (=) can be replaced with operator assignment ({{operator}}=).",
unexpected: "Unexpected operator assignment ({{operator}}=) shorthand."
}
},

Expand Down Expand Up @@ -113,6 +113,7 @@ module.exports = {
context.report({
node,
messageId: "replaced",
data: { operator },
fix(fixer) {
if (canBeFixed(left) && canBeFixed(expr.left)) {
const equalsToken = getOperatorToken(node);
Expand All @@ -139,7 +140,8 @@ module.exports = {
*/
context.report({
node,
messageId: "replaced"
messageId: "replaced",
data: { operator }
});
}
}
Expand All @@ -155,6 +157,7 @@ module.exports = {
context.report({
node,
messageId: "unexpected",
data: { operator: node.operator },
fix(fixer) {
if (canBeFixed(node.left)) {
const firstToken = sourceCode.getFirstToken(node);
Expand Down

0 comments on commit ddffa8a

Please sign in to comment.