Empty lines are missing in parsed AST
See original GitHub issueRelated https://github.com/mdx-js/eslint-mdx/issues/217
Subject of the issue
Consider code like following:
<div>
<a>Test</a>
</div>
The parsedd AST is:
{
"type": "root",
"children": [
{
"type": "jsx",
"value": "<div>",
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 1,
"column": 6,
"offset": 5
},
"indent": []
}
},
{
"type": "jsx",
"value": "<a>Test</a>",
"position": {
"start": {
"line": 3,
"column": 1,
"offset": 7
},
"end": {
"line": 3,
"column": 12,
"offset": 18
},
"indent": []
}
},
{
"type": "jsx",
"value": "</div>",
"position": {
"start": {
"line": 5,
"column": 1,
"offset": 20
},
"end": {
"line": 5,
"column": 7,
"offset": 26
},
"indent": []
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 6,
"column": 1,
"offset": 27
}
}
}
There is no \n
node in the children
property.
When using other parsers like babel
, they are remained correctly: babel AST
My expected AST:
{
"type": "root",
"children": [
{
"type": "jsx",
"value": "<div>",
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 1,
"column": 6,
"offset": 5
},
"indent": []
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 1,
"column": 6,
"offset": 5
},
"end": {
"line": 3,
"column": 1,
"offset": 7
},
"indent": []
}
},
{
"type": "jsx",
"value": "<a>Test</a>",
"position": {
"start": {
"line": 3,
"column": 1,
"offset": 7
},
"end": {
"line": 3,
"column": 12,
"offset": 18
},
"indent": []
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 3,
"column": 12,
"offset": 18
},
"end": {
"line": 5,
"column": 1,
"offset": 20
},
"indent": []
}
},
{
"type": "jsx",
"value": "</div>",
"position": {
"start": {
"line": 5,
"column": 1,
"offset": 20
},
"end": {
"line": 5,
"column": 7,
"offset": 26
},
"indent": []
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 6,
"column": 1,
"offset": 27
}
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
TypeScript AST transformation removes all blank lines
My issue is that after running ts.transform(...) and than convert transformed syntax tree back to text all empty lines are missing making the ......
Read more >Blank lines in the body of messages are missing #31 - GitHub
with the ARTICLE command I cannot parse the content (a blank line is supposed to separate the headers and the body); because of...
Read more >v3.20 on Windows not showing empty lines - meld - GitLab
Using Meld 3.20.2 Windows (current latest MSI) When diffing two files that have blank lines, those blank lines aren't shown.
Read more >ast — Abstract Syntax Trees — Python 3.11.1 documentation
An abstract syntax tree can be generated by passing ast.PyCF_ONLY_AST as a flag to the compile() built-in function, or using the parse() helper...
Read more >how to skip incomplete and missing lines when reading from ...
Empty lines are skipped. The real trouble is reading the incomplete lines. I suggest to read each line in as a string, and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To clarify with an example, this doesn’t include the whitespace between blocks either: https://astexplorer.net/#/gist/11d0f7a6b98f4bb7dd69d1ed2db21f74/f969c99364f251942156e78f17f7f5d29665b117
close in favor of https://github.com/mdx-js/eslint-mdx/pull/218 released