Why do I get the ESLint warning Use array destructuring for the following line?
tmpObj[item].sample = urls[key][0];
You must be having the prefer-destructuring flag on in your config. Destructuring was added as a part of ES6.
From the docs about the rule:
With JavaScript ES6, a new syntax was added for creating variables from an array index or object property, called destructuring. This rule enforces the usage of destructuring instead of accessing a property through a member expression.
The rule considers this as incorrect:
// With `array` enabled
var foo = array[0];
// With `object` enabled
var foo = object.foo;
var foo = object['foo'];
And this as correct:
// With `array` enabled
var [ foo ] = array;
var foo = array[someIndex];
// With `object` enabled
var { foo } = object;
In your case, the below should do it. You are still accessing the first element this way.
[tmpObj[item].sample] = urls[key];
PS : You can always switch off the flag.