Skip to content

unicorn/no-useless-undefined Pedantic

🛠️ An auto-fix is available for this rule.

What it does

Do not use useless undefined.

Why is this bad?

undefined is the default value for new variables, parameters, return statements, etc… so specifying it doesn't make any difference.

Examples

Examples of incorrect code for this rule:

javascript
let foo = undefined;

Examples of correct code for this rule:

javascript
let foo;

How to use

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

bash
oxlint --deny unicorn/no-useless-undefined
json
{
  "rules": {
    "unicorn/no-useless-undefined": "error"
  }
}

References

Released under the MIT License.