@book000/eslint-config 1.13.26 → 1.14.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 +6 -0
- package/package.json +1 -1
- package/test.mjs +18 -0
package/index.mjs
CHANGED
|
@@ -76,6 +76,12 @@ export default tseslint.config(
|
|
|
76
76
|
"unicorn/no-useless-undefined": "off",
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
|
+
{
|
|
80
|
+
// catch ブロックのエラー変数名を err に変更する(JS/TS 両方に適用)
|
|
81
|
+
rules: {
|
|
82
|
+
"unicorn/catch-error-name": ["error", { name: "err" }],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
79
85
|
{
|
|
80
86
|
ignores: ["dist", "output", "node_modules", "data", "logs", "coverage"],
|
|
81
87
|
},
|
package/package.json
CHANGED
package/test.mjs
CHANGED
|
@@ -155,6 +155,24 @@ async function main() {
|
|
|
155
155
|
shouldError: false,
|
|
156
156
|
rules: ["unicorn/no-useless-undefined"],
|
|
157
157
|
},
|
|
158
|
+
{
|
|
159
|
+
name: "catch-error-name: catch ブロックで err を使用するのは OK",
|
|
160
|
+
code: "try { throw new Error(); } catch (err) { console.log(err); }",
|
|
161
|
+
shouldError: false,
|
|
162
|
+
rules: ["unicorn/catch-error-name"],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "catch-error-name: catch ブロックで error を使用するのはエラー",
|
|
166
|
+
code: "try { throw new Error(); } catch (error) { console.log(error); }",
|
|
167
|
+
shouldError: true,
|
|
168
|
+
rules: ["unicorn/catch-error-name"],
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "catch-error-name: スコープ内に error 変数があるときに err を使用するのは OK",
|
|
172
|
+
code: "const error = 'msg'; try { throw new Error(); } catch (err) { console.log(error, err); }",
|
|
173
|
+
shouldError: false,
|
|
174
|
+
rules: ["unicorn/catch-error-name"],
|
|
175
|
+
},
|
|
158
176
|
];
|
|
159
177
|
|
|
160
178
|
// テスト用一時ファイルをsrc/配下に作成することで、flat configのfiles: ["**/*.ts"]に確実にマッチさせる
|