Skip to content

Commit

Permalink
Fixed excessive parentheses (cont.)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsManta committed Nov 19, 2017
1 parent bc87c9f commit b3a9b98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion edge/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,15 @@ function format(content, options = {}) {
inputNode.parent instanceof Stylus.nodes.UnaryOp ||
(
inputNode.nodes.length === 1 &&
inputNode.nodes[0] instanceof Stylus.nodes.BinOp &&
inputNode.parent instanceof Stylus.nodes.BinOp &&
inputNode.parent.op !== '[]' &&
inputNode.parent.op !== '[]='
)
const parentIsNestedExpression =
inputNode.nodes.length === 1 &&
inputNode.parent instanceof Stylus.nodes.Expression &&
(inputNode.parent instanceof Stylus.nodes.Arguments) === false && // Note that `Arguments` type inherits `Expression` type
!(inputNode.parent instanceof Stylus.nodes.Arguments) && // Note that `Arguments` type inherits `Expression` type
inputNode.parent.parent &&
(
inputNode.parent.parent instanceof Stylus.nodes.Ident ||
Expand Down
3 changes: 3 additions & 0 deletions spec/parenthesis/formattingOptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"newLineChar": "\r\n"
}
2 changes: 2 additions & 0 deletions spec/parenthesis/input.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fun(n)
bottom (n - 1) * 2px
3 changes: 3 additions & 0 deletions spec/parenthesis/output.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fun(n) {
bottom: (n - 1) * 2px;
}

0 comments on commit b3a9b98

Please sign in to comment.