Skip to content

Commit

Permalink
Update: improve report location for no-mixed-operators (#12328)
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot authored and platinumazure committed Oct 21, 2019
1 parent a102eaa commit 349ed67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/rules/no-mixed-operators.js
Expand Up @@ -197,13 +197,13 @@ module.exports = {

context.report({
node: left,
loc: getOperatorToken(left).loc.start,
loc: getOperatorToken(left).loc,
message,
data
});
context.report({
node: right,
loc: getOperatorToken(right).loc.start,
loc: getOperatorToken(right).loc,
message,
data
});
Expand Down
28 changes: 14 additions & 14 deletions tests/lib/rules/no-mixed-operators.js
Expand Up @@ -64,8 +64,8 @@ ruleTester.run("no-mixed-operators", rule, {
{
code: "a && b || c",
errors: [
{ column: 3, message: "Unexpected mix of '&&' and '||'." },
{ column: 8, message: "Unexpected mix of '&&' and '||'." }
{ column: 3, endColumn: 5, message: "Unexpected mix of '&&' and '||'." },
{ column: 8, endColumn: 10, message: "Unexpected mix of '&&' and '||'." }
]
},
{
Expand Down Expand Up @@ -110,48 +110,48 @@ ruleTester.run("no-mixed-operators", rule, {
code: "a + b - c",
options: [{ allowSamePrecedence: false }],
errors: [
{ column: 3, message: "Unexpected mix of '+' and '-'." },
{ column: 7, message: "Unexpected mix of '+' and '-'." }
{ column: 3, endColumn: 4, message: "Unexpected mix of '+' and '-'." },
{ column: 7, endColumn: 8, message: "Unexpected mix of '+' and '-'." }
]
},
{
code: "a * b / c",
options: [{ allowSamePrecedence: false }],
errors: [
{ column: 3, message: "Unexpected mix of '*' and '/'." },
{ column: 7, message: "Unexpected mix of '*' and '/'." }
{ column: 3, endColumn: 4, message: "Unexpected mix of '*' and '/'." },
{ column: 7, endColumn: 8, message: "Unexpected mix of '*' and '/'." }
]
},
{
code: "a || b ? c : d",
options: [{ groups: [["&&", "||", "?:"]] }],
errors: [
{ column: 3, message: "Unexpected mix of '||' and '?:'." },
{ column: 8, message: "Unexpected mix of '||' and '?:'." }
{ column: 3, endColumn: 5, message: "Unexpected mix of '||' and '?:'." },
{ column: 8, endColumn: 9, message: "Unexpected mix of '||' and '?:'." }
]
},
{
code: "a && b ? 1 : 2",
options: [{ groups: [["&&", "||", "?:"]] }],
errors: [
{ column: 3, message: "Unexpected mix of '&&' and '?:'." },
{ column: 8, message: "Unexpected mix of '&&' and '?:'." }
{ column: 3, endColumn: 5, message: "Unexpected mix of '&&' and '?:'." },
{ column: 8, endColumn: 9, message: "Unexpected mix of '&&' and '?:'." }
]
},
{
code: "x ? a && b : 0",
options: [{ groups: [["&&", "||", "?:"]] }],
errors: [
{ column: 3, message: "Unexpected mix of '?:' and '&&'." },
{ column: 7, message: "Unexpected mix of '?:' and '&&'." }
{ column: 3, endColumn: 4, message: "Unexpected mix of '?:' and '&&'." },
{ column: 7, endColumn: 9, message: "Unexpected mix of '?:' and '&&'." }
]
},
{
code: "x ? 0 : a && b",
options: [{ groups: [["&&", "||", "?:"]] }],
errors: [
{ column: 3, message: "Unexpected mix of '?:' and '&&'." },
{ column: 11, message: "Unexpected mix of '?:' and '&&'." }
{ column: 3, endColumn: 4, message: "Unexpected mix of '?:' and '&&'." },
{ column: 11, endColumn: 13, message: "Unexpected mix of '?:' and '&&'." }
]
}
]
Expand Down

0 comments on commit 349ed67

Please sign in to comment.