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
JavaScript Code Linting tool to find Variables which are initialised but might not be used due to condition

I have the following JavaScript code,

var foo = {
    company: "ABC",
    name: "John"
};

var att = "";

function test(ob, i) {
    var m = JSON.stringify(ob);
    if (i < 10) {
        att = att + m;
    }
}

test(foo, 20);

In above code, var m = JSON.stringify(ob); line is unnecessary initialisation of variable when i < 10 is not true. A better code will be to move the initialization inside the if condition.

I am not able to find a code linter that can detect such scenarios. In such cases, I want a warning that variable might not be used. Does anyone know any linting tool that can do this?

I tried

  1. ES Lint
  2. JS Lint
about 4 years ago · Juan Pablo Isaza
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