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

130
Visualizações
Default parentheses upon object destructuring

I've recently run into a problem that I can't fix.

I'm writing some code where I have to access data with the help of an input range field. I want to write a getData function which looks like this:

function getData() {
  let currentValue = slider.value;
  let index = currentValue - 1;
  return { pageViews, monthlyCost, leftPercentage } = viewsData[index];
}

this works BUT everytime I save my file visual studio code adds a parenthesis around the destructuring assigment like this:

return ({ pageViews, monthlyCost, leftPercentage } = viewsData[index]);

and after that the code doesn't work

can somebody help me with fixing this behavior in my code editor? thanks (:

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

I believe you have the prettier extension install in your IDE. To prevent this automatic behaviour for that specific line of code, you can use prettier-ignore and exclude the next line from formatting.

function getData() {
  let currentValue = slider.value;
  let index = currentValue - 1;

  // prettier-ignore
  return { pageViews, monthlyCost, leftPercentage } = viewsData[index];
}
about 4 years ago · Santiago Gelvez 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