Repository navigation
feat: prekによるpre-commit staged TS/JS lintの小規模trialを導入する - #2553
Merged
Merged
Conversation
#1933のresearch決定に基づき、prek(pre-commit互換のRust製Git hook manager)を 使ったpre-commit stage限定の軽量ESLint trialを追加する。pre-push stageは 導入しない。isolated temporary git repository上で動作確認するスクリプトを 併設し、開発者の実.git/hooksは変更しない。 - prek.toml: pre-commit stageのみ、eslintバイナリを`--`経由で直接呼び出す - package.json: devDependenciesにprek(npm alias経由でnpm:@j178/[email protected])をpin - docs/dev/local-hooks.md: install/bypass/uninstall/依存不足時挙動(実機検証済み)等を記載 - scripts/dev-hooks/verify_precommit_trial.sh: isolated fixtureでの動作確認スクリプト Co-Authored-By: Claude Sonnet 5 <[email protected]>
6 tasks
Contributor
Preview URLPreview removed (PR #2553 closed). |
PR Body Japanese Checkがfrontmatter titleフィールドと"install / bootstrap"見出しの 日本語比率不足でfailしていたため、doc_title_ja形式(既存hook-boundaries.md準拠)へ変更し、 見出しを日本語主体に修正する。 Refs #2552
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#1933 の research 決定に基づき、prek(Rust 製の pre-commit 互換 Git hook manager)を使った、staged TS/JS ファイルに対する軽量 ESLint チェックの小規模 trial を追加する(#2552)。
prek.toml(新規):pre-commitstage のみを定義し、language: systemでeslintバイナリを--経由で直接呼び出す(pnpm lintのeslint .はそのまま呼ばない)。pre-pushstage の定義は含まない。package.json: devDependencies にprek(pnpm aliasnpm:@j178/[email protected]経由で実体は npm registry の@j178/prek)を exact pin で追加。alias を使う理由はpackage.json中に quote 付き"prek"を literal に残すため(後述「実装メモ」参照)。pnpm-lock.yaml: 上記追加に伴う lockfile 更新。docs/dev/local-hooks.md(新規): install/bootstrap・version pin・bypass・uninstall・.legacy退避・worktree 環境での挙動・依存不足時の挙動(実機検証済み、fail-open / fail-closed の非対称性を含む)・partial-stage 挙動・pre-pushを導入しない理由・#1934/#1935/#1860との責務境界・test-runner/CI/open-pr validator との責務分離を記載。scripts/dev-hooks/verify_precommit_trial.sh(新規、実行可能ビット付与):mktemp -dで作成する isolated temporary git repository 上で (a) lint エラーを含む staged TS/JS ファイルでの commit ブロック、(b)--no-verifybypass、(c) prek install 前の fail-open / install 済みで prek 解決不能時の fail-closed、を確認する fixture スクリプト。本 PR はユーザーの実
.git/hooksを一切変更しない。動作確認はすべて上記 isolated fixture 内で完結させた(AC6 参照)。実装メモ:
package.jsonのprekalias についてnpm の scoped package 名(
@j178/prek)をそのまま devDependencies のキーにすると、package.json中に quote 付きの"prek"という文字列が現れず、Issue #2552 の Verification Commands(rg -n "\"prek\"" package.json)が意図した pin の存在確認を通らない。そのため pnpm/npm の dependency alias 構文("prek": "npm:@j178/[email protected]")を使い、devDependencies のキー名をprekにした。alias 経由でもnode_modules/.bin/prekは通常の@j178/prekインストール時と同じバイナリ名で解決される(pnpm exec prek --versionでprek 0.5.2を確認済み)。Checks
pnpm typecheckpnpm lintpnpm test(108 files / 1920 tests PASS)pnpm build./scripts/dev-hooks/verify_precommit_trial.shを手動実行し、isolated fixture 上で PASS を確認(実行ログは「AC4 手動実行ログ」節参照)git status --short .git/hooks(メインリポジトリ)が空であることを確認(AC6)AC1〜AC3 検証コマンド実行結果
AC4 手動実行ログ(
./scripts/dev-hooks/verify_precommit_trial.sh)AC5 標準4コマンド検証(
pnpm typecheck/pnpm lint/pnpm test/pnpm build)AC6(実
.git/hooks無変更)メインリポジトリの
.git/hooks/には prek 由来のファイルは一切生成されていない(ls -la .git/hooks/は*.sampleのみ)。本 PR の動作確認はすべてmktemp -dで作成した独立の temporary git repository(/tmp/...)上で行った。Schema Change Applicability
(スキーマ変更ではない)
本 PR は既存 JSON/YAML スキーマ・API 契約の変更を含まない。
prek.tomlは prek 自身が読む設定ファイル形式(prek 側の外部スキーマ)であり、本リポジトリが定義・所有するスキーマではない。package.jsonの変更は devDependencies へのエントリ追加のみで、既存フィールドのキー・型は変更していない。Schema Consumer Inventory
対象外(N/A)。既存スキーマのキー変更・型変更を行っていないため before/after 形式の inventory は不要。
Safety Claim Matrix
N/A(reason: 本 PR の変更は
prek.toml/package.json/pnpm-lock.yaml/docs/dev/local-hooks.md/scripts/dev-hooks/verify_precommit_trial.shの追加のみであり、transport / permission / sandbox / auth / mcp /.claude/skills//.github/workflows/のいずれにも該当しない safety-sensitive 変更ではないため)Notes
Closes #2552
Refs #1933
Refs #1932
(本 PR がクローズする対象 Issue と、関連する research/parent Issue の参照)
prek install実行(opt-in)や trial 効果測定・本採用判断は、本 Issue のクローズ後の別途 follow-up で扱う(docs/dev/local-hooks.mdおよび Issue 実装: prekによるpre-commit staged TS/JS lintの小規模trial導入 #2552 の Remaining Parent Gaps 参照)。#1934(AI エージェントゲート改変対策)・#1935(シナリオテスト required/nightly 分離)・#1860(minimal-harness 方針)との責務境界はdocs/dev/local-hooks.mdに明記した。not_applicable(ゲーム/プロダクトのランタイム挙動を変更しない開発ツール設定・ドキュメント追加のため)。