Skip to content

[Public API request] make parseForESLint accept ts.sourceFile  #774

@Quramy

Description

@Quramy

I want a public API for TypeScript language service plugin ( this is related to #254 (comment) ).

API proposal

Signature

parseForESLintFromSourceFile(
    sourceFile: ts.sourceFile,
    options?: ParserOptions | null,
): ParseForESLintResult

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 call createProgram)

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:

  • tokenize source text and create an AST node. And the parsing is so fast because of ts.IncrementalParser.
  • provide ts.Program ( So ts-estree don't need call createProgram )

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

Metadata

Metadata

Labels

accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestpackage: parserIssues related to @typescript-eslint/parserpackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy