Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore specific error for eslint in the whole project

I'm using AdonisJs (NodeJS framework) and they created a function called use to import file like they'd be namespaces, for example use('App/Services/User') instead of require('../app/Services/User').

The problem is that eslint will throw the error 'use' is not defined no-undef.

At this time I have two ways:

  1. Putting an eslint comment to disable alert for that line in each file, but it's annoying
  2. Use require instead of use, but it's a lot useful the function.

Is there a way to disable "one time for all" the specific no-undef for the use function in the whole project?

like image 637
Theraloss Avatar asked Mar 07 '23 23:03

Theraloss


2 Answers

Take a look at globals sections at .eslintrc config.

{
    "globals": {
        "use": false
    }
}
like image 75
Alexey B. Avatar answered Mar 21 '23 00:03

Alexey B.


You can configure you eslint on your .eslintrc.json Reference on their official page: https://eslint.org/docs/user-guide/configuring

For no-undef rule, you can add global in the configuration by

{
    "globals": {
        "var1": true,
        "var2": false
    }
}

Also specified in their documentation: https://eslint.org/docs/user-guide/configuring#specifying-globals

like image 36
James Maa Avatar answered Mar 20 '23 22:03

James Maa