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

See ARCHITECTURE.md for detailed architectural documentation.

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

Debugging

For troubleshooting and development purposes, tsgolint supports debug logging through the OXC_LOG environment variable.

Debug Logging

To enable verbose debug output, set the OXC_LOG environment variable to debug:

OXC_LOG=debug tsgolint

Debug logging provides detailed information about the linting process, including:

  • File assignment to TypeScript programs
  • Worker distribution and execution
  • Performance timing information
  • Internal state details

This can be helpful when:

  • Diagnosing performance issues
  • Understanding how files are being processed
  • Troubleshooting TypeScript configuration problems
  • Contributing to tsgolint development

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

Testing

tsgolint includes several types of tests to ensure correctness:

Unit Tests

Run Go unit tests for individual rules:

go test ./internal/...

Integration Tests

  • ./test.sh - End-to-end snapshot test running all 40+ rules
    • Runs all tsgolint rules on all fixture files
    • Captures diagnostic output in deterministic, sortable format
    • Verifies output matches expected snapshot

About

Type aware linting for oxlint

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors 11

Languages