@book000/eslint-config 1.16.118 → 1.16.120

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,22 @@
1
- # GitHub Copilot レビュー指示
1
+ # Copilot review instructions
2
2
 
3
- `@book000/eslint-config` は npm に公開される共有 ESLint flat config パッケージです。
4
- コードレビュー時は以下の観点を優先してください。
3
+ See `AGENTS.md` at the repository root for the full development guidance.
5
4
 
6
- ## リポジトリ構成
5
+ ## Language
7
6
 
8
- - `index.mjs`: 公開される ESLint flat config 本体 (エントリポイント)。
9
- - `test.mjs`: `index.mjs` のルール挙動を検証するカスタムテストスクリプト。
10
- - 実行環境: pnpm 11.10.0 / ESM (`.mjs`)。
7
+ - Write all deliverables (code comments, docs, commit messages, PR text) in English.
8
+ - Runtime messages are English.
11
9
 
12
- ## 重点的に確認する点
10
+ ## Review checklist
13
11
 
14
- - **ルール変更には必ずテストを伴うこと**: `index.mjs` のルールを追加・変更する PR で
15
- `test.mjs` の `testCases` にケースが追加・更新されていない場合は指摘する。
16
- - **flat config の配列順序**: flat config は「後勝ち」。`eslintPrettier` は必ず配列末尾に
17
- 置くこと。`unicorn/filename-case` のような後段オーバーライドの順序が入れ替わっていないか
18
- 確認する。
19
- - **公開パッケージとしての破壊的変更**: ルールの追加・厳格化は利用側プロジェクトに影響する。
20
- 破壊的変更に見合うバージョニング (Conventional Commits の `feat!:` / `fix:` など) が
21
- 適切か確認する。
22
- - **コメント**: `index.mjs` の各ルール調整には「なぜ off / 変更したか」の日本語コメントを
23
- 付ける慣習がある。理由コメントなしのルール変更は指摘する。
12
+ - A change to a rule in `index.mjs` must add or update a case in `test.mjs`.
13
+ - Each rule that is off or customized needs a short comment explaining why.
14
+ - Flat config is last-wins: `eslintPrettier` must stay at the end of the array, and later overrides such as `unicorn/filename-case` must keep their order.
15
+ - Rule additions or stricter settings are breaking changes for consumers; check that the commit type fits.
16
+ - Commits follow Conventional Commits; branches follow Conventional Branch short form.
24
17
 
25
- ## フラグすべきでない既知パターン (誤検知防止)
18
+ ## Known intentional patterns (do not flag)
26
19
 
27
- - **意図的に off / 緩和されているルール**: このパッケージは設計方針として
28
- `@typescript-eslint/no-explicit-any`・`no-unsafe-assignment`・`no-unsafe-argument`・
29
- `unicorn/prevent-abbreviations`・`unicorn/no-null`・`unicorn/prefer-top-level-await` などを
30
- 意図的に off にしている。これらを「有効化すべき」と指摘しない。
31
- - **`index.mjs` 内の `@ts-expect-error`**: `unicorn.configs["flat/recommended"]` の型不整合を
32
- 回避するための意図的な記述。削除を促さない。
33
- - **`test.mjs` が生成する一時ファイル**: テストは一時的に `src/__tmp__cli` と `tsconfig.json` を
34
- 作成して ESLint を実行する。この一時生成物を問題として扱わない。
35
-
36
- ## コーディング規約 (lint / 慣習で強制)
37
-
38
- - コメント: 日本語。エラーメッセージ: 英語。
39
- - 日本語と英数字の間には半角スペースを入れる。
40
- - `skipLibCheck` による TypeScript エラー回避は禁止。
41
- - コミットメッセージは [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
42
- (`<description>` は日本語)。
20
+ - Rules deliberately turned off, such as `@typescript-eslint/no-explicit-any`, `no-unsafe-assignment`, `no-unsafe-argument`, `unicorn/no-null` and `unicorn/prefer-top-level-await`. Do not ask to enable them.
21
+ - The explicit unicorn rule list instead of `flat/recommended`.
22
+ - `test.mjs` temporarily creating `src/__tmp__cli`, `tsconfig.json` and `eslint.config.mjs`.
@@ -1,4 +1,4 @@
1
- # Node.js でビルド・テストを実行する。バージョンは .node-version に記載されているものを利用する
1
+ # Build and test with Node.js. The version is read from .node-version
2
2
 
3
3
  name: Node CI
4
4
 
@@ -62,7 +62,7 @@ jobs:
62
62
  with:
63
63
  github_token: ${{ secrets.GITHUB_TOKEN }}
64
64
  default_bump: 'minor'
65
- custom_release_rules: 'feat:minor:✨ Features,fix:patch:🐛 Fixes,docs:patch:📰 Docs,chore:patch:🎨 Chore,pref:patch:🎈 Performance improvements,refactor:patch:🧹 Refactoring,build:patch:🔍 Build,ci:patch:🔍 CI,revert:patch:⏪ Revert,style:patch:🧹 Style,test:patch:👀 Test,release:major:📦 Release'
65
+ custom_release_rules: 'feat:minor:✨ Features,fix:patch:🐛 Fixes,docs:patch:📰 Docs,chore:patch:🎨 Chore,perf:patch:🎈 Performance improvements,refactor:patch:🧹 Refactoring,build:patch:🔍 Build,ci:patch:🔍 CI,revert:patch:⏪ Revert,style:patch:🧹 Style,test:patch:👀 Test,release:major:📦 Release'
66
66
 
67
67
  - name: 📝 Update package.json version
68
68
  run: |
package/AGENTS.md ADDED
@@ -0,0 +1,51 @@
1
+ # AGENTS.md
2
+
3
+ `@book000/eslint-config` is a shared ESLint flat config published to npm (ESM).
4
+ `index.mjs` is the entry point and `test.mjs` verifies the rule behavior.
5
+
6
+ ## Language
7
+
8
+ - All deliverables are written in English: documentation, code comments, JSDoc, commit messages, PR and Issue titles and bodies, review comments, and LLM instruction files.
9
+ - Runtime messages (including the output of `test.mjs`) are English.
10
+ - Exceptions: quotations, technical identifiers, generated files, and external source text.
11
+ - Never rewrite Git history to change the language of existing commits.
12
+
13
+ ## Conventions
14
+
15
+ - Commits: [Conventional Commits](https://www.conventionalcommits.org/).
16
+ - Branches: [Conventional Branch](https://conventional-branch.github.io) short form (`feat`, `fix`, `docs`, ...).
17
+ - Package manager: pnpm (version pinned by `packageManager` in `package.json`); Node.js version is in `.node-version`.
18
+ - Do not push commits to Renovate PRs.
19
+ - Do not work around TypeScript errors with `skipLibCheck`.
20
+ - Never commit secrets.
21
+
22
+ ## Commands
23
+
24
+ ```shell
25
+ pnpm install
26
+ pnpm test
27
+ ```
28
+
29
+ `pnpm test` runs `TEST_CLI=1 node --experimental-vm-modules test.mjs`.
30
+ It creates `src/`, `tsconfig.json` and `eslint.config.mjs` in the repository root, lints one temp file per test case in a single ESLint process, and removes the temp files, `tsconfig.json` and `eslint.config.mjs` afterwards (an empty `src/` is left behind).
31
+ The script exits with code 0 even when cases fail, so read the `Failed:` count in the summary (and any `❌` lines) instead of relying on the exit code.
32
+ There is no separate lint or build step.
33
+
34
+ ## Structure of `index.mjs`
35
+
36
+ The exported config is an ordered flat config array (the last matching definition of a rule wins):
37
+
38
+ 1. `neostandard({ noStyle: true })` and `tseslint.configs.recommended`.
39
+ 2. An explicit list of `eslint-plugin-unicorn` rules: a fixed snapshot of `flat/recommended` (see the comment in the file), not the preset itself.
40
+ 3. TypeScript-only rules for `**/*.ts` and `**/*.tsx` (`strictTypeChecked` and `stylisticTypeChecked`, type-aware via `parserOptions.project: ["tsconfig.json"]`), with a few relaxed rules (`no-explicit-any`, `no-unsafe-assignment`, `no-unsafe-argument`, and others).
41
+ 4. `unicorn/catch-error-name` and `unicorn/filename-case` overrides (including a `.vue` PascalCase override).
42
+ 5. `ignores`, then `eslint-config-prettier` last so that it can disable conflicting rules.
43
+
44
+ ## Rules for changes
45
+
46
+ - Keep a short comment explaining why each rule is off or customized; the rationale is the valuable part.
47
+ - Add or update a case in the `testCases` array of `test.mjs` whenever a rule is added or changed.
48
+ - Keep `eslintPrettier` at the end of the array, and keep later overrides (such as `unicorn/filename-case`) in their current order.
49
+ - When updating `eslint-plugin-unicorn`, check its changelog and update the explicit rule list; a removed or renamed rule ID breaks config validation for every consumer.
50
+ - Adding or tightening rules is a breaking change for consumers; choose the commit type accordingly.
51
+ - Update `README.md` when installation or usage changes.
package/CLAUDE.md CHANGED
@@ -1,163 +1 @@
1
- # Claude Code 作業方針
2
-
3
- ## 目的
4
-
5
- このドキュメントは、Claude Code がこのプロジェクトで作業する際の方針とルールを定義します。
6
-
7
- ## 判断記録のルール
8
-
9
- 判断は必ずレビュー可能な形で記録すること:
10
-
11
- 1. 判断内容の要約
12
- 2. 検討した代替案
13
- 3. 採用しなかった案とその理由
14
- 4. 前提条件・仮定・不確実性
15
- 5. 他エージェントによるレビュー可否
16
-
17
- 前提・仮定・不確実性を明示すること。仮定を事実のように扱ってはならない。
18
-
19
- ## プロジェクト概要
20
-
21
- - 目的: 個人用 ESLint 設定を提供するパッケージ
22
- - 主な機能: ESLint flat config に基づいた TypeScript / JavaScript プロジェクト向けのルール定義
23
- - 対象ユーザー: book000 の個人プロジェクト開発者
24
-
25
- ## 重要ルール
26
-
27
- - 会話言語: 日本語
28
- - コミット規約: [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) (`<description>` は日本語)
29
- - コメント言語: 日本語
30
- - エラーメッセージ言語: 英語
31
- - 日本語と英数字の間: 半角スペースを挿入
32
-
33
- ## 環境のルール
34
-
35
- - **ブランチ命名**: [Conventional Branch](https://conventional-branch.github.io) に従う (`<type>` は短縮形: feat, fix)
36
- - **GitHub リポジトリ調査**: テンポラリディレクトリに git clone して検索
37
- - **Renovate PR**: Renovate が作成したプルリクエストに対して、追加コミットや更新を行わない
38
-
39
- ## Git Worktree
40
-
41
- このプロジェクトでは Git Worktree を使用していません。
42
-
43
- ## コード改修時のルール
44
-
45
- - 日本語と英数字の間には、半角スペースを挿入しなければならない
46
- - 既存のエラーメッセージで、先頭に絵文字がある場合は、全体でエラーメッセージに絵文字を設定する
47
- - TypeScript プロジェクトにおいて、skipLibCheck を有効にして回避することは絶対にしてはならない
48
- - 関数やインターフェースには、docstring (JSDoc など) を日本語で記載・更新する
49
-
50
- ## 開発コマンド
51
-
52
- ```bash
53
- # 依存関係のインストール
54
- pnpm install
55
-
56
- # テスト実行
57
- pnpm test
58
- ```
59
-
60
- ## アーキテクチャと主要ファイル
61
-
62
- ### アーキテクチャサマリー
63
-
64
- - ESLint flat config (eslint.config.mjs 形式) を提供するパッケージ
65
- - TypeScript / JavaScript プロジェクト向けの厳格なルールセット
66
- - typescript-eslint, unicorn, neostandard, prettier の統合
67
-
68
- ### 主要ディレクトリとファイル
69
-
70
- - `index.mjs`: ESLint flat config のエントリポイント
71
- - `test.mjs`: ESLint ルールの動作検証スクリプト
72
- - `package.json`: パッケージ定義
73
- - `.github/workflows/`: GitHub Actions の CI/CD 設定
74
-
75
- ## 実装パターン
76
-
77
- ### 推奨パターン
78
-
79
- - ESLint ルール設定: `index.mjs` で flat config 形式で定義
80
- - テストケース追加: `test.mjs` の `testCases` 配列に追加
81
- - TypeScript 専用ルール: `files: ["**/*.ts", "**/*.tsx"]` で適用範囲を限定
82
-
83
- ### 非推奨パターン
84
-
85
- - `.eslintrc.js` などのレガシー設定形式の使用
86
- - `skipLibCheck` での TypeScript エラー回避
87
- - テストなしでのルール変更
88
-
89
- ## テスト
90
-
91
- - テスト方針: ESLint ルールの動作を検証し、期待通りの挙動を確認
92
- - テストフレームワーク: Node.js の `exec` を使用したカスタムテストスクリプト
93
- - テストコマンド: `pnpm test`
94
- - 追加テスト条件: 新しい ESLint ルールを追加・変更した場合、必ず test.mjs にテストケースを追加
95
-
96
- ## ドキュメント更新ルール
97
-
98
- ### 更新対象
99
-
100
- - `README.md`: パッケージの使用方法、インストール手順
101
- - `index.mjs`: ESLint ルール設定の変更時
102
- - `test.mjs`: テストケースの追加・変更時
103
-
104
- ### 更新タイミング
105
-
106
- - ESLint ルールの追加・変更時
107
- - パッケージの使用方法の変更時
108
- - 依存パッケージの大幅な更新時
109
-
110
- ## 作業チェックリスト
111
-
112
- ### 新規改修時
113
-
114
- 1. プロジェクトについて詳細に探索し理解すること
115
- 2. 作業を行うブランチが適切であること。すでに PR を提出しクローズされたブランチでないこと
116
- 3. 最新のリモートブランチに基づいた新規ブランチであること
117
- 4. PR がクローズされ、不要となったブランチは削除されていること
118
- 5. プロジェクトで指定されたパッケージマネージャ (pnpm) により、依存パッケージをインストールしたこと
119
-
120
- ### コミット・プッシュ前
121
-
122
- 1. コミットメッセージが [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) に従っていること (`<description>` は日本語)
123
- 2. コミット内容にセンシティブな情報が含まれていないこと
124
- 3. Lint / Format エラーが発生しないこと
125
- 4. 動作確認を行い、期待通り動作すること (pnpm test で確認)
126
-
127
- ### PR 作成前
128
-
129
- 1. プルリクエストの作成をユーザーから依頼されていること
130
- 2. コミット内容にセンシティブな情報が含まれていないこと
131
- 3. コンフリクトする恐れが無いこと
132
-
133
- ### PR 作成後
134
-
135
- 1. コンフリクトが発生していないこと
136
- 2. PR 本文の内容は、ブランチの現在の状態を、今までのこの PR での更新履歴を含むことなく、最新の状態のみ、漏れなく日本語で記載されていること
137
- 3. `gh pr checks <PR ID> --watch` で GitHub Actions CI を待ち、その結果がエラーとなっていないこと。成功している場合でも、ログを確認し、誤って成功扱いになっていないこと
138
- 4. GitHub Copilot レビューへの対応を行うこと。対応したら、レビューコメントそれぞれに対して返信を行うこと
139
- 5. コードレビューを実施し、指摘事項に対応すること
140
-
141
- ## リポジトリ固有
142
-
143
- - このパッケージは npm に公開される共有可能な ESLint 設定です。
144
- - `index.mjs` が ESLint flat config のエントリポイントです。
145
- - TypeScript プロジェクト向けに `files: ["**/*.ts", "**/*.tsx"]` で TypeScript 専用ルールを適用しています。
146
- - 以下のルールが特別に調整されています:
147
- - `@typescript-eslint/no-explicit-any`: off (any 型の使用を許可)
148
- - `@typescript-eslint/no-unsafe-assignment`: off (危険な代入を許可)
149
- - `@typescript-eslint/no-unsafe-argument`: off (危険な引数を許可)
150
- - `@typescript-eslint/restrict-template-expressions`: テンプレート式で number, boolean, any, nullish を許可
151
- - `@typescript-eslint/no-floating-promises`: void 演算子と即時関数での Promise を許可
152
- - `@typescript-eslint/no-unnecessary-condition`: 定数ループ条件 (無限ループ) を許可
153
- - `@typescript-eslint/no-extraneous-class`: 名前空間として使用されるクラスを許可
154
- - `@typescript-eslint/no-use-before-define`: TypeScript 準拠に変更
155
- - `unicorn/prefer-top-level-await`: off (トップレベル await を許可)
156
- - `unicorn/consistent-class-member-order`: off (private before public を強制せず public-first の慣習を許可)
157
- - `unicorn/prevent-abbreviations`: off (省略形を許可)
158
- - `unicorn/no-null`: off (null を許可)
159
- - `unicorn/no-useless-undefined`: off (無駄な undefined を許可)
160
- - `unicorn/catch-error-name`: catch のエラー変数名を `error` に統一 (`err` も許可)
161
- - `unicorn/filename-case`: `checkDirectories: false` でディレクトリ名チェックを無効化し、`__xxx__` 形式は対象外。`.vue` ファイルのみ pascalCase を適用
162
- - Renovate による依存パッケージの自動更新が有効です。Renovate の PR には追加コミットや更新を行わないこと。
163
- - テスト (test.mjs) は、一時的に `src/__tmp__cli` ディレクトリと `tsconfig.json` を作成して ESLint を実行します。
1
+ @AGENTS.md
package/README.md CHANGED
@@ -34,6 +34,13 @@ Then, create `eslint.config.mjs` file and write the following:
34
34
  export { default } from '@book000/eslint-config'
35
35
  ```
36
36
 
37
+ ## Included
38
+
39
+ - [neostandard](https://github.com/neostandard/neostandard) (without style rules) and the typescript-eslint `recommended` preset for all files.
40
+ - An explicit list of [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) rules, with some noisy rules turned off.
41
+ - For `*.ts` and `*.tsx`: typescript-eslint `strictTypeChecked` and `stylisticTypeChecked` with a few relaxed rules. A `tsconfig.json` in the project root is required.
42
+ - [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier), so formatting is left to Prettier.
43
+
37
44
  ## 📑 License
38
45
 
39
46
  This project is licensed under the [MIT License](LICENSE).
package/index.mjs CHANGED
@@ -6,95 +6,80 @@ import neostandard from "neostandard";
6
6
  import tseslint from "typescript-eslint";
7
7
 
8
8
  export default tseslint.config(
9
- // Standard JS のルールセット(スタイル系は prettier に委ねるため無効化)
9
+ // Standard JS rule set. Style rules are disabled because Prettier owns formatting.
10
10
  ...neostandard({ noStyle: true }),
11
11
  ...tseslint.configs.recommended,
12
12
  {
13
- // eslint-plugin-unicorn のルールを flat/recommended に頼らず明示的に列挙する。
14
- // 理由: flat/recommended は unicorn のバージョンアップごとに収録ルールが
15
- // 無断で増減し、本パッケージに依存する多数のプロジェクトへ一斉に
16
- // 新規エラーが波及するリスクがあるため。新しいルールを取り込む場合は
17
- // このリストへ明示的に追記すること(unicorn の CHANGELOG を確認して判断する)。
13
+ // List eslint-plugin-unicorn rules explicitly instead of using flat/recommended.
14
+ // Reason: flat/recommended gains or loses rules on every unicorn release, which would
15
+ // push new errors to every project that depends on this package at once.
16
+ // To adopt a new rule, add it to this list after checking the unicorn changelog.
18
17
  //
19
- // 生成方法: eslint-plugin-unicorn (現在インストールされている 71.1.0) の
20
- // flat/recommended が定義するルール一覧を元に、以下を除外・調整して作成した。
21
- // - deprecated ルールは対象外
22
- // - catch-error-name, filename-case はオプション付きで設定するため、
23
- // 下記の専用ブロックに記載し、ここでは省略する
24
- // - 意図的に off とするルール(下記コメント参照)
18
+ // The list is a fixed snapshot of flat/recommended at eslint-plugin-unicorn 71.1.0
19
+ // and is not re-synced automatically, minus:
20
+ // - deprecated rules
21
+ // - catch-error-name and filename-case, which need options and have dedicated blocks below
22
+ // - rules deliberately turned off (see the "off" entries below)
25
23
  //
26
- // 注意: このリストは eslint-plugin-unicorn の特定バージョン (71.1.0) 時点の
27
- // flat/recommended を元に生成した固定スナップショットである。unicorn を
28
- // アップデートする際は、追加・削除・改名されたルールが無いか CHANGELOG を
29
- // 確認し、このリストへ反映すること。反映を怠ると、削除・改名されたルール ID
30
- // を参照したままとなり、ESLint の設定検証エラーで全ユーザーがクラッシュする
31
- // おそれがある。
24
+ // When upgrading unicorn, check the changelog for added, removed or renamed rules and
25
+ // update this list. A removed or renamed rule ID left here makes ESLint fail config
26
+ // validation and crashes the linter for every consumer.
32
27
  plugins: { unicorn },
33
28
  rules: {
34
- // 集約処理のイディオムとして正当な用途が多く、for ループへの
35
- // 書き換え強制がかえって可読性を落とすため無効化する
29
+ // reduce is a legitimate aggregation idiom; forcing a rewrite to for loops hurts readability.
36
30
  "unicorn/no-array-reduce": "off",
37
- // クロージャで意図的に外側スコープの変数を捕捉する関数まで
38
- // 最上位への移動を要求し、誤検知が多いため無効化する
31
+ // Too many false positives: it demands hoisting even functions that intentionally
32
+ // capture outer-scope variables in a closure.
39
33
  "unicorn/consistent-function-scoping": "off",
40
- // トップレベル await を許可する(IIFE 併用の CLI ツール等のため)
34
+ // Allow top-level await (e.g. CLI tools that also use an IIFE).
41
35
  "unicorn/prefer-top-level-await": "off",
42
- // 省略形を許可する (dev -> development, prod -> production などの変換をさせない)
36
+ // Allow abbreviations (do not force dev -> development, prod -> production, etc.).
43
37
  "unicorn/name-replacements": "off",
44
- // null を許可する
38
+ // Allow null.
45
39
  "unicorn/no-null": "off",
46
- // 無駄な undefined を許可する
40
+ // Allow explicit undefined (e.g. `return undefined`, `x = undefined`).
47
41
  "unicorn/no-useless-undefined": "off",
48
- // クラスメンバーの順序(private before public)を強制しない。
49
- // public-first の慣習は API の可読性として広く使われているため。
42
+ // Do not enforce class member order (private before public).
43
+ // Public-first is a widely used convention that keeps the API readable.
50
44
  "unicorn/consistent-class-member-order": "off",
51
- // 依存プロジェクト横断での実運用調査 (tomacheese/book000/jaoafa 各オーガニゼーション規模) の
52
- // 結果、誤検知率が高く実利が薄いと判断したルールを以下のとおり無効化する。
45
+ // The rules below are off because of a high false-positive rate and little benefit
46
+ // in real usage across dependent projects.
53
47
  //
54
- // .then()/.catch()/.finally() チェーンを await へ書き換えるよう強制するが、
55
- // 関数自体を async 化したくない薄いラッパー関数 (Promise を返すだけの関数) まで
56
- // 書き換え対象になり実利が薄いため無効化する
48
+ // Forces .then()/.catch()/.finally() chains to become await, but also flags thin wrappers
49
+ // that just return a Promise and should not become async.
57
50
  "unicorn/prefer-await": "off",
58
- // is/has/should 等のプレフィックスを強制するが、ドメイン語彙由来の真偽値変数名
59
- // (enabled, visible 等) まで誤検知するため無効化する
51
+ // Enforces is/has/should prefixes, but also flags domain-vocabulary booleans
52
+ // such as enabled or visible.
60
53
  "unicorn/consistent-boolean-name": "off",
61
- // get/set/create 等の動詞プレフィックスを持つ関数以外の値 (変数・プロパティ等) を
62
- // 検出するが、removeButton (削除用ボタン要素を指す変数名) のようなドメイン語彙由来の
63
- // 命名まで誤検知するため無効化する
54
+ // Flags non-function values (variables, properties) with a verb prefix such as get/set/create,
55
+ // but also domain names like removeButton (a variable holding a "remove" button element).
64
56
  "unicorn/no-non-function-verb-prefix": "off",
65
- // Number() による型強制を強制するが、parseInt 等との挙動差 (NaN の扱い等) により
66
- // 意図せず動作が変わる危険があるため無効化する
57
+ // Forces Number() coercion, but it behaves differently from parseInt (e.g. NaN handling),
58
+ // so the automatic rewrite can change behavior unintentionally.
67
59
  "unicorn/prefer-number-coercion": "off",
68
- // モジュールトップレベル変数へのキャッシュ/メモ化目的の代入という一般的な
69
- // パターンまで誤検知するため無効化する
60
+ // Also flags the common pattern of assigning a module-level variable for caching or memoization.
70
61
  "unicorn/no-top-level-assignment-in-function": "off",
71
- // \uXXXX と \u{XXXX} は等価であり、既存コードへの機械的な書き換えを強制する
72
- // だけで実利が薄いため無効化する
62
+ // \uXXXX and \u{XXXX} are equivalent; the rule only forces a mechanical rewrite of existing code.
73
63
  "unicorn/prefer-unicode-code-point-escapes": "off",
74
- // ネストしたループ内の break による意図的な早期脱出パターンまで誤検知するため
75
- // 無効化する
64
+ // Also flags intentional early exits via break inside nested loops.
76
65
  "unicorn/no-break-in-nested-loop": "off",
77
- // 継承・拡張を意図した static メソッド内でのクラス名参照という正当な
78
- // パターンまで誤検知するため無効化する
66
+ // Also flags legitimate class-name references inside static methods that are meant to be extended.
79
67
  "unicorn/class-reference-in-static-methods": "off",
80
- // while (true) の先頭で break 条件を判定するコードを、条件を while() の式へ
81
- // 移すよう強制するが、ループ内で算出した値を break 条件に使うイディオム
82
- // (while (true) { const chunk = readNext(); if (!chunk) break; ... }) まで
83
- // 誤検知するため無効化する
68
+ // Forces a leading `if (...) break` of while (true) into the while() condition, but also flags
69
+ // the idiom where the break condition uses a value computed inside the loop
70
+ // (while (true) { const chunk = readNext(); if (!chunk) break; ... }).
84
71
  "unicorn/prefer-while-loop-condition": "off",
85
- // location.href への代入と location.assign() はほぼ等価であり、機械的な
86
- // 書き換えを強制するだけで実利が薄いため無効化する
72
+ // Assigning location.href and calling location.assign() are nearly equivalent;
73
+ // the rule only forces a mechanical rewrite.
87
74
  "unicorn/prefer-location-assign": "off",
88
- // 呼び出しの引数として渡された呼び出しの入れ子の深さを検出するが、
89
- // z.array(z.object({ ... })) のような Zod 等のスキーマ定義における正当な
90
- // 入れ子呼び出しまで誤検知するため無効化する
75
+ // Limits the nesting depth of calls passed as arguments, but also flags legitimate nesting in
76
+ // schema definitions such as Zod's z.array(z.object({ ... })).
91
77
  "unicorn/max-nested-calls": "off",
92
- // globalThis/window/global のプロパティへの代入は、テストやモックの
93
- // セットアップにおける標準的なイディオム (globalThis.fetch = mock 等) であり、
94
- // 実運用コードでの誤検知率が高いため無効化する
78
+ // Assigning to properties of globalThis/window/global is the standard way to set up tests and
79
+ // mocks (globalThis.fetch = mock), so the false-positive rate is high in real code.
95
80
  "unicorn/no-global-object-property-assignment": "off",
96
81
  //
97
- // 以下、上記以外の flat/recommended 収録ルールをすべて明示的に error とする
82
+ // All remaining rules of the flat/recommended snapshot are set to "error" explicitly below.
98
83
  "unicorn/better-dom-traversing": "error",
99
84
  "unicorn/consistent-assert": "error",
100
85
  "unicorn/consistent-compound-words": "error",
@@ -394,13 +379,13 @@ export default tseslint.config(
394
379
  ...tseslint.configs.stylisticTypeChecked,
395
380
  ],
396
381
  rules: {
397
- // TypeScriptのany型の使用を許可する
382
+ // Allow the any type.
398
383
  "@typescript-eslint/no-explicit-any": "off",
399
- // TypeScriptの危険な代入を許可する
384
+ // Allow unsafe assignments of any.
400
385
  "@typescript-eslint/no-unsafe-assignment": "off",
401
- // TypeScriptの危険な引数を許可する
386
+ // Allow unsafe any arguments.
402
387
  "@typescript-eslint/no-unsafe-argument": "off",
403
- // テンプレート式において、数値や真偽値、nullishを許可する
388
+ // Allow numbers, booleans, any and nullish values in template literals.
404
389
  "@typescript-eslint/restrict-template-expressions": [
405
390
  "error",
406
391
  {
@@ -410,7 +395,7 @@ export default tseslint.config(
410
395
  allowNullish: true,
411
396
  },
412
397
  ],
413
- // 呼び出されないPromiseを許容しないが、void演算子や即時関数では許可する
398
+ // Disallow floating Promises, except with the void operator or an immediately invoked async function.
414
399
  "@typescript-eslint/no-floating-promises": [
415
400
  "error",
416
401
  {
@@ -418,35 +403,35 @@ export default tseslint.config(
418
403
  ignoreIIFE: true,
419
404
  },
420
405
  ],
421
- // 不要な条件式を許容しないが、定数ループ条件(無限ループ)は許可する
406
+ // Disallow unnecessary conditions, except constant loop conditions (infinite loops).
422
407
  "@typescript-eslint/no-unnecessary-condition": [
423
408
  "error",
424
409
  {
425
410
  allowConstantLoopConditions: true,
426
411
  },
427
412
  ],
428
- // 名前空間として使用されるクラスを許可する
413
+ // Allow classes used as namespaces.
429
414
  "@typescript-eslint/no-extraneous-class": "off",
430
- // 変数などの未定義使用について、TypeScript準拠とする
415
+ // Use the TypeScript-aware version of no-use-before-define.
431
416
  "no-use-before-define": "off",
432
417
  "@typescript-eslint/no-use-before-define": "error",
433
418
  },
434
419
  },
435
420
  {
436
- // catch ブロックのエラー変数名は error に統一する。
437
- // err も常に許容する(error_ は要求しない)。
421
+ // Name the catch-clause variable `error`.
422
+ // `err` is always accepted too (error_ is not required).
438
423
  rules: {
439
424
  "unicorn/catch-error-name": ["error", { name: "error", ignore: [/^err$/] }],
440
425
  },
441
426
  },
442
427
  {
443
- // unicorn v65 からファイル名に加えてディレクトリ名もチェック対象となったが、
444
- // ignore オプションはマッチしたセグメントを含むファイル全体をスキップするため
445
- // ファイル名チェック自体まで無効化してしまう。
446
- // そのため checkDirectories: false でディレクトリ名チェックのみ無効化する。
447
- // src 等の慣習的なディレクトリ名でエラーが起きる問題もこれで解消される。
448
- // __tests__ や __mocks__ 等のダブルアンダースコアディレクトリは引き続き
449
- // ignore で対象外とする(テストファイル等はファイル名チェックも不要なため)。
428
+ // Since unicorn v65 directory names are checked as well as file names.
429
+ // The `ignore` option skips the whole file when any path segment matches.
430
+ // That would also disable the file name check, so only the directory check is disabled
431
+ // with checkDirectories: false.
432
+ // This also avoids errors for conventional directory names such as src.
433
+ // Double-underscore directories such as __tests__ and __mocks__ stay in `ignore`
434
+ // (test files need no file name check).
450
435
  rules: {
451
436
  "unicorn/filename-case": [
452
437
  "error",
@@ -455,13 +440,10 @@ export default tseslint.config(
455
440
  },
456
441
  },
457
442
  {
458
- // Vue コンポーネントは PascalCase の命名規則が慣習であるため、
459
- // .vue ファイルに限り pascalCase を適用する。
460
- // unicorn/filename-case のルールは ESLint flat config の「最後に定義したルールが勝つ」
461
- // 仕様により、プロジェクト側でオーバーライドするとここで設定した checkDirectories: false
462
- // も上書きされてしまう。
463
- // そのため、プロジェクト側で filename-case を再定義せずにこのデフォルト設定を
464
- // 使い続けられるよう、あらかじめ checkDirectories: false も含めて設定する。
443
+ // Vue components conventionally use PascalCase, so pascalCase applies to .vue files only.
444
+ // In flat config the last definition of a rule wins.
445
+ // A consumer that overrides unicorn/filename-case would also drop checkDirectories: false.
446
+ // It is repeated here so consumers can keep these defaults without redefining the rule.
465
447
  files: ["**/*.vue"],
466
448
  rules: {
467
449
  "unicorn/filename-case": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@book000/eslint-config",
3
- "version": "1.16.118",
3
+ "version": "1.16.120",
4
4
  "description": "ESLint config",
5
5
  "keywords": [
6
6
  "eslint-config"
package/test.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // Node.jsスクリプトでESLint flat config(index.mjs)の動作を検証するサンプル
1
+ // Verifies the behavior of the ESLint flat config (index.mjs) by linting temporary files.
2
2
  import { execFile } from "child_process";
3
3
  import fs from "fs";
4
4
  import path from "path";
@@ -9,292 +9,292 @@ const execFileAsync = promisify(execFile);
9
9
  async function main() {
10
10
  const testCases = [
11
11
  {
12
- name: "prefer-top-level-await: トップレベルawaitはOK",
12
+ name: "prefer-top-level-await: top-level await is allowed",
13
13
  code: "await Promise.resolve(1);",
14
14
  shouldError: false,
15
15
  rules: ["unicorn/prefer-top-level-await"],
16
16
  },
17
17
  {
18
- name: "name-replacements: dev, prodなど省略形はOK",
18
+ name: "name-replacements: abbreviations such as dev and prod are allowed",
19
19
  code: "const dev = true; const prod = false;",
20
20
  shouldError: false,
21
21
  rules: ["unicorn/name-replacements"],
22
22
  },
23
23
  {
24
- name: "no-null: nullの使用はOK",
24
+ name: "no-null: null is allowed",
25
25
  code: "const a = null;",
26
26
  shouldError: false,
27
27
  rules: ["unicorn/no-null"],
28
28
  },
29
29
  {
30
- name: "no-array-reduce: reduceの使用はOK",
30
+ name: "no-array-reduce: reduce is allowed",
31
31
  code: "const sum = [1, 2, 3].reduce((accumulator, value) => accumulator + value, 0);",
32
32
  shouldError: false,
33
33
  rules: ["unicorn/no-array-reduce"],
34
34
  },
35
35
  {
36
- name: "consistent-function-scoping: 外側スコープを捕捉するネストした関数はOK",
36
+ name: "consistent-function-scoping: nested function capturing an outer-scope variable is allowed",
37
37
  code: "function outer() { const base = 1; function inner() { return base; } return inner(); }",
38
38
  shouldError: false,
39
39
  rules: ["unicorn/consistent-function-scoping"],
40
40
  },
41
41
  {
42
- name: "no-use-before-define: 定義前の変数使用はエラー",
42
+ name: "no-use-before-define: using a variable before its definition is an error",
43
43
  code: "console.log(a); const a = 1;",
44
44
  shouldError: true,
45
45
  rules: ["@typescript-eslint/no-use-before-define"],
46
46
  },
47
47
  {
48
- name: "no-use-before-define: 定義後の変数使用はOK",
48
+ name: "no-use-before-define: using a variable after its definition is allowed",
49
49
  code: "const a = 1; console.log(a);",
50
50
  shouldError: false,
51
51
  rules: ["@typescript-eslint/no-use-before-define"],
52
52
  },
53
53
  {
54
- name: "no-explicit-any: any型の使用はOK",
54
+ name: "no-explicit-any: the any type is allowed",
55
55
  code: "let a: any = 1; a = 'str';",
56
56
  shouldError: false,
57
57
  rules: ["@typescript-eslint/no-explicit-any"],
58
58
  },
59
59
  {
60
- name: "no-unsafe-assignment: unsafeな代入はOK",
60
+ name: "no-unsafe-assignment: unsafe assignment is allowed",
61
61
  code: "function f(x: any) { const y: number = x; }",
62
62
  shouldError: false,
63
63
  rules: ["@typescript-eslint/no-unsafe-assignment"],
64
64
  },
65
65
  {
66
- name: "no-unsafe-argument: unsafeな引数はOK",
66
+ name: "no-unsafe-argument: unsafe argument is allowed",
67
67
  code: "function f(x: number) {} f(({} as any));",
68
68
  shouldError: false,
69
69
  rules: ["@typescript-eslint/no-unsafe-argument"],
70
70
  },
71
71
  {
72
- name: "restrict-template-expressions: number, boolean, any, nullishはOK",
72
+ name: "restrict-template-expressions: number, boolean, any and nullish are allowed",
73
73
  code: "const n = 1; const b = true; const a: any = 2; const u = undefined; `${n}${b}${a}${u}`;",
74
74
  shouldError: false,
75
75
  rules: ["@typescript-eslint/restrict-template-expressions"],
76
76
  },
77
77
  {
78
- name: "restrict-template-expressions: numberはOK",
78
+ name: "restrict-template-expressions: number is allowed",
79
79
  code: "const n = 42; `${n}`;",
80
80
  shouldError: false,
81
81
  rules: ["@typescript-eslint/restrict-template-expressions"],
82
82
  },
83
83
  {
84
- name: "restrict-template-expressions: booleanはOK",
84
+ name: "restrict-template-expressions: boolean is allowed",
85
85
  code: "const b = true; `${b}`;",
86
86
  shouldError: false,
87
87
  rules: ["@typescript-eslint/restrict-template-expressions"],
88
88
  },
89
89
  {
90
- name: "restrict-template-expressions: nullはOK",
90
+ name: "restrict-template-expressions: null is allowed",
91
91
  code: "const n = null; `${n}`;",
92
92
  shouldError: false,
93
93
  rules: ["@typescript-eslint/restrict-template-expressions"],
94
94
  },
95
95
  {
96
- name: "restrict-template-expressions: undefinedはOK",
96
+ name: "restrict-template-expressions: undefined is allowed",
97
97
  code: "const u = undefined; `${u}`;",
98
98
  shouldError: false,
99
99
  rules: ["@typescript-eslint/restrict-template-expressions"],
100
100
  },
101
101
  {
102
- name: "restrict-template-expressions: anyはOK",
102
+ name: "restrict-template-expressions: any is allowed",
103
103
  code: "const a: any = 123; `${a}`;",
104
104
  shouldError: false,
105
105
  rules: ["@typescript-eslint/restrict-template-expressions"],
106
106
  },
107
107
  {
108
- name: "restrict-template-expressions: objectはエラー",
108
+ name: "restrict-template-expressions: object is an error",
109
109
  code: "const o = {}; `${o}`;",
110
110
  shouldError: true,
111
111
  rules: ["@typescript-eslint/restrict-template-expressions"],
112
112
  },
113
113
  {
114
- name: "restrict-template-expressions: objectはエラー(詳細)",
114
+ name: "restrict-template-expressions: object is an error (with a property)",
115
115
  code: "const o = { foo: 1 }; `${o}`;",
116
116
  shouldError: true,
117
117
  rules: ["@typescript-eslint/restrict-template-expressions"],
118
118
  },
119
119
  {
120
- name: "no-floating-promises: 通常のPromiseはエラー",
120
+ name: "no-floating-promises: a plain Promise is an error",
121
121
  code: "Promise.resolve(1);",
122
122
  shouldError: true,
123
123
  rules: ["@typescript-eslint/no-floating-promises"],
124
124
  },
125
125
  {
126
- name: "no-floating-promises: void演算子はOK",
126
+ name: "no-floating-promises: the void operator is allowed",
127
127
  code: "void Promise.resolve(1);",
128
128
  shouldError: false,
129
129
  rules: ["@typescript-eslint/no-floating-promises"],
130
130
  },
131
131
  {
132
- name: "no-floating-promises: void演算子なしはエラー",
132
+ name: "no-floating-promises: without the void operator is an error",
133
133
  code: "Promise.resolve(1);",
134
134
  shouldError: true,
135
135
  rules: ["@typescript-eslint/no-floating-promises"],
136
136
  },
137
137
  {
138
- name: "no-floating-promises: 即時関数でawaitなしはエラー",
138
+ name: "no-floating-promises: an unawaited Promise inside an IIFE is an error",
139
139
  code: "(async () => { Promise.resolve(1); })();",
140
140
  shouldError: true,
141
141
  rules: ["@typescript-eslint/no-floating-promises"],
142
142
  },
143
143
  {
144
- name: "no-floating-promises: 即時関数はOK",
144
+ name: "no-floating-promises: an awaited Promise inside an IIFE is allowed",
145
145
  code: "(async () => { await Promise.resolve(1); })();",
146
146
  shouldError: false,
147
147
  rules: ["@typescript-eslint/no-floating-promises"],
148
148
  },
149
149
  {
150
- name: "no-unnecessary-condition: 不要な条件式はエラー",
150
+ name: "no-unnecessary-condition: an unnecessary condition is an error",
151
151
  code: "if (true) { console.log(1); }",
152
152
  shouldError: true,
153
153
  rules: ["@typescript-eslint/no-unnecessary-condition"],
154
154
  },
155
155
  {
156
- name: "no-unnecessary-condition: 無限ループ条件はOK",
156
+ name: "no-unnecessary-condition: a constant loop condition (infinite loop) is allowed",
157
157
  code: "while (true) { break; }",
158
158
  shouldError: false,
159
159
  rules: ["@typescript-eslint/no-unnecessary-condition"],
160
160
  },
161
161
  {
162
- name: "no-extraneous-class: 名前空間的クラスはOK",
162
+ name: "no-extraneous-class: a class used as a namespace is allowed",
163
163
  code: "class Namespace {}",
164
164
  shouldError: false,
165
165
  rules: ["@typescript-eslint/no-extraneous-class"],
166
166
  },
167
167
  {
168
- name: "no-useless-undefined: 無駄なundefinedはOK",
168
+ name: "no-useless-undefined: a useless undefined is allowed",
169
169
  code: "function f(x = undefined) { return undefined; }",
170
170
  shouldError: false,
171
171
  rules: ["unicorn/no-useless-undefined"],
172
172
  },
173
173
  {
174
- name: "catch-error-name: catch ブロックで error を使用するのは OK",
174
+ name: "catch-error-name: using error in a catch clause is allowed",
175
175
  code: "try { throw new Error(); } catch (error) { console.log(error); }",
176
176
  shouldError: false,
177
177
  rules: ["unicorn/catch-error-name"],
178
178
  },
179
179
  {
180
- name: "catch-error-name: catch ブロックで e など error/err 以外を使用するのはエラー",
180
+ name: "catch-error-name: a name other than error/err (e.g. e) in a catch clause is an error",
181
181
  code: "try { throw new Error(); } catch (e) { console.log(e); }",
182
182
  shouldError: true,
183
183
  rules: ["unicorn/catch-error-name"],
184
184
  },
185
185
  {
186
- name: "catch-error-name: err を使用するのは OK(常に許容)",
186
+ name: "catch-error-name: err is allowed (always accepted)",
187
187
  code: "try { throw new Error(); } catch (err) { console.log(err); }",
188
188
  shouldError: false,
189
189
  rules: ["unicorn/catch-error-name"],
190
190
  },
191
191
  {
192
- name: "catch-error-name: スコープ内に error 変数があるときに err を使用するのは OK(重複回避)",
192
+ name: "catch-error-name: err is allowed when an error variable exists in scope (avoids a clash)",
193
193
  code: "const error = 'msg'; try { throw new Error(); } catch (err) { console.log(error, err); }",
194
194
  shouldError: false,
195
195
  rules: ["unicorn/catch-error-name"],
196
196
  },
197
197
  {
198
- name: "filename-case: __tests__ ディレクトリはケースチェック対象外(OK)",
198
+ name: "filename-case: the __tests__ directory is excluded from case checks (allowed)",
199
199
  code: "export const a = 1;",
200
200
  shouldError: false,
201
201
  rules: ["unicorn/filename-case"],
202
202
  dir: "__tests__",
203
203
  },
204
204
  {
205
- name: "filename-case: __mocks__ ディレクトリはケースチェック対象外(OK)",
205
+ name: "filename-case: the __mocks__ directory is excluded from case checks (allowed)",
206
206
  code: "export const a = 1;",
207
207
  shouldError: false,
208
208
  rules: ["unicorn/filename-case"],
209
209
  dir: "__mocks__",
210
210
  },
211
211
  {
212
- name: "filename-case: src ディレクトリはケースチェック対象外(OK)",
212
+ name: "filename-case: the src directory is excluded from case checks (allowed)",
213
213
  code: "export const a = 1;",
214
214
  shouldError: false,
215
215
  rules: ["unicorn/filename-case"],
216
216
  dir: "src",
217
217
  },
218
218
  {
219
- name: "consistent-class-member-order: public フィールドの後に private フィールドが来てもエラーにならない(OK)",
219
+ name: "consistent-class-member-order: a private field after a public field is not an error (allowed)",
220
220
  code: "class Foo { public name: string = 'foo'; private id: number = 1; }",
221
221
  shouldError: false,
222
222
  rules: ["unicorn/consistent-class-member-order"],
223
223
  },
224
224
  {
225
- name: "prefer-await: .then() チェーンを使う非asyncな薄いラッパー関数はOK",
225
+ name: "prefer-await: a thin non-async wrapper using a .then() chain is allowed",
226
226
  code: "function getValue(): Promise<number> { return Promise.resolve(1).then((value) => value); }",
227
227
  shouldError: false,
228
228
  rules: ["unicorn/prefer-await"],
229
229
  },
230
230
  {
231
- name: "consistent-boolean-name: is/has等のプレフィックスがない真偽値変数名はOK",
231
+ name: "consistent-boolean-name: a boolean variable without an is/has prefix is allowed",
232
232
  code: "const enabled: boolean = true;",
233
233
  shouldError: false,
234
234
  rules: ["unicorn/consistent-boolean-name"],
235
235
  },
236
236
  {
237
- name: "no-non-function-verb-prefix: 動詞プレフィックスを持つ非関数の変数名はOK",
237
+ name: "no-non-function-verb-prefix: a non-function variable with a verb prefix is allowed",
238
238
  code: "const removeButton = 1;",
239
239
  shouldError: false,
240
240
  rules: ["unicorn/no-non-function-verb-prefix"],
241
241
  },
242
242
  {
243
- name: "prefer-number-coercion: parseInt による数値変換はOK",
243
+ name: "prefer-number-coercion: number conversion with parseInt is allowed",
244
244
  code: "const n = parseInt('1', 10);",
245
245
  shouldError: false,
246
246
  rules: ["unicorn/prefer-number-coercion"],
247
247
  },
248
248
  {
249
- name: "no-top-level-assignment-in-function: トップレベル変数へのキャッシュ代入はOK",
249
+ name: "no-top-level-assignment-in-function: caching into a top-level variable is allowed",
250
250
  code: "let cache: number | undefined; function setCache(): void { cache = 1; }",
251
251
  shouldError: false,
252
252
  rules: ["unicorn/no-top-level-assignment-in-function"],
253
253
  },
254
254
  {
255
- name: "prefer-unicode-code-point-escapes: \\uXXXX形式のエスケープはOK",
255
+ name: "prefer-unicode-code-point-escapes: the \\uXXXX escape form is allowed",
256
256
  code: "const s = '\\u00e9';",
257
257
  shouldError: false,
258
258
  rules: ["unicorn/prefer-unicode-code-point-escapes"],
259
259
  },
260
260
  {
261
- name: "no-break-in-nested-loop: ネストしたループ内のbreakによる早期脱出はOK",
261
+ name: "no-break-in-nested-loop: an early exit with break inside nested loops is allowed",
262
262
  code: "for (let i = 0; i < 3; i++) { for (let j = 0; j < 3; j++) { if (j === 1) break; } }",
263
263
  shouldError: false,
264
264
  rules: ["unicorn/no-break-in-nested-loop"],
265
265
  },
266
266
  {
267
- name: "class-reference-in-static-methods: staticメソッド内での非呼び出し位置のクラス名参照はOK",
267
+ name: "class-reference-in-static-methods: a non-call class-name reference inside a static method is allowed",
268
268
  code: "class Foo { static bar = 1; static create(): number { return Foo.bar; } }",
269
269
  shouldError: false,
270
270
  rules: ["unicorn/class-reference-in-static-methods"],
271
271
  },
272
272
  {
273
- name: "prefer-while-loop-condition: while(true) + 内部breakによる終了判定はOK",
273
+ name: "prefer-while-loop-condition: while (true) with an inner break as the exit check is allowed",
274
274
  code: "let i = 0; while (true) { if (i >= 5) break; i++; }",
275
275
  shouldError: false,
276
276
  rules: ["unicorn/prefer-while-loop-condition"],
277
277
  },
278
278
  {
279
- name: "prefer-location-assign: location.hrefへの代入はOK",
279
+ name: "prefer-location-assign: assigning location.href is allowed",
280
280
  code: "location.href = 'https://example.com';",
281
281
  shouldError: false,
282
282
  rules: ["unicorn/prefer-location-assign"],
283
283
  },
284
284
  {
285
- name: "max-nested-calls: スキーマ定義等のメソッドチェーンによる深いネストはOK",
285
+ name: "max-nested-calls: deeply nested calls such as schema definitions are allowed",
286
286
  code: "function a(x: number) { return b(x); } function b(x: number) { return c(x); } function c(x: number) { return d(x); } function d(x: number) { return x; } const result = a(b(c(d(1))));",
287
287
  shouldError: false,
288
288
  rules: ["unicorn/max-nested-calls"],
289
289
  },
290
290
  {
291
- name: "no-global-object-property-assignment: globalThisプロパティへの代入(テストのモック等)はOK",
291
+ name: "no-global-object-property-assignment: assigning a globalThis property (e.g. test mocks) is allowed",
292
292
  code: "globalThis.fetch = (() => Promise.resolve(new Response())) as typeof fetch;",
293
293
  shouldError: false,
294
294
  rules: ["unicorn/no-global-object-property-assignment"],
295
295
  },
296
296
  {
297
- name: "filename-case: checkDirectories: false のため kebab-case でないディレクトリ名もエラーにならない(OK)",
297
+ name: "filename-case: with checkDirectories: false, a directory name that is not kebab-case is not an error (allowed)",
298
298
  code: "export const a = 1;",
299
299
  shouldError: false,
300
300
  rules: ["unicorn/filename-case"],
@@ -302,21 +302,21 @@ async function main() {
302
302
  },
303
303
  ];
304
304
 
305
- // テスト用一時ファイルをsrc/配下に作成することで、flat configのfiles: ["**/*.ts"]に確実にマッチさせる
305
+ // Create temp files under src/ so they reliably match files: ["**/*.ts"] in the flat config.
306
306
  const srcDir = path.join(process.cwd(), "src");
307
307
  const tmpDir = path.join(srcDir, "__tmp__cli");
308
308
  if (!fs.existsSync(srcDir)) fs.mkdirSync(srcDir);
309
309
  if (!fs.existsSync(tmpDir)) fs.mkdirSync(tmpDir);
310
310
 
311
- // テストケースごとに dir(src 配下の任意のディレクトリ名)が指定されていれば、
312
- // unicorn/filename-case のディレクトリ名チェックを検証するために作成する
311
+ // Create each directory named by a test case's dir (under src) so the
312
+ // unicorn/filename-case directory name check can be verified.
313
313
  const extraDirs = new Set(
314
314
  testCases
315
315
  .map((testCase) => testCase.dir)
316
316
  .filter((dir) => dir && dir !== "__tmp__cli")
317
317
  );
318
- // クリーンアップ時に削除してよいのは、このテストで新規に作成したディレクトリのみとする
319
- // (既存の src/__tests__ 等を誤って削除しないようにするため)
318
+ // Only directories created by this test are removed during cleanup,
319
+ // so an existing src/__tests__ etc. is never deleted by mistake.
320
320
  const createdExtraDirs = new Set();
321
321
  for (const dir of extraDirs) {
322
322
  const dirPath = path.join(srcDir, dir);
@@ -326,7 +326,6 @@ async function main() {
326
326
  }
327
327
  }
328
328
 
329
- // テスト用tsconfig.jsonを作成
330
329
  const tsconfigPath = path.join(process.cwd(), "tsconfig.json");
331
330
  fs.writeFileSync(
332
331
  tsconfigPath,
@@ -347,11 +346,11 @@ async function main() {
347
346
  )
348
347
  );
349
348
 
350
- // テスト用にflat configファイル名をeslint.config.mjsに一時コピー
349
+ // Temporarily copy index.mjs to eslint.config.mjs so ESLint picks it up as the flat config
351
350
  const flatConfigPath = path.join(process.cwd(), "eslint.config.mjs");
352
351
  fs.copyFileSync(path.join(process.cwd(), "index.mjs"), flatConfigPath);
353
352
 
354
- // テスト用一時ファイルをすべて書き出す (プロセス起動は後で 1 回だけ行う)
353
+ // Write all temp files first; ESLint is started only once afterwards
355
354
  const tmpFilePaths = testCases.map((testCase, i) => {
356
355
  const { code, dir } = testCase;
357
356
  const kebabName = `test-${i}.ts`;
@@ -361,12 +360,9 @@ async function main() {
361
360
  return tmpFilePath;
362
361
  });
363
362
 
364
- // 全テストケースを 1 回の eslint 起動でまとめて検証する。
365
- // 以前はテストケースごとに `npx eslint` を並列起動していたため、
366
- // type-aware (typescript-eslint) なパーサ初期化がテストケース数分同時に走り、
367
- // メモリ枯渇・OOM killer の引き金になっていた。
368
- // 1 プロセス・1 回の TypeScript プログラム初期化にまとめることで、
369
- // プロセス数をテストケース数から 1 に減らし、メモリ使用量を大幅に下げる。
363
+ // Lint all test cases in a single ESLint process.
364
+ // Type-aware typescript-eslint initializes a TypeScript program per process,
365
+ // so one process keeps memory usage low (per-case processes risked OOM).
370
366
  const eslintBinPath = path.join(
371
367
  process.cwd(),
372
368
  "node_modules",
@@ -391,10 +387,9 @@ async function main() {
391
387
  );
392
388
  jsonOutput = stdout;
393
389
  } catch (error) {
394
- // eslint はテストケースに期待どおりのエラーがあると非ゼロの exit code を返すが、
395
- // これはテストとして期待される挙動なので、JSON 形式の stdout が取れていれば
396
- // 正常系として扱う。設定エラー等で stdout に JSON が出力されない場合は
397
- // ここでは判別せず、後続の JSON.parse で例外として検出させる。
390
+ // ESLint exits non-zero when a test case has the expected errors, which is normal here,
391
+ // so treat it as success as long as JSON was written to stdout.
392
+ // If stdout has no JSON (e.g. a config error), the later JSON.parse throws.
398
393
  if (error.stdout) {
399
394
  jsonOutput = error.stdout;
400
395
  } else {
@@ -412,9 +407,8 @@ async function main() {
412
407
  const tmpFilePath = tmpFilePaths[i];
413
408
  const fileResult = resultsByFilePath.get(tmpFilePath);
414
409
  if (!fileResult) {
415
- // 対象ファイルが eslint の結果に存在しない場合、空メッセージとして
416
- // 握りつぶすと「エラー 0 件 = OK」と誤ってパスしてしまう。
417
- // ファイルが実際には lint されていないことを示すため、例外として検出する。
410
+ // If the file is missing from the ESLint results, treating it as "no messages"
411
+ // would pass the case by mistake (0 errors = OK), so fail loudly instead.
418
412
  throw new Error(
419
413
  `ESLint did not return a result for temp file: ${tmpFilePath}`
420
414
  );
@@ -451,18 +445,18 @@ async function main() {
451
445
  pass++;
452
446
  } else {
453
447
  console.error(
454
- `❌ ${name} (期待: ${shouldError ? "エラー" : "OK"}, 実際: ${
455
- errorCount > 0 ? "エラー" : "OK"
448
+ `❌ ${name} (expected: ${shouldError ? "error" : "OK"}, actual: ${
449
+ errorCount > 0 ? "error" : "OK"
456
450
  })`
457
451
  );
458
452
  fail++;
459
453
  }
460
454
  if (relevantErrors && relevantErrors.length > 0) {
461
- console.error(` 対象ルールのエラー:`);
455
+ console.error(` Errors from the target rules:`);
462
456
  relevantErrors.forEach((e) => console.error(` ${e}`));
463
457
  }
464
458
  if (ignoredErrors && ignoredErrors.length > 0) {
465
- console.warn(` 無視したエラー:`);
459
+ console.warn(` Ignored errors:`);
466
460
  ignoredErrors.forEach((e) => console.warn(` ${e}`));
467
461
  }
468
462
  }
@@ -473,8 +467,8 @@ async function main() {
473
467
  fs.rmSync(path.join(srcDir, dir), { recursive: true });
474
468
  }
475
469
  fs.unlinkSync(tsconfigPath);
476
- console.log("\n--- サマリ ---");
477
- console.log(`成功: ${pass} / 失敗: ${fail} / 合計: ${testCases.length}`);
470
+ console.log("\n--- Summary ---");
471
+ console.log(`Passed: ${pass} / Failed: ${fail} / Total: ${testCases.length}`);
478
472
  }
479
473
 
480
474
  if (process.env.CI || process.env.TEST_CLI) {