unicorn/no-useless-undefined Pedantic
What it does
Prevents usage of undefined in cases where it would be useless.
WARNING
This rule can conflict with the default behaviors of the eslint/array-callback-return and eslint/getter-return rules. For both rules, you can set the allowImplicit option to avoid conflicts.
Why is this bad?
undefined is the default value for new variables, parameters, return statements, etc, so specifying undefined in these cases is pointless.
Examples
Examples of incorrect code for this rule:
let foo = undefined;
const noop = () => undefined;Examples of correct code for this rule:
let foo;
const noop = () => {};Configuration
This rule accepts a configuration object with the following properties:
checkArguments
type: boolean
default: true
Whether to check for useless undefined in function call arguments.
checkArrowFunctionBody
type: boolean
default: true
Whether to check for useless undefined in arrow function bodies.
How to use
To enable this rule using the config file or in the CLI, you can use:
{
"rules": {
"unicorn/no-useless-undefined": "error"
}
}oxlint --deny unicorn/no-useless-undefined