[Vuejs]-Eslint – Use array destructuring in my vue project

3👍

Take a look at this: eslint prefer-destructuring rule:

This rule enforces usage of destructuring instead of accessing a
property through a member expression.

As the examples you have seen, you should change your:

this.report = newVal[0]

To this instead:

[this.report] = newVal;

To make it clear for you, if newVal has 4 items, and you want to store first 2 items into different variables, instead of doing:

const a = newVal[0];
const b = newVal[1];

Using destructuring, you should do:

const [a, b] = newVal;

Leave a comment