babel / babel-eslint

:tokyo_tower: A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)

Home Page:https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node type of JSXText is different from espree

golopot opened this issue · comments

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?

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

@kaicataldo It was 10.0.1

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

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"]} .

@kaicataldo I think the bug is caused by

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