简体   繁体   中英

How to import environment exported by eslint plugin?

I see that in https://github.com/Gillespie59/eslint-plugin-angular/blob/master/environments.js subsection mocks eslint-plugin-angular declares the inject global variable.

How do I import these environment settings from my application? I tried "extends": "angular" but eslint still complains:

7:14  error  'inject' is not defined  no-undef

I tried adding:

"env": {
    "angular/mocks": true
}

to the config, but then I got

Environment key "angular/mocks" is unknown

You are getting this error because ESLint can only use environments exposed by plugins and not configs. You have to register eslint-plugin-angular as plugin in your config file:

"plugins": ["angular"],
"env": {
  "angular/mocks": true
}

If that still doesn't work, you should run ESLint with --debug flag to see if your config is correctly loaded and environment is applied. You can also run ESLint with --print-config flag followed by a path to some file in your repository to see all of the rules and global variables that ESLint will use when linting that file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM