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

171
Visualizações
I'm getting ESLINT warnings when declaring more than one private class method in JS, why?

If I declare just one private method in a class then ESLINT compiles with no warnings, but... ESLINT emits one extra warning for each new private method I declare in that same class.

For instance, ESLINT emits 2 warnings for a classe declared like this:

class Clazz {
  #methodOne() { /*...*/ }
  #methodTwo() { /*...*/ }
  #methodThree() { /*...*/ }
}

ESLINT output:

WARNING  Compiled with 1 warning                                                                                                                                   10:14:26 PM

Module Warning (from ./node_modules/eslint-loader/index.js):

/Users/***/Clazz.js
  3:3  error  Duplicate name ''  no-dupe-class-members
  4:3  error  Duplicate name ''  no-dupe-class-members

✖ 2 problems (2 errors, 0 warnings)

I wonder if I'm doing something wrong or should I just ignore these warnings.


package.json:

{
  //...
  "eslint": "^6.7.2",
  "eslint-plugin-vue": "^6.2.2",
  "babel-eslint": "^10.1.0",
  "@vue/cli-plugin-eslint": "^3.1.1",
  //...
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I had the same problem and found a workaround. Define your private methods like this:

class Clazz {
  #methodOne = function() { /*...*/ }
  #methodTwo = function() { /*...*/ }
  #methodThree = function() { /*...*/ }
}

and the linter warnings/errors will go away.

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