Skip to content

Commit

Permalink
Docs: Clarify prefer-destructuring array/object difference (fixes #9970
Browse files Browse the repository at this point in the history
…) (#11851)
  • Loading branch information
OliverSieweke authored and platinumazure committed Jun 18, 2019
1 parent 81c3823 commit 65faa04
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/rules/prefer-destructuring.md
Expand Up @@ -16,6 +16,11 @@ One key is `VariableDeclarator` and the other is `AssignmentExpression`, which c

The rule has a second object with a single key, `enforceForRenamedProperties`, which determines whether the `object` destructuring applies to renamed variables.

**Note**: It is not possible to determine if a variable will be referring to an object or an array at runtime. This rule therefore guesses the assignment type by checking whether the key being accessed is an integer. This can lead to the following possibly confusing situations:

- Accessing an object property whose key is an integer will fall under the category `array` destructuring.
- Accessing an array element through a computed index will fall under the category `object` destructuring.

Examples of **incorrect** code for this rule:

```javascript
Expand Down

0 comments on commit 65faa04

Please sign in to comment.