Why this matters
Destructuring makes code more readable by clearly showing which properties are being accessed and their defaults.
Ensure that destructuring is used in function parameters where applicable. This improves readability by clearly showing accessed properties and default values.
Destructuring makes code more readable by clearly showing which properties are being accessed and their defaults.
Side-by-side examples engineers can pattern-match during review.
function configure(options: { key?: string, value?: number }) {
const key = options.key || "defaultKey";
const value = options.value || 0;
}function configure({ key = "defaultKey", value = 0 }: { key?: string; value?: number }) {}function configure(options: { key?: string, value?: number }) {
const key = options.key || "defaultKey";
const value = options.value || 0;
}function configure({ key = "defaultKey", value = 0 }: { key?: string; value?: number }) {}From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.