Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Node type of JSXText is different from espree #759

Closed
golopot opened this issue Mar 19, 2019 · 5 comments · Fixed by #785
Closed

Node type of JSXText is different from espree #759

golopot opened this issue Mar 19, 2019 · 5 comments · Fixed by #785

Comments

@golopot
Copy link
Contributor

golopot commented Mar 19, 2019

For jsx texts like foo in <>foo</>, espress has type JSXText, while babel-eslint has type Literal.

require("espree").parse("<>foo</>", { ecmaFeatures: { jsx: true } })
  .body[0].expression.children[0].type; // JSXText


require("babel-eslint").parse("<>foo</>")
  .body[0].expression.children[0].type; // Literal

Is this working as intended?

@kaicataldo
Copy link
Member

Can you share what version of babel-eslint you're using?

@golopot
Copy link
Contributor Author

golopot commented Apr 24, 2019

@kaicataldo It was 10.0.1

@kaicataldo
Copy link
Member

Can you confirm this is still an issue with the latest release?

@golopot
Copy link
Contributor Author

golopot commented Apr 24, 2019

Yes the issue still holds in 11.0.0-beta.0 .

require('babel-eslint').parse('<div>foo</div>', {babelOptions: {configFile: "./.babelrc"}} ).body[0].expression.children[0].type

With .babel {"plugins": ["@babel/plugin-syntax-jsx"]} .

@golopot
Copy link
Contributor Author

golopot commented Apr 28, 2019

@kaicataldo I think the bug is caused by

if (path.isJSXText()) {
node.type = "Literal";
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants