Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!