4

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?

Theraloss
  • 660
  • 2
  • 8
  • 26

2 Answers2

5

Take a look at globals sections at .eslintrc config.

{
    "globals": {
        "use": false
    }
}
Alexey B.
  • 11,570
  • 2
  • 45
  • 71
1

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

James Maa
  • 1,532
  • 7
  • 19