Pular para o conteúdo

noUselessCatchBinding

Este conteúdo não está disponível em sua língua ainda.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noUselessCatchBinding": "error"
}
}
}
}

Disallow unused catch bindings.

This rule disallows unnecessary catch bindings in accordance with ECMAScript 2019. See also: the ECMAScript 2019 “optional catch binding” feature in the language specification.

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.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

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.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

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.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Unsafe fix: Remove the catch binding.

3 │ }·catch·({·unused1,·unused2·})·{}
-----------------------
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 {}