No Destructuring
Disallow destructuring patterns to encourage descriptive parameter names and explicit property access.
Summary
The no-destructuring rule reports destructuring patterns in five contexts:
- Callback parameters.
for...ofloops.- Standalone function parameters.
- Variable declarations.
- Assignment expressions.
Each check can be independently toggled.
Why Use This Rule?
- Encourages descriptive parameter names that convey the whole object's role.
- Makes property access explicit so readers can trace where each value comes from.
- Keeps callback bodies readable with named intermediate constants.
Examples
Configuration
Options
warning
ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.
| Option | Type | Default | Description |
|---|---|---|---|
assignmentExpressions | boolean | true | Ban destructuring in assignment expressions. |
callbackParams | boolean | true | Ban destructuring in callback parameters of array methods. |
forOfLoops | boolean | true | Ban destructuring in for...of loops. |
functionParams | boolean | true | Ban destructuring in standalone function/method parameters. |
ignoreFiles | string[] | [] | File patterns to skip. |
variableDeclarations | boolean | true | Ban destructuring in const/let/var declarations. |
Autofix
Autofix is not available for this rule. Flagged code must be updated manually.
Troubleshooting
- Warning fires on
Object.entries()destructuring — TheforOfLoopscheck applies to allfor...ofdestructuring. Access entries by index instead, or setforOfLoops: false. - Want to allow destructuring in variable declarations only — Set
variableDeclarations: falsewhile keeping the other checks enabled.