Skip to main content

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...of loops.
  • Standalone function parameters.
  • Variable declarations.
  • Assignment expressions.

Each check can be independently toggled.

Why Use This Rule?

  1. Encourages descriptive parameter names that convey the whole object's role.
  2. Makes property access explicit so readers can trace where each value comes from.
  3. 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.

OptionTypeDefaultDescription
assignmentExpressionsbooleantrueBan destructuring in assignment expressions.
callbackParamsbooleantrueBan destructuring in callback parameters of array methods.
forOfLoopsbooleantrueBan destructuring in for...of loops.
functionParamsbooleantrueBan destructuring in standalone function/method parameters.
ignoreFilesstring[][]File patterns to skip.
variableDeclarationsbooleantrueBan 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 — The forOfLoops check applies to all for...of destructuring. Access entries by index instead, or set forOfLoops: false.
  • Want to allow destructuring in variable declarations only — Set variableDeclarations: false while keeping the other checks enabled.