Ignore specific error for eslint in the whole project
Asked Answered
I

2

5

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?

Infrequent answered 26/9, 2017 at 7:57 Comment(0)
B
7

Take a look at globals sections at .eslintrc config.

{
    "globals": {
        "use": false
    }
}
Bilge answered 26/9, 2017 at 8:1 Comment(0)
T
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

Truss answered 26/9, 2017 at 8:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.