コーディングポリシーに「プロジェクトスクリプト優先」ルールを追加

npx等の直接実行によるlockfile迂回を防ぐため、プロジェクト定義のスクリプトを優先する原則とREJECT項目を追加
This commit is contained in:
nrslib 2026-02-18 09:58:00 +09:00
parent e028af5043
commit 425f929134
2 changed files with 4 additions and 0 deletions

View File

@ -13,6 +13,7 @@ Prioritize correctness over speed, and code accuracy over ease of implementation
| File size | ~300 lines as a guideline. Be flexible depending on the task | | File size | ~300 lines as a guideline. Be flexible depending on the task |
| Boy Scout | Leave touched areas a little better than you found them | | Boy Scout | Leave touched areas a little better than you found them |
| Fail Fast | Detect errors early. Never swallow them | | Fail Fast | Detect errors early. Never swallow them |
| Project scripts first | Use project-defined scripts for tool execution. Direct invocation is a last resort |
## No Fallbacks or Default Arguments ## No Fallbacks or Default Arguments
@ -288,3 +289,4 @@ function formatPercentage(value: number): string { ... }
- **Internal implementation exported from public API** - Only export domain-level functions and types. Do not export infrastructure functions or internal classes - **Internal implementation exported from public API** - Only export domain-level functions and types. Do not export infrastructure functions or internal classes
- **Replaced code surviving after refactoring** - Remove replaced code and exports. Do not keep unless explicitly told to - **Replaced code surviving after refactoring** - Remove replaced code and exports. Do not keep unless explicitly told to
- **Workarounds that bypass safety mechanisms** - If the root fix is correct, no additional bypass is needed - **Workarounds that bypass safety mechanisms** - If the root fix is correct, no additional bypass is needed
- **Direct tool execution bypassing project scripts** - `npx tool` and similar bypass the lockfile, causing version mismatches. Look for project-defined scripts (npm scripts, Makefile, etc.) first. Only consider direct execution when no script exists

View File

@ -13,6 +13,7 @@
| ファイルサイズ | 目安として300行。タスクに応じて柔軟に | | ファイルサイズ | 目安として300行。タスクに応じて柔軟に |
| ボーイスカウト | 触った箇所は少し改善して去る | | ボーイスカウト | 触った箇所は少し改善して去る |
| Fail Fast | エラーは早期に検出。握りつぶさない | | Fail Fast | エラーは早期に検出。握りつぶさない |
| プロジェクトスクリプト優先 | ツール実行はプロジェクト定義のスクリプトを使う。直接実行は最後の手段 |
## フォールバック・デフォルト引数の禁止 ## フォールバック・デフォルト引数の禁止
@ -288,3 +289,4 @@ function formatPercentage(value: number): string { ... }
- **内部実装のパブリック API エクスポート** - 公開するのはドメイン操作の関数・型のみ。インフラ層の関数や内部クラスをエクスポートしない - **内部実装のパブリック API エクスポート** - 公開するのはドメイン操作の関数・型のみ。インフラ層の関数や内部クラスをエクスポートしない
- **リファクタリング後の旧コード残存** - 置き換えたコード・エクスポートは削除する。明示的に残すよう指示されない限り残さない - **リファクタリング後の旧コード残存** - 置き換えたコード・エクスポートは削除する。明示的に残すよう指示されない限り残さない
- **安全機構を迂回するワークアラウンド** - 根本修正が正しいなら追加の迂回は不要 - **安全機構を迂回するワークアラウンド** - 根本修正が正しいなら追加の迂回は不要
- **プロジェクトスクリプトを迂回するツール直接実行** - `npx tool` 等の直接実行は lockfile を迂回しバージョン不一致を起こす。プロジェクトが定義したスクリプトnpm scripts, Makefile 等)を探して使う。見つからない場合のみ直接実行を検討する