Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[estree] attach comments after directives at the end of file (#14920)
Co-authored-by: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
- Loading branch information
1 parent
57d2b47
commit 580d730
Showing
5 changed files
with
126 additions
and
25 deletions.
There are no files selected for viewing
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
4 changes: 4 additions & 0 deletions
4
packages/babel-parser/test/fixtures/estree/directives/interleaved-comments/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,4 @@ | ||
// 1; | ||
"use strict"; | ||
// 2; | ||
"use strict"; |
67 changes: 67 additions & 0 deletions
67
packages/babel-parser/test/fixtures/estree/directives/interleaved-comments/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,67 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":13}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":13}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":6,"end":19,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":13}}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " 2;", | ||
"start":20,"end":25,"loc":{"start":{"line":3,"column":0,"index":20},"end":{"line":3,"column":5,"index":25}} | ||
} | ||
], | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " 1;", | ||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":5,"index":5}} | ||
} | ||
], | ||
"directive": "use strict", | ||
"expression": { | ||
"type": "Literal", | ||
"start":6,"end":18,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":12}}, | ||
"value": "use strict", | ||
"raw": "\"use strict\"" | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":26,"end":39,"loc":{"start":{"line":4,"column":0},"end":{"line":4,"column":13}}, | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " 2;", | ||
"start":20,"end":25,"loc":{"start":{"line":3,"column":0,"index":20},"end":{"line":3,"column":5,"index":25}} | ||
} | ||
], | ||
"directive": "use strict", | ||
"expression": { | ||
"type": "Literal", | ||
"start":26,"end":38,"loc":{"start":{"line":4,"column":0},"end":{"line":4,"column":12}}, | ||
"value": "use strict", | ||
"raw": "\"use strict\"" | ||
} | ||
} | ||
] | ||
}, | ||
"comments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " 1;", | ||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":5,"index":5}} | ||
}, | ||
{ | ||
"type": "CommentLine", | ||
"value": " 2;", | ||
"start":20,"end":25,"loc":{"start":{"line":3,"column":0,"index":20},"end":{"line":3,"column":5,"index":25}} | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/estree/directives/trailing-comment-eof/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,3 @@ | ||
"use strict"; | ||
|
||
/** @external foo */ |
37 changes: 37 additions & 0 deletions
37
packages/babel-parser/test/fixtures/estree/directives/trailing-comment-eof/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,37 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":20}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":20}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": "* @external foo ", | ||
"start":15,"end":35,"loc":{"start":{"line":3,"column":0,"index":15},"end":{"line":3,"column":20,"index":35}} | ||
} | ||
], | ||
"expression": { | ||
"type": "Literal", | ||
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}}, | ||
"value": "use strict", | ||
"raw": "\"use strict\"" | ||
}, | ||
"directive": "use strict" | ||
} | ||
] | ||
}, | ||
"comments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": "* @external foo ", | ||
"start":15,"end":35,"loc":{"start":{"line":3,"column":0,"index":15},"end":{"line":3,"column":20,"index":35}} | ||
} | ||
] | ||
} |