Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom parserOpts for babel parser in @babel/eslint-parser #11423

Closed

Conversation

vikr01
Copy link
Contributor

@vikr01 vikr01 commented Apr 15, 2020

Q                       A
Fixed Issues? N/A
Patch: Bug Fix? N/A
Major: Breaking Change? N/A
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? No
License MIT

The README for @babel/eslint-parser states:

  • babelOptions passes through Babel's configuration loading and merging options (for instance, in case of a monorepo). When not defined, @babel/eslint-parser will use Babel's default configuration file resolution logic.

However, this hasn't exactly been true, because you can't override all of the babel parser's options. With this, there's now capability to use neat features like the flowComments plugin to lint flow comments just like flow typings.

);

normalizedParserOptions.plugins = ["estree", ...parserPlugins];
if (options.allowImportExportEverywhere !== undefined) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if options.allowImportExportEverywhere exists, it'll use that over parserOpts. allowImportExportEverywhere to prevent breaking changes.

parserOpts,
);

normalizedParserOptions.plugins = ["estree", ...parserPlugins];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the "estree" plugin is necessary for the eslint parser here, so I figured we shouldn't override it.

@nicolo-ribaudo nicolo-ribaudo added area: eslint PR: New Feature 🚀 A type of pull request used for our changelog categories labels Apr 16, 2020
@vikr01
Copy link
Contributor Author

vikr01 commented Apr 20, 2020

@danez You reviewed #9168 from me before, might you be able to review this?

I’d ideally like for us to start using this at Facebook. 🙂

@nicolo-ribaudo
Copy link
Member

@vikr01 We might want to do #11334 (comment) instead

@existentialism
Copy link
Member

With this, there's now capability to use neat features like the flowComments plugin to lint flow comments just like flow typings.

Somewhat related, but for those who are using a Babel config, we could always support flowComments by augmenting the flow preset to enable comment parsing and/or a new syntax plugin... then with babel-eslint@11 it'd just read the config?

(And yeah, I guess for the whole "passing config programmatically" story, we should roll with #11334 (comment))

@vikr01
Copy link
Contributor Author

vikr01 commented Apr 21, 2020

@existentialism Agree — I think enabling the flowComments syntax via the flow preset would be nice.

@vikr01
Copy link
Contributor Author

vikr01 commented Apr 21, 2020

@nicolo-ribaudo That looks to be for babel config plugins, this is for the syntax plugins. Don’t the two work differently, or am I mistaken?

@nicolo-ribaudo
Copy link
Member

@vikr01 My proposal was to allow passing a full Babel config, so you will also be able to pass parserOpts without special-casing it in our code.

@JLHwung
Copy link
Contributor

JLHwung commented Mar 2, 2021

In #11639 we allowed pass through all babel options to @babel/eslint-parser. Closing this PR. @vikr01 Thanks for contributing!

@JLHwung JLHwung closed this Mar 2, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: eslint outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants