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
To use the rule in ESLint, you would use the unprefixed plugin name, followed by a slash, followed by the rule name. So if this plugin were named eslint-plugin-myplugin , then in your configuration you'd refer to the rule by the name myplugin/dollar-sign . Example: "rules": {"myplugin/dollar-sign": 2} .
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names. All the goodness that the ES2015+ static module syntax intends to provide, marked up in your editor.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With