这是indexloc提供的服务,不要输入任何密码
Skip to content

oxc-project/tsgolint

Repository files navigation

✨ tsgolint ✨

tsgolint is a TypeScript linter containing only type-aware rules, powered by typescript-go adapted for Oxlint.

This project originated in typescript-eslint/tsgolint. Fork permission is granted by @auvred.

If you want faster typed linting with ESLint, see typescript-eslint/typescript-eslint#10940 Enhancement: Use TypeScript's Go port (tsgo / typescript-go) for type information.

Important

tsgolint is a prototype in the early stages of development. This is a community effort. Feel free to ask to be assigned to any of the good first issues.

Running tsgolint on microsoft/typescript repo

What's been prototyped

  • Primitive linter engine
  • Lint rules tester
  • Source code fixer
  • 40 type-aware typescript-eslint's rules
  • Basic tsgolint CLI

Try running

npx oxlint-tsgolint --help

to see available options.

Speedup over ESLint

tsgolint is 20-40 times faster than ESLint + typescript-eslint.

Most of the speedup is due to the following facts:

  • Native speed parsing and type-checking (thanks to typescript-go)
  • No more TS AST -> ESTree AST conversions. TS AST is directly used in rules.
  • Parallel parsing, type checking and linting. tsgolint uses all available CPU cores.

See benchmarks for more info.

What hasn't been prototyped

  • Non-type-aware rules
  • Editor extension
  • Rich CLI features
  • Config file
  • Plugin system

Architecture

Oxlint CLI -> paths + rules -> tsgolint -> diagnostics -> Oxlint CLI.

  • Oxlint is the "frontend" for tsgolint, it handles CLI, path walking, ignores logic and printing of diagnostics.
  • tsgolint is the backend for Oxlint, accepting paths as input, and outputs structured diagnostics.

Scope of tsgolint is only:

  • run the type-aware rules
  • pass structured diagnostics back to oxlint

Note about typescript-go shims

tsgolint accesses internal typescript-go APIs via shims, which is not a recommended approach. We advise against using this method and suggest waiting for an official API release instead. See this discussion and this one.

More technical details can be found here.

Building tsgolint

git submodule update --init                       # init typescript-go submodule

cd typescript-go
git am --3way --no-gpg-sign ../patches/*.patch    # apply typescript-go patches
cd ..

go build -o tsgolint ./cmd/tsgolint

Implemented rules

Name Status
await-thenable
no-array-delete
no-base-to-string
no-confusing-void-expression
no-duplicate-type-constituents
no-floating-promises
no-for-in-array
no-implied-eval
no-meaningless-void-operator
no-misused-promises
no-misused-spread
no-mixed-enums
no-redundant-type-constituents
no-unnecessary-boolean-literal-compare
no-unnecessary-template-expression
no-unnecessary-type-arguments
no-unnecessary-type-assertion
no-unsafe-argument
no-unsafe-assignment
no-unsafe-call
no-unsafe-enum-comparison
no-unsafe-member-access
no-unsafe-return
no-unsafe-type-assertion
no-unsafe-unary-minus
non-nullable-type-assertion-style
only-throw-error
prefer-promise-reject-errors
prefer-reduce-type-parameter
prefer-return-this-type
promise-function-async
related-getter-setter-pairs
require-array-sort-compare
require-await
restrict-plus-operands
restrict-template-expressions
return-await
switch-exhaustiveness-check
unbound-method
use-unknown-in-catch-callback-variable

About

Type aware linting for oxlint

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Languages