-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Possible to use swc with / for eslint? #246
Comments
It's blocked by #230 (because we can't emit esprima-compatible ast) |
Would be pretty nice if the parser could be turned into a standalone project you can use in other rust projects 👀 |
@ForsakenHarmony Parser is uploaded on crates.io, and it can be built with stable rust. |
I just tried but it seems eslint is expecting something a little bit different than the format returned by
EDIT2: To test with eslint, just create a
Then to debug,
Using @swc/core 1.1.6 and eslint 6.7.2:
as expected, since the tokens array is indeed not where it is supposed to be. |
@kdy1 I'm a bit confused about the status of this, hope you can clarify. (As you might be guessing I'm also super excited about swc use with eslint because of speed). A comment above (#246 (comment)) is mentioning this having been blocked by #230. That issue is closed and merged. Considering the comment above "AST is missing the tokens array." I'm guessing there is more missing? |
It still requires lots of work |
If I got it right #230 would allow to have the needed AST format as an output. as #274 is merged, does this mean this issue is unblocked? What would be the needed next steps? In case it is not unblocked, would something like https://github.com/babel/babel-eslint/tree/master/lib/babylon-to-espree be an intermediate solution? Adapting it to work with the output from swc? Or is there some issue with the format that would make that solution used by babel impossible with swc? |
It's possible, but I'm not sure if it worths |
Can you elaborate more? Do you mean that with #274 it is now natively possible to use swc as a eslint (espree) parser? And if not, what is missing to be done? or do you mean that converting the format in js as it is done with babel is "possible, but not worth it"? Would that be too much work for a possibly small speed improvement? In general I think this is a topic of interest to speed up eslint end if the remaining work to be done is clear maybe easier to get it contributed. |
No, because eslint does not use babel ast. swc-to-espree is not done.
Is eslint slow because of the parser? Note: It can be a huge difference if eslint custom parser api supports asynchronous parser. If it's the case, performance will be improved a lot even if the bottleneck wasn't the parser. |
I started a discussion on eslint about asynchronous parser api. |
It may worth then, but I expect conversion of swc ast -> babel ast -> espree ast to be slow. |
Is there some insight on this? Is there a working solution that could make ESLint work with SWC yet? |
@Extroonie swc has code to produce ESTree AST/ acorn AST, but it's not exposed to js world currently. It will be nice if you can patch it to expose it. |
@kdy1 sorry but I don't quite get that. What do you mean by patching it? Could you walk me through it please? |
@Extroonie I mean adding a method that is callable from js world, like swc/crates/node/src/transform.rs Lines 140 to 157 in a4e93eb
|
@kdy1 thanks. Just want to double-check, the problem I'm having with ESLint and SWC is that some of the code with decorators and other ECMAScript proposals are throwing parser errors with ESLint. Now, I'm not sure whether SWC or ESLint has to deal with it. |
You need to patch both |
@kdy1 I'd love to give it a shot! Which methods of |
@manuschillerdev There's |
In my case, I have just deleted the attribute Then I set up the following config in vscode. "editor.defaultFormatter": "dbaeumer.vscode-eslint",
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
} It works well for me. |
- Due to swc/jest not supporting lint at this time - See: swc-project/swc#246
This comment was marked as spam.
This comment was marked as spam.
Hey everyone! Is anyone still looking into this? I see the issue has been stale for a while and was wondering if we already have it exposed in JS? Really excited about the idea of moving off of @typescript-eslint/parser (as this is the main bottleneck of my current eslint setup) to SWC! cc @kdy1 👀 |
Nope. The linter should be written in Rust to make it performant enough. |
eslint
is a big part of our largest project's build times and it's currently configured to use babel-parser.To get rid of babel entirely it'd be nice to be able to get eslint to use swc somehow:
https://eslint.org/docs/user-guide/configuring#specifying-parser
On an unrelated note, with swc 1.0.21 the project finally builds and seems to mostly work (I haven't looked to closely yet). Thank you for your hard work and the quick responses to bug reports, it's much appreciated!
The text was updated successfully, but these errors were encountered: