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

Update Babel to ^7.7.0 and enable Flow enums parsing #812

Closed gkz closed 4 years ago

gkz commented 4 years ago

The ability to parse Flow enums was added in Babel 7.7.0. It sits behind an option "enums" for the flow Babel plugin.

Update the Babel dependency to ^7.7.0, fix a small test issue, then enable enums: true.

I understand that we wouldn't need to do this with the 11.x series of babel-eslint because Babel is a peer dependency in 11.x, but that's still in beta and not officially released, so that's why I'm opening up a PR for the 10.x series.

gkz commented 4 years ago

The support for parsing enums should not be breaking, since enum is a "future reserved word" and its usage was previously a parse error.

gkz commented 4 years ago

Hi @kaicataldo, now that the holiday season has passed, I was wondering if you'd be willing to take another look at this.

kaicataldo commented 4 years ago

@gkz Would you be willing to make this PR over in https://github.com/babel/babel/tree/master/eslint/babel-eslint-parser? I'm working to get babel-eslint back to a sane state for the Babel v8 release, and doing all active development there now. Thanks!

kaicataldo commented 4 years ago

Though, actually, this should already work in the latest version. Adding these tests could be helpful though.

gkz commented 4 years ago

We need to add the "flow" plugin to the parser options (to be able to parse Flow code), and add the enums: true flow plugin option to parse neums.

I'll take a look

kaicataldo commented 4 years ago

@gkz The latest version reads your Babel config at parse time, so if Babel is able to parse it, ESLint should also.

gkz commented 4 years ago

@kaicataldo We are blocked on launching the enums feature because of lack of Eslint support. @babel/eslint-parser has not been released yet. I would appreciate it if you would consider merging this and releasing 10.0.4. Since the version of @babel/parser is specified as ^7.0.0, anyone installing babel-eslint will get the latest version of Babel parser already, so the only change in this PR is adding {enums: true}. Since enum is a reserved word, any usage would be a parse error.

gkz commented 4 years ago

I realized I need to add EnumDeclarations to the scope analysis - will update the PR soon

gkz commented 4 years ago

I have updated the test

kaicataldo commented 4 years ago

Do we also need to update the peer dependency on @babel/core?

nicolo-ribaudo commented 4 years ago

No, it would be a breaking change. If someone is using an old version of Babel, this PR is a noop but doesn't do any harm.

kaicataldo commented 4 years ago

Ah right, this is in v10. Got it :+1:

kaicataldo commented 4 years ago

Thanks for contributing!

gkz commented 4 years ago

Thanks for merging!

kaicataldo commented 4 years ago

Published in babel-eslint@10.1.0.