Skip to content

chore: apply TypeScript/ESLint setup guide - #35

Merged
isamu merged 1 commit into
mainfrom
chore/ts-eslint-strict-20260803
Aug 2, 2026
Merged

chore: apply TypeScript/ESLint setup guide#35
isamu merged 1 commit into
mainfrom
chore/ts-eslint-strict-20260803

Conversation

@isamu

@isamu isamu commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

TypeScript / ESLint 設定ガイド をこのリポジトリに適用した。

ガイド §5「既存プロジェクトの導入順序」に従い、違反 0 件のものだけ即 error、既存違反があるものは warn で導入している。CI は緑のまま。

Items to Confirm / Review

  1. tsconfig.eslint.json を新規追加した — 型情報 ESLint ルール専用。build 用 tsconfig は lint 対象の全ファイルを include していないため、project にそれを指定すると当該ファイルがパースエラーになる。build には影響しない(参照するのは eslint のみ)。
  2. .tsx が今まで一度も lint されていなかった — 旧 files: ["**/*.ts", "**/*.vue"] はどの .tsx にもマッチしない。**/*.tsx を追加したので React 側が新規に lint 対象になった。
  3. no-undef を off にした — 型としてのみ使う参照(React.FormEvent 等)を "not defined" と誤検出するため。TypeScript 自身が検出するので二重チェックは不要(typescript-eslint の eslint-recommended も同じ扱い)。
  4. @typescript-eslint/no-explicit-any の既存の off / warn 設定は削除した — ガイドが error を要求するため。違反が残っている場合のみ warn に落としてある。

tsconfig

各フラグを個別に入れてエラー件数を実測し、0 件のものだけ有効化した(ガイド §1「件数を測ってから決める」)。

tsconfig.json

フラグ 実測エラー 対応
useUnknownInCatchVariables 0 ✅ 有効化
noImplicitOverride 0 ✅ 有効化
noImplicitReturns 0 ✅ 有効化
noUncheckedIndexedAccess 0 ✅ 有効化
noPropertyAccessFromIndexSignature 0 ✅ 有効化
exactOptionalPropertyTypes 0 ✅ 有効化

ESLint

  • tseslint.configs.strict + tseslint.configs.stylistic を導入
    as を禁止する consistent-type-assertionsstylistic にしか入っていない — ガイド §2 の罠)
  • 型情報を使うルールを追加: no-floating-promises / no-misused-promises / await-thenable / no-base-to-string
    parserOptions.project が無いとルールが動きさえしない
  • strictTypeChecked は丸ごと入れず、ガイドの指示どおりルールを名指しで追加

warn で入れたもの

既存違反があるため warn で導入(= 返すべきバックログ)。CI は緑のまま件数だけ見える。

  • @typescript-eslint/await-thenable
  • @typescript-eslint/consistent-type-assertions
  • @typescript-eslint/no-explicit-any
  • @typescript-eslint/no-floating-promises

検証

yarn lint      → 0 errors
yarn typecheck → pass
yarn build     → pass
eslint .       → パースエラーなし(エディタの ESLint 連携で config ファイルを開いても壊れない)

User Prompt

メンテ対象のdir,packageに以下を適用してPR -> local review -> mergeをして
https://github.com/isamu/zenn-docs/blob/docs/ts-setup-guide/guides/typescript-eslint-setup.md

対象は GUIChatPlugins 配下の 36 リポジトリ、適用強度は「0 件のフラグのみ即適用、残りは warn」、レビューは /code-review のローカル実行、と確認済み。設定パターンは GUIChatPluginTemplate#29 でレビュー済みのものを全リポに展開している。

🤖 Generated with Claude Code

tsconfig: enable the guide's non-strict-included flags that measured 0 errors.
Flags that still report errors are left off and listed in the PR.

eslint:
- tseslint strict + stylistic (consistent-type-assertions lives only in stylistic)
- lint .tsx as well; React sources were matched by no config and went unlinted
- type-aware rules via a lint-only tsconfig.eslint.json, since the build
  tsconfigs do not cover every linted file
- no-undef off for TS (TypeScript checks it; it flags type-only references)
- rules with existing violations start at warn so CI stays green

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@isamu
isamu merged commit 7334cbb into main Aug 2, 2026
11 checks passed
@isamu
isamu deleted the chore/ts-eslint-strict-20260803 branch August 2, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant