@book000/eslint-config 1.14.60 → 1.14.62
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.
- package/index.mjs +11 -3
- package/package.json +1 -1
- package/test.mjs +17 -4
package/index.mjs
CHANGED
|
@@ -84,10 +84,18 @@ export default tseslint.config(
|
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
|
-
//
|
|
88
|
-
//
|
|
87
|
+
// unicorn v65 からファイル名に加えてディレクトリ名もチェック対象となったが、
|
|
88
|
+
// ignore オプションはマッチしたセグメントを含むファイル全体をスキップするため
|
|
89
|
+
// ファイル名チェック自体まで無効化してしまう。
|
|
90
|
+
// そのため checkDirectories: false でディレクトリ名チェックのみ無効化する。
|
|
91
|
+
// src 等の慣習的なディレクトリ名でエラーが起きる問題もこれで解消される。
|
|
92
|
+
// __tests__ や __mocks__ 等のダブルアンダースコアディレクトリは引き続き
|
|
93
|
+
// ignore で対象外とする(テストファイル等はファイル名チェックも不要なため)。
|
|
89
94
|
rules: {
|
|
90
|
-
"unicorn/filename-case": [
|
|
95
|
+
"unicorn/filename-case": [
|
|
96
|
+
"error",
|
|
97
|
+
{ checkDirectories: false, ignore: [/^__[\w-]+__$/] },
|
|
98
|
+
],
|
|
91
99
|
},
|
|
92
100
|
},
|
|
93
101
|
{
|
package/package.json
CHANGED
package/test.mjs
CHANGED
|
@@ -194,9 +194,16 @@ async function main() {
|
|
|
194
194
|
dir: "__mocks__",
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
|
-
name: "filename-case:
|
|
197
|
+
name: "filename-case: src ディレクトリはケースチェック対象外(OK)",
|
|
198
198
|
code: "export const a = 1;",
|
|
199
|
-
shouldError:
|
|
199
|
+
shouldError: false,
|
|
200
|
+
rules: ["unicorn/filename-case"],
|
|
201
|
+
dir: "src",
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "filename-case: checkDirectories: false のため kebab-case でないディレクトリ名もエラーにならない(OK)",
|
|
205
|
+
code: "export const a = 1;",
|
|
206
|
+
shouldError: false,
|
|
200
207
|
rules: ["unicorn/filename-case"],
|
|
201
208
|
dir: "notKebabCaseDir",
|
|
202
209
|
},
|
|
@@ -215,9 +222,15 @@ async function main() {
|
|
|
215
222
|
.map((testCase) => testCase.dir)
|
|
216
223
|
.filter((dir) => dir && dir !== "__tmp__cli")
|
|
217
224
|
);
|
|
225
|
+
// クリーンアップ時に削除してよいのは、このテストで新規に作成したディレクトリのみとする
|
|
226
|
+
// (既存の src/__tests__ 等を誤って削除しないようにするため)
|
|
227
|
+
const createdExtraDirs = new Set();
|
|
218
228
|
for (const dir of extraDirs) {
|
|
219
229
|
const dirPath = path.join(srcDir, dir);
|
|
220
|
-
if (!fs.existsSync(dirPath))
|
|
230
|
+
if (!fs.existsSync(dirPath)) {
|
|
231
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
232
|
+
createdExtraDirs.add(dir);
|
|
233
|
+
}
|
|
221
234
|
}
|
|
222
235
|
|
|
223
236
|
// テスト用tsconfig.jsonを作成
|
|
@@ -322,7 +335,7 @@ async function main() {
|
|
|
322
335
|
|
|
323
336
|
fs.unlinkSync(flatConfigPath);
|
|
324
337
|
fs.rmSync(tmpDir, { recursive: true });
|
|
325
|
-
for (const dir of
|
|
338
|
+
for (const dir of createdExtraDirs) {
|
|
326
339
|
fs.rmSync(path.join(srcDir, dir), { recursive: true });
|
|
327
340
|
}
|
|
328
341
|
fs.unlinkSync(tsconfigPath);
|