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

61
Vistas
Prettier with top level async

There is a way to use async top level with prettier ?

I'm actually trying to ignore my await top level with /prettier ignore but prettier, ignore this line ...

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can get Prettier to ignore line(s) with the following comment.

// prettier-ignore
const res = await asyncFunc();

This will make Prettier ignore the following line.

If you, however, want to make Prettier ignore multiple lines, then you can do something like this:

// prettier-ignore
{
const res = await asyncFunc();
const data = await getData();
}

This will make Prettier not format the code surrounded by { }. The comments and brackets/parentheses might help you with making Prettier ignore top-level await.


EDIT: The easiest option, though, is to just use an async function (until Prettier supports it).

(async (param) => {
  await getData(param);
})()

The anonymous async function above will call itself straight away, so it'll act like await has no async function.

With this method, Prettier will be happy. 🙂

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