babel / babel-eslint

:tokyo_tower: A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)
https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser
MIT License
2.96k stars 208 forks source link

Missing 'ImportExpression' in visitorKeys #837

Closed vilchik-elena closed 4 years ago

vilchik-elena commented 4 years ago

Hi,

When parsing with babel-eslint code containing import() I would expect visitorKeys to contain ImportExpression. Could you clarify why it is not the case?

Using latest babel-eslint 10.1.0

const babel = require('babel-eslint');
const eslint = require('eslint');
const result = babel.parseForESLint("import('moduleName')");
console.log(result.visitorKeys['ImportExpression']); // prints 'undefined'
const wrapped = new eslint.SourceCode("import('moduleName')", result.ast);
console.log(wrapped.visitorKeys['ImportExpression']); // prints [ 'source' ]

Wrapping the result into new SourceCode() resets visitorKeys to some eslint's defaults which contain ImportExpression.

JLHwung commented 4 years ago

It is fixed in https://github.com/babel/babel/pull/10828, babel-eslint will be renamed as @babel/eslint-parser, for which we are still preparing.

vilchik-elena commented 4 years ago

@JLHwung thanks! does it mean that there is no yet release with the fix?

JLHwung commented 4 years ago

@vilchik-elena Yes, we can expect a release soon.

JLHwung commented 4 years ago

Fixed in @babel/eslint-parser 7.11.0, see https://babel.dev/blog/2020/07/13/the-state-of-babel-eslint#the-future for the renaming guide.