Closed gkz closed 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.
Hi @kaicataldo, now that the holiday season has passed, I was wondering if you'd be willing to take another look at this.
@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!
Though, actually, this should already work in the latest version. Adding these tests could be helpful though.
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
@gkz The latest version reads your Babel config at parse time, so if Babel is able to parse it, ESLint should also.
@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.
I realized I need to add EnumDeclarations to the scope analysis - will update the PR soon
I have updated the test
Do we also need to update the peer dependency on @babel/core
?
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.
Ah right, this is in v10. Got it :+1:
Thanks for contributing!
Thanks for merging!
Published in babel-eslint@10.1.0
.
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.