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

352
Visualizações
eslint showing unexpected use of comma, no-sequences for an array

I have the following code, and eslint keeps showing no-sequences warning.

const full = {};

["firstname", "lastname", "spouse"].forEach(key => {
})

["cellphone", "phone"].forEach(key => {
})

Though the error is on the second forEach block, the warning only appears when I put the first forEach block. is this an eslint bug?

here is the link on eslint demo editor

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Since your code has no semicolon, you're basically trying to access an array in the first forEach:

["firstname", "lastname", "spouse"].forEach(key => {
})["cellphone", "phone"].forEach(key => {
})

Of course this is not correct. To fix this problem, just add a semicolon:

["firstname", "lastname", "spouse"].forEach(key => {
}); // Add a semicolon here

["cellphone", "phone"].forEach(key => {
}); // Here it is not necessary, but it is a good practice to avoid that kind of error

This will fix the error because semicolons point out the end of a statement, so ESLint will be able to understand that there are two different statements.

about 4 years ago · Juan Pablo Isaza Relatório

0

You are missing a semi-colon at the end of the first forEach call, so your code is equivalent to:

["firstname", "lastname", "spouse"].forEach(key => {
})["cellphone", "phone"].forEach(key => {})

That is attempting to get the value of the "phone" property of the return value of forEach (which is undefined). [] is interpreted to be bracket notation instead of an array literal due to automatic semicolon insertion. ESLint is pointing out the use of the comma operator in "cellphone", "phone", which results in attempting to read the "phone" property.

about 4 years ago · Juan Pablo Isaza Relatório

0

I didn't know object value access is actually multiline.

const data = {"key":123}

console.log(

  data

  ["key"]

)

Though on newline, Would actually work and print access data["key"] to print 123.

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