[英]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. 我看到,在https://github.com/Gillespie59/eslint-plugin-angular/blob/master/environments.js款
mocks
eslint-插件棱角声明inject
全局变量。
How do I import these environment settings from my application? 如何从我的应用程序导入这些环境设置? I tried
"extends": "angular"
but eslint still complains: 我试过
"extends": "angular"
分明"extends": "angular"
但是eslint仍然抱怨:
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. 您收到此错误是因为ESLint只能使用插件而不是配置所暴露的环境。 You have to register eslint-plugin-angular as plugin in your config file:
您必须在配置文件中注册eslint-plugin-angular作为插件:
"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. 如果仍然无效,则应使用
--debug
标志运行ESLint,以查看配置是否已正确加载并应用了环境。 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. 您还可以使用
--print-config
标志运行ESLint,后跟存储库中某个文件的路径,以查看ESLint在使用该文件时将使用的所有规则和全局变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.