-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Public API request] make parseForESLint accept ts.sourceFile #774
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
Comments
I'm working on a toolchain that invokes the TypeScript compiler and also ESLint. Currently both of these tasks perform the full steps of: load source files, tokenize, parse, and perform semantic analysis. This is an expensive operation, so it's unfortunate to do it twice. It seems that we could cut the time in half by sharing the @Quramy Is that the same thing you are proposing here? (I'm unfamiliar with |
Happy to accept a PR for both cases! Quramy has built a ts language server plugin to coordinate linting via the language server instance, instead of installing an eslint plugin. For the case of accepting a typescript-eslint/packages/typescript-estree/src/parser.ts Lines 299 to 309 in 611dff3
For the case of sharing a Our code (as of the commits I merged on the weekend) does a lot of manipulation of this program as well (in order to handle the IDE's persistent state usecase). So you'd probably want something a bit different - a thin wrapper which accepts a set of programs ahead of the lint, and then when asked to parse a file, it iterates over the programs until it finds one that has the file, and then uses the same API above to convert the |
Cool. Should I open a separate issue for my scenario? I might work on this if I get some time. |
You can if you want - there's no huge need to open a new issue. |
I'll tackle the original request of making |
#5892 was merged into the |
I want a public API for TypeScript language service plugin ( this is related to #254 (comment) ).
API proposal
Signature
Expected behavior
This new function should works almost the same as
parseForESLint
. However, the following points are different:result.ast
should be converted by@typescript-eslint/typescript-estree/src/ast-converter
directly.result.services.program
should be undefined ( I want to skip to callcreateProgram
)Motivation
I develop a TypeScript language service plugin to integrate tsserver and ESLint, https://github.com/Quramy/typescript-eslint-language-service.
In tsserver, ts.LanguageService does:
Of course, I can provide a language service plugin using only public
@typescript-eslint/parser
APIs. But they accept only string text. So source code's text would be tokenized twice if using these public APIs. It's so silly.Now I use some internal APIs ( see https://github.com/Quramy/typescript-eslint-language-service/blob/v1.2.3/src/ast-converter.ts#L187 ) for the above performance reason. But depending on them is too fragile.
Please consider it.
Quramy
The text was updated successfully, but these errors were encountered: