Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Description
Default parameters and default values are only used if the parameter or property is undefined (either because its value is undefined or because it is missing). So if we know that a function parameter or property can never be undefined, then we also know that the default is never actually used. This can be used to detect useless defaults.
Fail Cases
// React props destructuring
function Bar({ foo = "" }: { foo: string }) { /* ... */ }
// destructuring assignment
const { foo = "" } = { foo: "bar" }
// default parameter
[1, 2, 3].map((a = 42) => a + 1)
Pass Cases
// React props destructuring
function Bar({ foo }: { foo: string }) { /* ... */ }
function Bar({ foo = "" }: { foo?: string }) { /* ... */ }
// destructuring assignment
const { foo } = { foo: "bar" }
// default parameter
[1, 2, 3].map((a) => a + 1)
[1, 2, 3, undefined].map((a = 42) => a + 1)
Additional Info
This rule requires strict null checks to be enabled.
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Description
Default parameters and default values are only used if the parameter or property is
undefined(either because its value isundefinedor because it is missing). So if we know that a function parameter or property can never beundefined, then we also know that the default is never actually used. This can be used to detect useless defaults.Fail Cases
Pass Cases
Additional Info
This rule requires strict null checks to be enabled.