babel / babylon

PSA: moved into babel/babel as @babel/parser -->

Home Page:https://github.com/babel/babel/tree/master/packages/babel-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create espree plugin

tunnckoCore opened this issue Β· comments

Hey! πŸ‘‹

I'm just digging around babel-eslint, babylon and eslint. Trying to set up some config for eslint. I always wonder why even babel-eslint exist. Okey, there are reasons, but behind the scenes most of it's code base is that babylon-to-espree, so today i'm thinking why not just include it here? So then we can freely add ESLint parser option to babylon, e.g. "parser": "babylon".

Currently there are three problems: 1) babel-eslint has some bugs and don't have "full" support and configuration of the babylon, 2) eslint can't use babylon only because ranges (which thing is exactly the idea behind babylon-to-espree in the babel-eslint), 3) if eslint use babel-eslint it don't get all of the power of babylon. Or okey, it should, but there are some problems, which i don't want to report, because it may be better to do the effort to PR such plugin.

Do you want PRs here and there for such thing?

Sorry if something isn't clear, i'm a bit tired. ;]

commented

Hey @charlike! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

commented

@charlike no it's a good idea, had a similar thought earlier https://github.com/babel/notes/blob/23a33a109cc230119f7abd1348a0e8c4bed442d3/2017-06/june-21.md#babel-eslint about making an "eslint" plugin but espree works too since it would be the same thing. Yeah basically if we integrate that functionality in babylon itself we don't need babel-eslint to do that much stuff.

Not sure what you mean about the full support/config of babylon though? and babylon does allow ranges as an option https://github.com/babel/babylon#options.

cc @not-an-aardvark @kaicataldo on thoughts?

I'm not talking about making eslint plugin. I'm talking about moving some babel-eslint code here as native babylon's builtin plugin. Babel-eslint then may be just some thin layer for babel-specific things and fixes. In bonus we will can just use babylon as eslint parser.

Not sure what you mean about the full support/config of babylon though? and babylon does allow ranges as an option babel/babylon#options.

I just mean that babel-eslint has too much hardcoded things and some things may not work so well like it would if we just has espree plugin here and use that parser in the eslint directly, not through babel-eslint.

@charlike that is exactly what @hzoo is proposing :)

Possibly add another Babylon plugin for ESLint so that we don't have to mutate the AST afterward, effectively making babel-eslint a minimal wrapper.

He originally proposed an eslint (in this case naming it estree may make more sense) plugin for babylon.

What? πŸ˜† Sorry it's sounds a bit strange to me. Of course it is possible, but then it won't feel as good as defining it through ESLint's parser option ✌️ I see it like needless effort, when we almost have ready esPree plugin for babylon.

commented

@charlike I think you are confused? Brian is saying I proposed the exact same thing you did, I just named it "eslint" instead of "espree"

Doh, probably, i'm a bit tired 🀣 just realised that after rereading it.

cc @not-an-aardvark on thoughts?

Thanks for the ping. In theory it sounds like it would nice to have a way of making babylon produce ESTree, although I think babel-eslint would still be necessary in either case for patching scope analysis. I'm not really familiar enough with babel-eslint's codebase to have a strong opinion one way or the other about whether this is worthwhile.

commented

@not-an-aardvark In theory we should be able to remove everything in https://github.com/babel/babel-eslint/tree/master/babylon-to-espree, the scope stuff is in https://github.com/babel/babel-eslint/blob/master/index.js

(babylon already produces ESTree via the estree plugin) babel/babel-eslint#489

@not-an-aardvark: In theory it sounds like it would nice to have a way of making babylon produce ESTree

it's Babylon's esTree plugin making that? huh. Or you meant esPree. Haha, damn names πŸš€ 🀣

I meant ESTree. I hadn't realized that plugin already exists.

I guess this is already solved, if there are problems with the estree plugin we are happy to accept issues and PRs.

commented

@danez this is for espree not estree. The idea is that we would move logic from babel-eslint into the babylon parser as a plugin, depends on if it's worth doing (possibly)

@hzoo yup.

Yea, it worth.

So please open, i can get something done when get time.