Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collect comments around parentheses in expressions (#13803)
Co-authored-by: Brian Ng <bng412@gmail.com>
- Loading branch information
1 parent
7bbdf09
commit 64f14b0
Showing
16 changed files
with
508 additions
and
21 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
.../regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function assertElement(assertFn, shouldBeElement, opt_message) { | ||
return /** @type {!Ele ment} */ ( | ||
assertType_( | ||
assertFn, | ||
shouldBeElement, | ||
isElement(shouldBeElement), | ||
'Element expected', | ||
opt_message | ||
) | ||
); | ||
} | ||
|
||
const slot = /** @type {!HTMLSlotElement} */ (e.target); | ||
|
||
assertElement( | ||
/** @type {Element} */ (el), | ||
); |
4 changes: 4 additions & 0 deletions
4
...ression/comment-before-parentheses-return-arg-createParenthesizedExpressions/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"retainLines": true, | ||
"createParenthesizedExpressions": true | ||
} |
16 changes: 16 additions & 0 deletions
16
...regression/comment-before-parentheses-return-arg-createParenthesizedExpressions/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function assertElement(assertFn, shouldBeElement, opt_message) { | ||
return (/** @type {!Ele ment} */ | ||
assertType_( | ||
assertFn, | ||
shouldBeElement, | ||
isElement(shouldBeElement), | ||
'Element expected', | ||
opt_message)); | ||
|
||
|
||
} | ||
|
||
const slot = /** @type {!HTMLSlotElement} */e.target; | ||
|
||
assertElement( | ||
/** @type {Element} */el); |
17 changes: 17 additions & 0 deletions
17
...s/babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function assertElement(assertFn, shouldBeElement, opt_message) { | ||
return /** @type {!Ele ment} */ ( | ||
assertType_( | ||
assertFn, | ||
shouldBeElement, | ||
isElement(shouldBeElement), | ||
'Element expected', | ||
opt_message | ||
) | ||
); | ||
} | ||
|
||
const slot = /** @type {!HTMLSlotElement} */ (e.target); | ||
|
||
assertElement( | ||
/** @type {Element} */ (el), | ||
); |
13 changes: 13 additions & 0 deletions
13
.../babel-generator/test/fixtures/regression/comment-before-parentheses-return-arg/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function assertElement(assertFn, shouldBeElement, opt_message) { | ||
return ( | ||
/** @type {!Ele ment} */ | ||
assertType_(assertFn, shouldBeElement, isElement(shouldBeElement), 'Element expected', opt_message) | ||
); | ||
} | ||
|
||
const slot = | ||
/** @type {!HTMLSlotElement} */ | ||
e.target; | ||
assertElement( | ||
/** @type {Element} */ | ||
el); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/comments/basic/nested-parentheses/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 + /* 0 */(/* 1 */(/* 2 */(/* 3 */i/* 4 */)/* 5 */)/* 6 */)/* 7 */; |
128 changes: 128 additions & 0 deletions
128
packages/babel-parser/test/fixtures/comments/basic/nested-parentheses/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":68,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":68}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":68,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":68}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":68,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":68}}, | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"start":0,"end":60,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":60}}, | ||
"left": { | ||
"type": "NumericLiteral", | ||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}}, | ||
"extra": { | ||
"rawValue": 1, | ||
"raw": "1" | ||
}, | ||
"value": 1 | ||
}, | ||
"operator": "+", | ||
"right": { | ||
"type": "Identifier", | ||
"start":35,"end":36,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":36},"identifierName":"i"}, | ||
"name": "i", | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 11 | ||
}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 4 ", | ||
"start":36,"end":43,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":43}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 5 ", | ||
"start":44,"end":51,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":51}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 6 ", | ||
"start":52,"end":59,"loc":{"start":{"line":1,"column":52},"end":{"line":1,"column":59}} | ||
} | ||
], | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 0 ", | ||
"start":4,"end":11,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":11}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 1 ", | ||
"start":12,"end":19,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":19}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 2 ", | ||
"start":20,"end":27,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":27}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 3 ", | ||
"start":28,"end":35,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":35}} | ||
} | ||
] | ||
}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 7 ", | ||
"start":60,"end":67,"loc":{"start":{"line":1,"column":60},"end":{"line":1,"column":67}} | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
}, | ||
"comments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 0 ", | ||
"start":4,"end":11,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":11}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 1 ", | ||
"start":12,"end":19,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":19}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 2 ", | ||
"start":20,"end":27,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":27}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 3 ", | ||
"start":28,"end":35,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":35}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 4 ", | ||
"start":36,"end":43,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":43}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 5 ", | ||
"start":44,"end":51,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":51}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 6 ", | ||
"start":52,"end":59,"loc":{"start":{"line":1,"column":52},"end":{"line":1,"column":59}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 7 ", | ||
"start":60,"end":67,"loc":{"start":{"line":1,"column":60},"end":{"line":1,"column":67}} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/babel-parser/test/fixtures/comments/regression/13750/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if (args[0] === 1 || /* istanbul ignore next */ (args[0] === 2 || args[0] === 3)) { | ||
output = args[0] + 10; | ||
} else { | ||
output = 20; | ||
} |
Oops, something went wrong.