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

155
Visualizações
eslint no-use-before-define rules does not work in node.js

I use node.js 12.3.0 and i had installed eslint 7.0.0 by npm. So i wrote the .eslintrc.js like below.

module.exports = {
    "env": {
        "commonjs": true,
        "es6": true,
        "node": true
    },
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parserOptions": {
        "ecmaVersion": 12
    },
    "rules": {
        "semi": ["error", "always", {"omitLastInOneLineBlock": true }],
        "no-shadow-restricted-names" : "error",
        "no-unused-vars": ["warn", { "vars": "all" }],
        "no-redeclare": ["error", { "builtinGlobals": true }],
        "no-use-before-define": ["error", { "functions": true, "classes": true, "variables": true }]
    }
};

As you know, i already added "no-use-before-define" but it didn't work. All another eslint rules are worked fine but only "no-use-before-define" didn't check anythings.

Here is my examples js file.

let c = qwertqwert(); //As you know qwerqwert is not defined. I want to check this.
a = 123123; //I don't want to allow assign any value to variable before declaration.
b = asdfafasfdasdfas; //Also i need to check any undefined variable or functions are used.

Does "no-use-before-define" can check this?

It seems only can check when i use the variable or function before define or declaration.

Func(); //I use(call) first.

//But the define statement is after.
function Func()
{
   return 10;
}

Above code had checked fine by eslint but it is meaningless. Because i want let eslint to check usage of undefined functions or value.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

if you define eslint should show the error you should write a rule like

  • if you don't want rule you can remove it or skip rule by file

     "no-use-before-define": [
         "error",
         {
             "functions": false,
             "classes": false,
             "variables": false
         }
     ],
    

NOTE :- i am using extension of airbnb

 extends: [
'airbnb-base',

],

it works for me

node js :- 14.17.6

eslint :- 7.12.1+

enter image description here

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