Skip to content

eslint/no-redeclare Pedantic

What it does

Disallow variable redeclaration

Why is this bad?

n JavaScript, it’s possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

Example

javascript
var a = 3;
var a = 10;

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-redeclare
json
{
  "rules": {
    "no-redeclare": "error"
  }
}

References

Released under the MIT License.