Skip to content

타입 인지 린팅 알파


Oxlint의 타입 인지 린팅 알파 릴리스를 공개합니다!

개요

8월 기술 프리뷰에 이어 타입 인지 린팅이 알파 단계에 도달했습니다. 안정성, 설정 가능성, 규칙 커버리지가 크게 개선되었습니다.

타입 인지 린팅은 TypeScript 타입 시스템을 활용하는 no-floating-promises, no-misused-promises, await-thenable 같은 강력한 규칙을 가능하게 합니다. 타입 인지 규칙 43개로 런타임 오류 범주를 배포 전에 잡을 수 있습니다.

이 글에서:

Quick Start

oxlintoxlint-tsgolint를 설치한 뒤 --type-aware로 실행합니다.

sh
npm add -D oxlint oxlint-tsgolint@latest
npx oxlint --type-aware
sh
pnpm add -D oxlint oxlint-tsgolint@latest
pnpm oxlint --type-aware
sh
yarn add -D oxlint oxlint-tsgolint@latest
yarn oxlint --type-aware
sh
bun add -D oxlint oxlint-tsgolint@latest
bunx oxlint --type-aware

다른 설정 없이 특정 타입 인지 규칙만 시험하려면(oxlint-tsgolint가 전역 또는 로컬에 있어야 함):

sh
npx oxlint --type-aware -A all -D typescript/no-floating-promises
sh
pnpx oxlint --type-aware -A all -D typescript/no-floating-promises
sh
yarn oxlint --type-aware -A all -D typescript/no-floating-promises
sh
bunx oxlint --type-aware -A all -D typescript/no-floating-promises

설정 옵션은 사용 가이드를 참고하세요.

Performance

ProjectOxlint + Type AwareESLint + typescript-eslintImprovement
vuejs/core2.531 s20.800 s8.22x
outline/outline4.448 s55.070 s12.38x

MacBook Pro M2 Max 12코어(성능 8, 효율 4)에서 측정했습니다.

타입 인지 oxlinteslint + typescript-eslint 대비 약 10배 빠른 편입니다. 자세히는 성능 벤치마크를 참고하세요.

Oxlint로 린팅하면서 타입 체크까지 할 수 있습니다. 타입 정보를 한 번 계산하므로 중복 작업을 피합니다.

알려진 이슈

tsgolint는 프로덕션 코드베이스에서 시험할 준비가 되어 있지만, 아주 큰 저장소에서는 메모리 부족이 날 수 있습니다. 다음 이정표에서 메모리 사용을 최적화하고 있습니다. tsgolint를 써 보시고 OOM이 나면 프로젝트 정보와 함께 tsgolint 저장소로 알려 주시면 메모리 개선에 도움이 됩니다.

기술 프리뷰 이후 새로운 점

린팅과 동시에 타입 체크

tsgolint는 린팅 중 TypeScript 타입 체크 오류를 내보낼 수 있습니다. 타입 인지 규칙이 파일 안 타입을 모두 검사하므로, 이미 구한 타입 정보를 버리지 않고 활용합니다. 경우에 따라 별도 tsc --noEmit 없이 넘어갈 수 있어, CI에서 린트+타입 체크 시간을 줄일 수 있습니다.

실험 기능이며 oxlint--type-check--type-aware를 함께 주면 켤 수 있습니다.

$ oxlint --type-aware --type-check

  × typescript(TS2322): Type 'number' is not assignable to type 'string'.
   ╭─[index.ts:1:7]
 1 │ const message: string = 1
   ·       ───────
   ╰────

oxlint에서 규칙 설정

tsgolint에서 도는 타입 인지 규칙도 다른 린트 규칙처럼 oxlint에서 설정합니다. 예: no-floating-promises에서 안전한 호출 허용, void 무시 등.

json
{
  "rules": {
    "typescript/no-floating-promises": [
      "error",
      {
        "ignoreVoid": true,
        "allowForKnownSafePromises": [
          { "from": "file", "name": "SafePromise" },
          { "from": "lib", "name": "PromiseLike" }
        ]
      }
    ]
  }
}

옵션은 typescript-eslint와 맞추었으며, 각 규칙 문서의 설정 절(예: no-floating-promises)을 참고하세요.

oxlint 인라인 비활성 주석

tsgolint 규칙도 파일·줄 주석으로 다른 oxlint 규칙과 비슷하게 끌 수 있습니다.

ts
/* oxlint-disable typescript/no-floating-promises */

// oxlint-disable-next-line typescript/no-floating-promises
[1, 2, 3].map(async (x) => x + 1);

더 많은 지원 규칙

typescript-eslint에서 인기 있는 규칙 포팅을 계속했으며, oxlint로 쓸 수 있습니다. tsgolint와 함께 현재 타입 인지 규칙 43개를 지원합니다.

프리뷰 이후 추가된 규칙 예:

TypeScript 프로그램 진단 보고

이전에는 TypeScript가 프로그램을 만들고 파싱하지 못할 때 오류가 안 보여 린팅이 안 되는 이유를 알기 어려웠습니다. 이제 프로그램 생성 문제를 진단으로 보고하며 tsconfig.json 설정 문제도 포함합니다.

예: tsconfig.jsonbaseUrl이 있으면 오류로 보고합니다. TypeScript v7.0에서 baseUrl이 제거되었기 때문입니다.

$ oxlint --type-aware

  × typescript(tsconfig-error): Invalid tsconfig
   ╭─[tsconfig.json:4:3]
 3 │     "compilerOptions": {
 4 │         "baseUrl": ".",
   ·         ─────────
 5 │         "experimentalDecorators": true,
   ╰────
  help: Option 'baseUrl' has been removed. Please remove it from your configuration.
        See https://github.com/oxc-project/tsgolint/issues/351 for more information.

타입 인지 규칙 자동 수정

--fix로 타입 인지 규칙도 자동 수정됩니다. oxlint --type-aware --fix를 실행하면 tsgolint의 수정 가능한 진단이 일반 oxlint 수정과 같이 적용됩니다. 비타입 인지 규칙과 수정 워크플로가 같아집니다.

Technical details

Architecture

Oxlint의 타입 인지 린팅은 이중 바이너리 구조입니다.

oxlint CLI (Rust)
  ├─ 파일 순회, 무시 로직, 진단 처리
  ├─ 비타입 인지 규칙과 커스텀 JS 플러그인 실행
  ├─ 경로·설정을 tsgolint에 전달
  └─ 결과 포맷·표시

tsgolint (Go)
  ├─ 타입 체크에 typescript-go 직접 사용
  ├─ 타입 인지 규칙 실행
  └─ 구조화된 진단 반환

Oxlint 코어는 빠르게 유지하고 typescript-go로 TypeScript 타입 시스템을 씁니다. 프론트/백 분리로 oxlint는 UX를, tsgolint는 무거운 타입 분석을 맡습니다.

TypeScript compatibility

tsgolinttypescript-go, Microsoft의 Go 기반 재작성으로 TypeScript v7.0이 될 코드를 기반으로 합니다. TypeScript 7 진행은 공식 블로그를 참고하세요. 더 이상 지원되지 않는 기능을 만날 수 있습니다.

호환성 참고:

  • TypeScript 7.0+ 기능만 지원
  • 7.0 이전 문법·폐기 기능은 미지원
  • baseUrl 같은 레거시 tsconfig.json 옵션은 TypeScript 7.0에서 제거됨

TypeScript 6.0 이전 폐기 기능을 쓰 중이면 코드베이스를 먼저 마이그레이션해야 합니다. 폐기된 tsconfig 옵션 업데이트는 TypeScript 마이그레이션 가이드를 참고하세요.

Implementation details

tsgolint는 typescript-go 공개 API를 쓰지 않습니다. 대신 shim으로 내부 API를 노출해 빌드합니다. typescript-go 업데이트를 추적하며 깨지는 부분을 고칩니다.

typescript-go 포크는 renovatebot으로 정기 동기화합니다. TypeScript 7.0 정식 출시 후에는 main 팁 대신 안정 릴리스를 추적할 예정입니다.

What's next

베타를 위해 다음을 진행 중입니다.

  • 더 많은 규칙typescript-eslint 타입 인지 규칙 59개 중 43개 지원. 베타까지 커버리지 확대 예정.
  • 성능·메모리 — 특히 아주 큰 모노레포에서 최적화 계속.

Acknowledgements

감사드립니다.

  • typescript-go를 만든 TypeScript 팀
  • 지원을 보내 주신 typescript-eslint
  • tsgolint를 만든 @auvred
  • 성능 작업과 규칙 옵션 지원을 이어 온 @camchenry

Try it out

Quick Start로 설치·실행해 보세요.

타입 인지 린팅에 대한 피드백을 기다립니다.

연락처: