How to import environment exported by eslint plugin?

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

How to 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 } 

into the configuration, but then I got

 Environment key "angular/mocks" is unknown 
+5
source share
1 answer

You get this error because ESLint can only use environments open by plugins, not configs. You must register eslint-plugin-angular as a plugin in your configuration file:

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

If this still does not work, you should run ESLint with the --debug flag to find out if your configuration is loaded correctly and the environment is applied. You can also run ESLint with the --print --print-config flag, followed by the path to some file in your repository, to see all the rules and global variables that ESLint will use when dragging this file.

+2
source

Source: https://habr.com/ru/post/1263796/


All Articles