Skip to content

Commit

Permalink
Update: check ternary : even if ? was reported in space-infix-ops (
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Jan 30, 2021
1 parent fb27422 commit 1a078b9
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 10 deletions.
4 changes: 3 additions & 1 deletion lib/rules/space-infix-ops.js
Expand Up @@ -132,7 +132,9 @@ module.exports = {

if (nonSpacedConsequentNode) {
report(node, nonSpacedConsequentNode);
} else if (nonSpacedAlternateNode) {
}

if (nonSpacedAlternateNode) {
report(node, nonSpacedAlternateNode);
}
}
Expand Down
72 changes: 63 additions & 9 deletions tests/lib/rules/space-infix-ops.js
Expand Up @@ -161,15 +161,69 @@ ruleTester.run("space-infix-ops", rule, {
},
{
code: "a?b:c",
output: "a ? b:c",
errors: [{
messageId: "missingSpace",
data: { operator: "?" },
type: "ConditionalExpression",
line: 1,
column: 2,
endColumn: 3
}]
output: "a ? b : c",
errors: [
{
messageId: "missingSpace",
data: { operator: "?" },
type: "ConditionalExpression",
line: 1,
column: 2,
endColumn: 3
},
{
messageId: "missingSpace",
data: { operator: ":" },
type: "ConditionalExpression",
line: 1,
column: 4,
endColumn: 5
}
]
},
{
code: "a? b :c",
output: "a ? b : c",
errors: [
{
messageId: "missingSpace",
data: { operator: "?" },
type: "ConditionalExpression",
line: 1,
column: 2,
endColumn: 3
},
{
messageId: "missingSpace",
data: { operator: ":" },
type: "ConditionalExpression",
line: 1,
column: 6,
endColumn: 7
}
]
},
{
code: "a ?b: c",
output: "a ? b : c",
errors: [
{
messageId: "missingSpace",
data: { operator: "?" },
type: "ConditionalExpression",
line: 1,
column: 3,
endColumn: 4
},
{
messageId: "missingSpace",
data: { operator: ":" },
type: "ConditionalExpression",
line: 1,
column: 5,
endColumn: 6
}
]
},
{
code: "a?b : c",
Expand Down

0 comments on commit 1a078b9

Please sign in to comment.