noUselessCatchBinding
¥Summary
-
规则生效日期:
v2.2.3¥Rule available since:
v2.2.3 -
诊断类别:
lint/nursery/noUselessCatchBinding¥Diagnostic Category:
lint/nursery/noUselessCatchBinding -
此规则包含 unsafe 修复程序。
¥This rule has an unsafe fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
¥How to configure
{ "linter": { "rules": { "nursery": { "noUselessCatchBinding": "error" } } }}¥Description
禁止使用未使用的 catch 绑定。
¥Disallow unused catch bindings.
此规则禁止根据 ECMAScript 2019 使用不必要的 catch 绑定。另请参阅:ECMAScript 2019 语言规范中的“可选 catch 绑定”特性。
¥This rule disallows unnecessary catch bindings in accordance with ECMAScript 2019. See also: the ECMAScript 2019 “optional catch binding” feature in the language specification.
¥Examples
¥Invalid
try { // Do something} catch (unused) {}code-block.js:3:9 lint/nursery/noUselessCatchBinding FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This catch binding is unused.
1 │ try {
2 │ // Do something
> 3 │ } catch (unused) {}
│ ^^^^^^^^
4 │
ℹ Since ECMAScript 2019, catch bindings are optional; you can omit the catch binding if you don’t need it.
ℹ Unsafe fix: Remove the catch binding.
3 │ }·catch·(unused)·{}
│ ---------
try { // Do something} catch ({ unused }) {}code-block.js:3:9 lint/nursery/noUselessCatchBinding FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This catch binding is unused.
1 │ try {
2 │ // Do something
> 3 │ } catch ({ unused }) {}
│ ^^^^^^^^^^^^
4 │
ℹ Since ECMAScript 2019, catch bindings are optional; you can omit the catch binding if you don’t need it.
ℹ Unsafe fix: Remove the catch binding.
3 │ }·catch·({·unused·})·{}
│ -------------
try { // Do something} catch ({ unused1, unused2 }) {}code-block.js:3:9 lint/nursery/noUselessCatchBinding FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This catch binding is unused.
1 │ try {
2 │ // Do something
> 3 │ } catch ({ unused1, unused2 }) {}
│ ^^^^^^^^^^^^^^^^^^^^^^
4 │
ℹ Since ECMAScript 2019, catch bindings are optional; you can omit the catch binding if you don’t need it.
ℹ Unsafe fix: Remove the catch binding.
3 │ }·catch·({·unused1,·unused2·})·{}
│ -----------------------
¥Valid
try { // Do something} catch (used) { console.error(used);}try { // Do something} catch ({ used }) { console.error(used);}try { // Do something} catch ({ used, unused }) { console.error(used);}try { // Do something} catch {}¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号