Skip to content
Permalink
Browse files

Update: improve report location for no-mixed-operators (#12328)

  • Loading branch information
golopot authored and platinumazure committed Oct 21, 2019
1 parent a102eaa commit 349ed6700e1155384597e1e6035550a96cb8a42d
Showing with 16 additions and 16 deletions.
  1. +2 −2 lib/rules/no-mixed-operators.js
  2. +14 −14 tests/lib/rules/no-mixed-operators.js
@@ -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
});
@@ -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 '||'." }
]
},
{
@@ -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 '&&'." }
]
}
]

0 comments on commit 349ed67

Please sign in to comment.
You can’t perform that action at this time.