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

345
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 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