Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
syumai
May 21, 2026
Programming
1.2k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
TSKaigi 2026の発表資料です
syumai
May 21, 2026
More Decks by syumai
See All by syumai
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
Oxlintのカスタムルールの現況
syumai
6
1.2k
『[入門] Cloudflare Workers』本はなぜ誕生したのか
syumai
0
400
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
9
3.1k
知られているようで知られていない JavaScriptの仕様 4選
syumai
3
1.2k
CloudflareのSandbox SDKを試してみた
syumai
0
880
実践AIチャットボットUI実装入門
syumai
9
4.2k
ProxyによるWindow間RPC機構の構築
syumai
3
1.5k
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
1.2k
Other Decks in Programming
See All in Programming
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
590
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.4k
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.8k
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
Inside Stream API
skrb
1
780
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
810
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
410
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6.5k
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
190
Lessons from Spec-Driven Development
simas
PRO
0
220
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
230
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
220
Featured
See All Featured
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
300
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.6k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
750
Are puppies a ranking factor?
jonoalderson
1
3.6k
How to make the Groovebox
asonas
2
2.2k
Docker and Python
trallard
47
3.9k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
540
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
2
250
Skip the Path - Find Your Career Trail
mkilby
1
150
Java REST API Framework Comparison - PWX 2021
mraible
34
9.4k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
850
Transcript
Oxlintはいかにして tsgolintのlint ruleを呼び出しているのか 2026-5-22 TSKaigi 2026 @syumai
syumai X: @__syumai Website: https://syum.ai © LayerX Inc. whoami LayerX
ソフトウェアエンジニア バクラクヘルプデスク エージェントを開発中 主にTypeScriptを書いてます ECMAScript 仕様輪読会 / Asakusa.go 主催
今日話すこと © LayerX Inc. Oxlintとは tsgolintとは tsgolintのlintルールの書き方 Oxlintによるtsgolintの呼び出し方法 3
Oxlintとは © LayerX Inc. Oxcプロジェクトのlinter https://oxc.rs/ Rust製の高速なJavaScript向けTool chain Oxcはlinter, formatter,
parser, transformerなどを含む ESLint互換が特徴 設定はESLint v8の形式 (Flat configは非対応、migration toolあり) ESLintのJS pluginも動作する (v9以降のAPIをサポート) 開発元はViteを開発するVoidZero (https://voidzero.dev/) OxlintはVite+の vp check サブコマンドとして取り込まれている 4
https://oxc.rs/#feature-linter © LayerX Inc. 5
https://viteplus.dev/#feature-check © LayerX Inc. 6
Oxlintとは © LayerX Inc. Oxlint単体では、TypeScriptの型情報を使ったlintができない 構文解析のみで対応できるものはサポートしている no-explicit-any など 型情報がないと対応できないlintルールもある no-floating-promises
, no-for-in-array など 7
https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-explicit-any © LayerX Inc. 8
https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-explicit-any © LayerX Inc. 9
https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-explicit-any © LayerX Inc. 10
https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-for-in-array © LayerX Inc. 11
https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-for-in-array © LayerX Inc. 12
https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-for-in-array © LayerX Inc. 13
tsgolintとは © LayerX Inc. 元は、2025年7月にtypescript-eslintのチームがリリースしたtsgoベースのLinter https://github.com/typescript-eslint/tsgolint これを、Oxcプロジェクトとしてforkし、Oxlintと連携できるようにしたもの https://github.com/oxc-project/tsgolint 実装は全部Go tsgoのinternal
packageの中身を無理矢理公開して使用 Oxlint + tsgolintはESLint + typescript-eslintより10倍程度速いらしい https://oxc.rs/blog/2025-12-08-type-aware-alpha.html#performance 14
https://speakerdeck.com/syumai/how-tsgolint-exposes-typescript-gos-private-apis (アーカイブあり) © LayerX Inc. 15
Oxlint + tsgolintの使い方 © LayerX Inc. 16
tsgolintによるlint ruleの書き方 © LayerX Inc. tsgolintが内部で利用可能な形で公開したtsgoのast / checker packageを使って解析 ast
packageで、欲しいNodeを探す checker packageで、欲しい型情報とのマッチを確認 17
no-for-in-arrayの例 https://github.com/oxc-project/tsgolint/blob/v0.23.0/internal/rules/no_for_in_array/no_for_in_array.go © LayerX Inc. 18
no-for-in-arrayの例 https://github.com/oxc-project/tsgolint/blob/v0.23.0/internal/rules/no_for_in_array/no_for_in_array.go © LayerX Inc. 19
no-for-in-arrayの例 https://github.com/oxc-project/tsgolint/blob/v0.23.0/internal/rules/no_for_in_array/no_for_in_array.go © LayerX Inc. 20
https://github.com/oxc-project/tsgolint/tree/v0.23.0/internal/rules © LayerX Inc. 21
cmd/tsgolint/main.go でルールを登録している https://github.com/oxc-project/tsgolint/blob/v0.23.0/cmd/tsgolint/main.go#L162-L172 © LayerX Inc. 22
自分でもtype-awareなruleを入れてみたい!
どうやって入れる?
仮説 © LayerX Inc. Oxlintとtsgolintは別々に配布されている tsgolint側だけforkしてruleを足したら動く のでは? → Oxlintがどのようにtsgolintのバイナリを探すか調べた 25
Oxlintによるtsgolintバイナリの探索 https://github.com/oxc-project/oxc/blob/oxlint_v1.66.0/crates/oxc_linter/src/tsgolint.rs#L45-L48 © LayerX Inc. Oxlintにそれらしいコードを発見 26
Oxlintによるtsgolintバイナリの探索 https://github.com/oxc-project/oxc/blob/oxlint_v1.66.0/crates/oxc_linter/src/tsgolint.rs#L1259-L1266 © LayerX Inc. OXLINT_TSGOLINT_PATH 環境変数か、 node_modules/.bin からパスを入手していた 27
やったこと © LayerX Inc. tsgolintをforkし、独自のルールを追加 require-error-cause を足してみた 興味があれば: https://github.com/syumai/tsgolint-custom forkしたtsgolintをビルド
OXLINT_TSGOLINT_PATH にビルドしたバイナリのパスを指定 Oxlintの設定で独自ルールを有効化、lintを実行 → 結果、何も検出されず失敗 28
なぜ失敗したのか?
補足: plugin ではないです (当時の勘違い) https://x.com/__syumai/status/2028114581714063731 © LayerX Inc. 30
Oxlint側のtsgolintルール定義 https://github.com/oxc-project/oxc/pull/19446 © LayerX Inc. prefer-read-only を見てみた 31
PRの変更ファイル一覧から、Oxlint側のtypescriptのrule定義一覧を発見 https://github.com/oxc-project/oxc/tree/56a7feb22fdfd82ea4e52a376cfcf3ca6f7388cd/crates/oxc_linter/src/rules/typescript © LayerX Inc. 32
prefer-readonly の定義の例 type-aware なルールは (tsgolint) の指定がある https://github.com/oxc-project/oxc/blob/oxlint_v1.66.0/crates/oxc_linter/src/rules/typescript/prefer_readonly.rs © LayerX Inc.
33
no-explicit-any の定義の例 type-aware でないルールは (tsgolint) の指定がない https://github.com/oxc-project/oxc/blob/oxlint_v1.66.0/crates/oxc_linter/src/rules/typescript/no_explicit_any.rs © LayerX Inc.
34
declare_oxc_lint マクロ マクロへの引数のパース時に (tsgolint) のmarkerを探して、 is_tsgolint_rule: true のルールとして登録 https://github.com/oxc-project/oxc/blob/oxlint_v1.66.0/crates/oxc_macros/src/declare_oxc_lint.rs#L79-L97 ©
LayerX Inc. 35
実行の流れ
実行の流れ © LayerX Inc. Oxlintを実行 lintルールの実行に進む 通常のルールは、Oxlint側で実行 is_tsgolint_rule が有効なルールは、Oxlint側で実行せずフォールバック type-aware
lintingが有効な場合は、tsgolintを子プロセスとしてヘッドレスで起動 Oxlintの実行結果と、tsgolintの実行結果をまとめてfix / report 37
lintルール実行時の is_tsgolint_rule のフォールバック is_tsgolint_rule が有効なルールをskipする https://github.com/oxc-project/oxc/blob/oxlint_v1.66.0/crates/oxc_linter/src/lib.rs © LayerX Inc. 38
tsgolintのヘッドレスでの起動 tsgolintの実行パスを探して tsgolint headless を実行、stdin / stdoutを接続する © LayerX Inc.
39
Oxlint → tsgolintの通信処理 https://github.com/oxc-project/oxc/blob/oxlint_v1.66.0/crates/oxc_linter/src/tsgolint.rs © LayerX Inc. JSONでstdinに書き込む lint対象のファイルパス、使用するルールなどの情報を含んでいる 40
tsgolint → Oxlintの通信処理 https://github.com/oxc-project/oxc/blob/oxlint_v1.66.0/crates/oxc_linter/src/tsgolint.rs © LayerX Inc. lint結果のdiagnosticsをバイナリエンコードで返す Oxlint側の TsGoLintMessageStream
でパースして、Oxlint側ルールの診断結果とまとめる 41
まとめ © LayerX Inc. tsgolintは、typescript-goの内部機能を使ってtype-awareなlintルールを実装している Oxlintから実行できるtype-awareなGo製のルールを簡単に追加する方法はない Oxlintとtsgolintの両方を変更 する必要がある Oxlintはtsgolintを子プロセスとして起動し、stdin /
stdoutで通信している tsgolintへの入力はJSON、出力は独自のバイナリフォーマット 42