Skip to content

調査: worktree 環境での pnpm lint 不安定化の原因特定と ESLint flat config ignores による恒久修正案の選定 #187

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: research
parent_issue: none
goal_ref: "worktree 環境で発生する pre-existing lint エラー(No tsconfigRootDir was set)の根本原因を特定し、恒久修正案を選定する"
change_kind: research-only

Parent Issue

none(単独調査)

Outcome

pnpm lint が .claude/worktrees/ の有無・cwd・実行 commit によって不安定化する原因を、ESLint flat config の走査対象・ignores 設定・typescript-eslint typed-linting 設定の有無に分解して特定する。

調査結果に基づき、以下のいずれかを implementation Issue として起票可能にする。

  1. eslint.config.mjs の ignores に .claude/worktrees/** または **/.claude/worktrees/** を追加する
  2. lint script を eslint src 等へ狭める
  3. typed linting が原因なら projectService / tsconfigRootDir を明示する
  4. 原因が未追跡ファイル・古い worktree・local-only config の場合は worktree cleanup / preflight check を整備する

In Scope

  • pnpm lint の再現条件マトリクス作成(clean main / worktree なし / worktree 1個 / worktree 複数 / cwd 違い)
  • eslint.config.mjs の flat config ignore 挙動確認(dotfile は自動無視されないことを確認)
  • .claude/worktrees/ が lint 対象に含まれているかの確認(eslint . スキャン対象)
  • typescript-eslint の typed-linting 設定が現行 config に存在するか確認(現行は recommended のみ)
  • .eslintignore / ignorePatterns が flat config で有効かどうかの仕様確認
  • 恒久修正候補の比較と採用案の選定:
    • eslint.config.mjs ignores に .claude/worktrees/** / **/.claude/worktrees/** を追加(第一候補)
    • lint script 対象範囲縮小(eslint src 等)
    • worktree cleanup / preflight 整備
    • typed linting 設定の明示化(typed linting を導入する場合のみ)

Out of Scope

  • tsconfig.json の rootDir 変更(TypeScript compiler option であり ESLint の走査除外には無効)
  • 型情報付き lint の新規導入(recommendedTypeChecked 等)
  • .eslintignore 追加のみでの修正(flat config では読み込まれない)
  • legacy ignorePatterns による対処(flat config 非対応)
  • worktree 管理ポリシー全体の再設計
  • ESLint 以外のツール(TypeScript compiler 等)での同様問題対処

Acceptance Criteria

  • pnpm lint の再現条件マトリクスが確認される(clean main / worktree なし / worktree 1個以上 / cwd 違い)
  • pnpm exec eslint . --debug 等による実際の lint 対象ファイル・config 解決ログが comment に記録されている
  • エラー全文・rule id・対象ファイル path・実行 commit SHA が記録されている
  • .claude/worktrees/ が lint 対象に含まれているか否かが確認されている
  • 恒久修正候補の比較(eslint.config.mjs ignores 追加 / lint script 縮小 / その他)が記載されている
  • 恒久修正案が選定され、採用理由が記載されている(第一候補: eslint.config.mjs の ignores に .claude/worktrees/** を追加)
  • 選定した修正案を適用する implementation Issue が起票され、本 Issue がその Issue を link している
  • 本 Issue は close 可能、もしくは追加調査が必要な場合はその内容が明示されている

Verification Commands

  • gh issue list --search "eslint.config.mjs ignores worktree" --state open --json number,title,url — 後続 implementation Issue が起票されているか確認
  • gh issue view 187 --comments --repo squne121/loop-protocol — 本 Issue の本文・コメントに調査結果が記載されているか確認
  • gh issue view 187 --comments --repo squne121/loop-protocol | grep -E "eslint.*debug|tsconfigRootDir|worktree" — 再現ログ・config 解決ログが comment にあるか確認

Allowed Paths

  • 読み取り専用。リポジトリ変更なし(既定)

Stop Conditions

  • Outcome / Scope / AC が検索可能な形で記載されていない場合は即停止
  • Allowed Paths 外への書き込みを試みた場合は即停止
  • 権限不足(permission denied)により操作が完了できない場合は即停止
  • 成果物の書き込みに失敗した場合(I/O エラー等)は即停止

Handoff Contract

Background

PR #177 の実装中に pnpm lint が 62 件の "No tsconfigRootDir was set" エラーを返した。これは .claude/worktrees/ 配下の worktree が ESLint の tsconfig 自動検出に影響するため発生する pre-existing 問題。実装内容とは無関係だが、CI / test-runner が毎回 baseline_only として処理する必要があり、ノイズになっている。恒久修正によってこのノイズを排除することが本調査の目的。

Required Skills

  • TypeScript / ESLint(@typescript-eslint/parser の parserOptions 設定)

Activity

  1. added
    phase/research
    state/queued
    agent/research
    on May 21, 2026
  2. squne121 commented on May 22, 2026

    @squne121
    OwnerAuthor

    Verdict: REQUEST_CHANGES 相当

    Issue #187 は、問題意識は正しいですが、このまま research Issue としてエージェントに渡すと 誤った根本原因に収束するリスクが高い です。特に「worktree tsconfig の誤検出」「.eslintignore / ignorePatterns / tsconfig.json の比較」という前提が、現在のリポジトリ実装と ESLint v10 / flat config の仕様に噛み合っていません。


    確認した前提

    #187 は、PR #177 で pnpm lint が 62 件の "No tsconfigRootDir was set" エラーを出したことを根拠に、.claude/worktrees/ 配下の worktree が ESLint の tsconfig 自動検出に影響している、という前提で起票されています。

    ただし PR #177 内部では証跡が割れています。PR 本文では pnpm lint: FAIL(pre-existing: 62 errors...) と記録されていますが、同じ PR の検証コメントでは標準品質ゲートがすべて成功、baseline_only: false とされています。

    さらに #187 の前段には PR #90 / #105 の記録があり、worktree 共存時の lint 失敗は以前から観測されています。PR #90 では「worktree 複数存在時の eslint tsconfigRootDir 候補競合」、PR #105 では main 通常 checkout では 62 errors だが worktree では pass という逆向きの観測も記録されています。


    Blocker 1: 現行 eslint.config.mjs には project / projectService / tsconfigRootDir が存在しない

    現在の eslint.config.mjs は @eslint/js と typescript-eslint の recommended config を読み込み、ignore は dist/** と node_modules/** のみです。parserOptions.project、projectService、tsconfigRootDir は設定されていません。

    typescript-eslint の仕様上、型情報付き lint では projectService: true または project を設定して TSConfig を見つける必要があり、tsconfigRootDir は相対 TSConfig パスや projectService の基準ディレクトリを固定するためのものです。 また、project: true は lint 対象ファイルごとに近傍の tsconfig.json を探索しますが、#187 が主張する「tsconfig 自動検出」はこの系統の設定がある場合の話です。

    したがって、#187 の現状記述だけでは 現行 main の ESLint 設定から "No tsconfigRootDir was set" が出るメカニズムを説明できません。原因候補は少なくとも次のどれかに分岐します。

    1. 実行時に別コミット / 別 worktree の eslint.config.mjs が読まれていた

    2. .claude/worktrees/ 配下の別リポジトリ内ファイルが lint 対象に入り、その中の設定・依存・生成物が影響した

    3. ローカル環境だけに存在する未追跡ファイル、古い config、またはサブエージェント生成物が混入した

    4. エラー文が typescript-eslint 本体ではなく、プロジェクト内または外部の独自 rule / guard / wrapper 由来だった

    この切り分けなしに tsconfigRootDir 固定へ進むのは危険です。


    Blocker 2: .eslintignore / ignorePatterns は ESLint flat config では採用案として弱い

    #187 は修正候補として .eslintignore / ignorePatterns / parserOptions.project を並べています。 しかしこのリポジトリは eslint.config.mjs を使う flat config 構成です。ESLint の移行ガイドでは、flat config は .eslintignore を読み込まず、ignore は eslint.config.* 内の ignores に移す必要があるとされています。

    また flat config では dotfile / dot directory がデフォルトでは無視されません。.claude/ 配下を lint 対象から外したいなら、現行 config の ignore object に '.claude/worktrees/**' ではなく、再帰性・ディレクトリ扱いを意識した pattern を追加する必要があります。ESLint docs は directory ignore では globalIgnores() や ignores を使い、再帰的に同名ディレクトリを無視するなら **/.config/ のような pattern が必要だと説明しています。

    つまり #187 の候補リストは、現行 ESLint v10 / flat config ではこう直すべきです。

    修正候補:
    primary:
    - eslint.config.mjs の ignores に .claude/worktrees/** または **/.claude/worktrees/** を追加
    - pnpm lint の対象を eslint src へ狭める
    secondary:
    - typed linting を導入する場合のみ parserOptions.projectService + tsconfigRootDir を検討
    reject_or_low_priority:
    - .eslintignore 追加
    - legacy ignorePatterns
    - tsconfig.json の rootDir 変更


    Blocker 3: tsconfig.json 変更は根本修正候補として不適切

    現行 tsconfig.json は include: ["src"] であり、worktree や .claude/ を TypeScript compiler の対象に含めていません。

    #187 は tsconfig.json の rootDir / project 設定で解消できるか検証すると書いていますが、これはかなり筋が悪いです。rootDir は TypeScript の出力構造・入力範囲に関わる compiler option であり、ESLint の走査対象から .claude/worktrees/ を除外する設定ではありません。今回の主因が「eslint . が repo root 以下を広く走査すること」なら、修正点は ESLint の対象範囲または ignore です。

    tsconfig.json をいじる研究を In Scope に入れるなら、少なくとも次の仮説を明記すべきです。

    hypothesis:

    • ESLint が型情報付き lint を有効化している
    • その型情報取得が tsconfig include/exclude の影響を受けている
    • 現行 eslint.config.mjs または実行時 config に project/projectService が存在する

    現状の main ではこの仮説は成立していません。


    Blocker 4: 再現条件が AC に入っていない

    #187 の AC は「メカニズムが記載されている」「候補比較が記載されている」「恒久修正案が選定されている」という文書成果物中心です。 しかしこの問題は 環境依存の lint failure なので、研究Issueであっても再現マトリクスが必須です。

    最低限、次を AC に入れるべきです。

    • 以下の各ケースで pnpm lint の結果を比較し、stdout/stderr を comment に貼る
      • clean main checkout
      • .claude/worktrees/ が存在しない状態
      • .claude/worktrees/ に 1 個の worktree が存在する状態
      • .claude/worktrees/ に複数 worktree が存在する状態
      • worktree 内 cwd から実行
      • repo root cwd から実行
    • pnpm exec eslint . --debug または同等の config-resolution 証跡で、実際に読まれた config と lint 対象ファイルを記録する
    • git status --ignored --short と .claude/worktrees/ 配下の代表ファイル一覧を記録する
    • エラー全文、rule id、対象ファイル path、実行 commit SHA を記録する

    これがないと、「worktree tsconfig 誤検出」という説明が事後的な物語になります。


    Blocker 5: parserOptions.project / projectService を安易に入れると問題を増やす

    typescript-eslint は現在、project より projectService を推奨しています。projectService は各ファイルに対して近傍の tsconfig.json を自動利用し、editor と近い型情報を得る設計です。

    ただし、これは 型情報付き lint を導入する場合の話です。現行 config は tseslint.configs.recommended で、recommendedTypeChecked ではありません。package.json 上も lint は単に eslint . です。

    今回の目的が「pre-existing lint ノイズを消す」なら、型情報付き lint の導入・projectService 化はスコープ拡張です。むしろ worktree 配下のファイルまで型情報解決を始め、さらに重く不安定になる可能性があります。


    高品質化した #187 の推奨改稿

    Issue の Outcome は次の形に変えるのがよいです。

    Outcome

    pnpm lint が .claude/worktrees/ の有無・cwd・実行 commit によって不安定化する原因を、ESLint flat config の走査対象、ignore 設定、typescript-eslint typed-linting 設定の有無に分解して特定する。

    調査結果に基づき、以下のいずれかを implementation Issue として起票可能にする。

    1. eslint.config.mjs の ignores に .claude/worktrees/** を追加する
    2. lint script を eslint src 等へ狭める
    3. typed linting を導入している別 config が原因なら projectService / tsconfigRootDir を明示する
    4. 原因が未追跡ファイル・古い worktree・local-only config の場合は、worktree cleanup / preflight check を整備する

    In Scope はこうするべきです。

    In Scope

    • pnpm lint の再現条件マトリクス作成
    • eslint.config.mjs の flat config ignore 挙動確認
    • .claude/worktrees/ が lint 対象に含まれているかの確認
    • typescript-eslint の typed-linting 設定が現行 config に存在するか確認
    • .eslintignore / ignorePatterns が flat config で有効かどうかの仕様確認
    • 恒久修正候補の比較:
      • eslint.config.mjs ignores
      • lint script 対象範囲縮小
      • worktree cleanup / preflight
      • typed linting 設定の明示化

    Out of Scope はこうするべきです。

    Out of Scope

    • 型情報付き lint の新規導入
    • TypeScript compiler の rootDir 変更
    • worktree 管理ポリシー全体の再設計
    • .eslintignore 追加のみでの修正

    推奨採用案

    現時点の第一候補は eslint.config.mjs の ignore に .claude/worktrees/** を追加する implementation Issue です。

    理由は単純です。

    現行 lint script は eslint . で repo root 以下を対象にします。

    現行 ESLint config は .claude/worktrees/** を ignore していません。

    ESLint flat config では .eslintignore ではなく config 内 ignores を使う必要があります。

    flat config では dotfile/dot directory が自動無視されないため、.claude/ は明示的に除外すべきです。

    最小パッチ案は次です。

    // eslint.config.mjs
    export default tseslint.config(
    {
    ignores: [
    'dist/',
    'node_modules/
    ',
    '.claude/worktrees/',
    '
    /.claude/worktrees/',
    ],
    },
    js.configs.recommended,
    ...tseslint.configs.recommended,
    {
    files: ['
    /*.ts'],
    rules: {
    'no-undef': 'off',
    },
    },
    )

    ただし implementation Issue では、実際の再現ログを取ってから適用してください。tsconfigRootDir 由来と断定したまま進めるのは危険です。


    最終コメント案

    敵対的レビュー結果

    REQUEST_CHANGES 相当。

    本 Issue は問題意識は妥当だが、現行 eslint.config.mjs には parserOptions.project / projectService / tsconfigRootDir が存在しないため、「typescript-eslint の tsconfig 自動探索が worktree tsconfig を誤検出している」という前提が未証明。

    また、このリポジトリは ESLint flat config (eslint.config.mjs) を使っているため、.eslintignore / legacy ignorePatterns を修正候補の中心に置くのは不適切。flat config では .eslintignore は読まれず、ignore は eslint.config.mjs の ignores で管理する必要がある。

    修正前に以下を AC に追加すること。

    • clean main / worktree なし / worktree 1個 / worktree 複数 / cwd 違いの pnpm lint 再現マトリクス
    • pnpm exec eslint . --debug 等による実際の lint 対象ファイル・config 解決ログ
    • エラー全文、rule id、対象 file path、commit SHA の記録
    • .eslintignore / ignorePatterns ではなく flat config ignores を第一候補にする候補比較
    • tsconfig.json rootDir 変更は原則 Out of Scope とすること

    現時点の第一候補は eslint.config.mjs の ignores に .claude/worktrees/** を追加する案。ただし、No tsconfigRootDir was set の直接発生源が未確認なので、implementation Issue 起票前に再現ログで裏取りすること。

  3. changed the title [-]調査: worktree 環境で複数 tsconfig 検出による pre-existing lint エラーの根本原因と対処方針を明確にする[/-] [+]調査: worktree 環境での pnpm lint 不安定化の原因特定と ESLint flat config ignores による恒久修正案の選定[/+] on May 22, 2026
  4. squne121 commented on May 22, 2026

    @squne121
    OwnerAuthor

    Issue 本文更新 — edit-issue による feedback 反映

    anchor comment #issuecomment-4514774491 の reviewer feedback(classification: feedback_update_required / scope_impact: amend)を受け、以下の変更を本文に反映しました。

    変更内容

    タイトル

    • 旧: 「調査: worktree 環境で複数 tsconfig 検出による pre-existing lint エラーの根本原因と対処方針を明確にする」
    • 新: 「調査: worktree 環境での pnpm lint 不安定化の原因特定と ESLint flat config ignores による恒久修正案の選定」
    • 理由: 「複数 tsconfig 検出」は未証明の前提。事実確認で eslint.config.mjs に parserOptions なし確認済み

    Outcome

    • 「tsconfig 誤検出」という未証明前提を除去
    • ESLint flat config の走査対象・ignores 設定・typed-linting 設定の有無への分析焦点を明確化
    • 実装候補 4 選択肢(ignores 追加 / lint script 縮小 / projectService 明示 / cleanup preflight)を列挙

    In Scope

    • 再現条件マトリクス(clean main / worktree なし / 1個 / 複数 / cwd 違い)を追加
    • eslint --debug による config 解決ログ確認を追加
    • .eslintignore / ignorePatterns が flat config で有効かの仕様確認を追加
    • 不適切な .eslintignore / tsconfig.json rootDir 検証を除外

    Out of Scope

    • tsconfig.json rootDir 変更(TypeScript compiler option、ESLint 走査除外に無効)を明示追加
    • 型情報付き lint 新規導入(recommendedTypeChecked)を明示追加
    • .eslintignore 追加のみでの修正(flat config では読み込まれない)を明示追加
    • legacy ignorePatterns(flat config 非対応)を明示追加

    Acceptance Criteria

    • 再現マトリクス確認・eslint --debug ログ記録・エラー証跡記録の AC を追加
    • 前提が誤った AC(「tsconfig 誤検出メカニズムの記載」等)を修正

    Verification Commands

    • 実際の成果物確認コマンドに更新(eslint.config.mjs ignores worktree 検索 / grep による調査ログ確認)

    Handoff Contract

    変更しなかったセクション

    Machine-Readable Contract / Parent Issue / Background / Required Skills / Stop Conditions / Allowed Paths は変更していません。

  5. squne121 commented on May 22, 2026

    @squne121
    OwnerAuthor

    編集記録: Verification Commands セクション形式修正

    変更理由: review-issue の C4 チェック(^[-$] 始まり行が1件以上)を満たしていなかったため。

    変更内容: Verification Commands セクションの ```bash コードブロック形式を、テンプレート想定の bullet 形式(`- `コマンド` — 説明`)に変換。

    変更箇所: Verification Commands セクションのみ。他のセクションは変更なし。

    変更者: issue-author SubAgent(edit-issue skill)

  6. squne121 commented on May 22, 2026

    @squne121
    OwnerAuthor

    Child Issue 起票完了

    調査結果に基づき、implementation Issue を起票しました。

    調査で確認済みの root cause(flat config での dotfile 自動無視なし + .eslintignore 非対応)に対して、eslint.config.mjs の ignores に 2 パターン(root-relative + recursive)を追加する config-change で解決します。

  7. squne121 commented on May 22, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: 完了 (2026-05-22T03:58:16Z)

    • iteration: 1
    • verdict: approve
    • termination_reason: approved
    • 改善履歴:
      • Iteration 1: anchor comment(squne121/OWNER, feedback_update_required)の事実確認を実施
        • codebase-investigator: C1-C4 全 critical repo facts confirmed(eslint.config.mjs に parserOptions なし、lint script が eslint .、ignores に .claude/worktrees/** なし)
        • web-researcher: C6-C9 ESLint flat config 外部仕様確認(.eslintignore 非対応・dotfile 自動無視なし・再帰パターン必要)
        • Outcome / In Scope / Out of Scope / AC / VC / Handoff Contract を修正
        • タイトルを「複数 tsconfig 検出」(未証明前提)から「pnpm lint 不安定化の原因特定と ESLint flat config ignores による恒久修正案の選定」に変更
        • VC を bullet 形式(C4 準拠)に変換
    • 次アクション: 実装: eslint.config.mjs の ignores に .claude/worktrees/** を追加して worktree 環境での pnpm lint ノイズを排除する #208 を起票済み。impl-review-loop で実装可能な状態。
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      follow_up_issues:
        - request_dedupe_key: "eslint.config.mjs ignores .claude/worktrees worktree lint fix"
          issue_number: 208
          issue_url: "https://github.com/squne121/loop-protocol/issues/208"
          status: created
    
      note_only_observations:
        - dedupe_key: "review-issue C4 VC format bullet research template"
          source_url: "https://github.com/squne121/loop-protocol/issues/187"
          source_note_id: "refinement-loop-iteration-1"
          summary: "research Issue の VC がコードブロック形式だったため C4 FAIL。bullet 形式(- `command` — 説明)が正しい形式。既存 #191 / #161 が対応中のためスキップ"
  8. squne121 commented on May 22, 2026

    @squne121
    OwnerAuthor

    クローズ

    refinement-loop 調査(codebase-investigator + web-researcher)の結果、ESLint flat config ignores への追加が明確な恒久修正案として確認された。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/researchphase/researchstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions