@book000/eslint-config 1.14.61 → 1.15.0
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 +27 -3
- package/package.json +1 -1
- package/test.mjs +9 -2
package/index.mjs
CHANGED
|
@@ -84,10 +84,34 @@ 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
|
+
],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
// Vue コンポーネントは PascalCase の命名規則が慣習であるため、
|
|
103
|
+
// .vue ファイルに限り pascalCase を適用する。
|
|
104
|
+
// unicorn/filename-case のルールは ESLint flat config の「最後に定義したルールが勝つ」
|
|
105
|
+
// 仕様により、プロジェクト側でオーバーライドするとここで設定した checkDirectories: false
|
|
106
|
+
// も上書きされてしまう。
|
|
107
|
+
// そのため、プロジェクト側で filename-case を再定義せずにこのデフォルト設定を
|
|
108
|
+
// 使い続けられるよう、あらかじめ checkDirectories: false も含めて設定する。
|
|
109
|
+
files: ["**/*.vue"],
|
|
110
|
+
rules: {
|
|
111
|
+
"unicorn/filename-case": [
|
|
112
|
+
"error",
|
|
113
|
+
{ case: "pascalCase", checkDirectories: false },
|
|
114
|
+
],
|
|
91
115
|
},
|
|
92
116
|
},
|
|
93
117
|
{
|
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
|
},
|