Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

344
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda