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
add preset and plugins to parser options #11334
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern with this is that adding this means that the team is committed to maintaining use cases for @babel/eslint-parser
outside of it being a tool that allows ESLint to lint files compiled with Babel, which I believe is out of scope for the project. This happened to be a case that was supported before because the plugins were hard coded into the source code (please note that plugins were not configurable before the v11 prereleases).
Given the size of the team, I'm not convinced we should be committing to spending resources that way. I'm curious what the rest of the team thinks regarding this.
@kaicataldo Could we just forward the |
I would say that that's basically exactly what this PR is doing, forwarding more options to Babel's config loading utility... |
@nicolo-ribaudo I think we could. For historical context, here is the discussion where we decided what to include. Are you envisioning we allow all configuration options? As I mentioned above, I believe That being said, I also think it's confusing to cherry pick options that we pass through like we have in the current iteration. |
I'm definitely happy to defer to consensus on this. |
The sole use case for this PR is to simplify linting code that is being compiled with Babel using the same configuration options that Babel itself provides. As described in the babel options documentation, the main options that you use to configure babel are Pretty much every babel config out there is primarily just I know lots of people here are very attached to having Babel configuration always be loaded from a self contained file, but please don't block those of us that want to pass the same Babel configuration programatically from other JavaScript code! :-) |
Sorry, I hadn't seen this comment as it came in while I was writing my own comment. I could see concern at maintaining every option under the sun and having to keep track of them all and keep them in sync. But like I said in my last comment, |
Would it make sense to allow for a full configuration object instead of passing through individual options? So configuration precedence could then be:
Also, thanks for participating in this discussion. Now is the perfect time to get this kind of feedback and figure these APIs out before we finalize them for the next major release. |
What I would really like to avoid is the confusion of having configuration loaded through multiple mechanisms and merged in hard-to-debug ways. i.e. I don't think configuration passed through an |
While presets & plugins are all that my use case requires, I'd lean more towards giving more (all?) options versus limiting to just one (configFile). I totally get what you're saying though about wanting to avoid confusion. In fact for a wide range of (closed source) projects that I maintain for work, we have devised one common configuration file for babel, webpack, eslint, jest etc that makes it easy to configure & update lots of projects at once. The outline of the config file looks like this:
We then have a eslint helper binary that just loads this config file, parses the babel section & eslint section and passes those to the real eslint binary as configuration options. It's pretty cool to build tools that foster/encourage integration between different tools like this, and furthering this aim is what motivated me to make this PR. ;-) |
I see what you mean, but that's how currently other Babel integrations work. If you use Currently, the config precedence is:
(I can't find docs for this; we should write them) |
Understood. In that case, it sounds like passing through a configuration object directly to Babel seems like the option that's the most in line with other tools that integrate with Babel. If the rest of the team is on board with that, I'm 👍 to that. I think I allowing for all options makes more sense than cherry-picking specific configuration options and passing them through. |
Shall I modify this PR to pass through all options, or do you think it makes sense to do that in an entirely separate PR? |
@hzoo @existentialism @JLHwung What's your opinion on this? |
Sorry for my absence - I've been sick. I'm still of the mind that we should pass through the options. |
This makes sense. The parser can export a "recommended" (or maybe "legacy") config that uses the current default options for the parser. |
I don't think we should we do this. Folks should pass through the options they want. |
We should only force-enable the estree parser plugin. |
So, just to be completely clear, I don't think this iteration of this PR is the correct solution. I'm going to take a look at this today and see what this would actually entail. @jharris4 Sorry for all the back and forth. Appreciate you bringing this to our attention! |
@kaicataldo Thanks for considering this! It will be great to have all the babel options available for passthrough. I'm happy to help craft the PR or review if that'd be helpful. |
Closing this now that #11639 has been released. |
Thanks for contributing! |
As described in babel/babel-eslint#784 and #10752 (comment) this PR adds support for the
presets
andplugins
babel options to thebabel-eslint-parser
package.