Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

355
Vistas
ESLint Warning: Use array destructuring

Why do I get the ESLint warning Use array destructuring for the following line?

tmpObj[item].sample = urls[key][0];
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

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.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda