Eslint角和茉莉花:未定义no-undef [英] Eslint angular and jasmine: is not defined no-undef
问题描述
我正在尝试使用angular,eslint:recommended和jasmine插件推荐的设置来减少我的角度代码.但是我得到的不是关于茉莉花的东西的定义错误. 我的eslint文件如下所示:
I am trying to lint my angular code using angular, eslint:recommended and the jasmine plugin recommended settings. However I get is not defined errors on the jasmine stuff. My eslint file looks like this:
{
"plugins": ["jasmine"],
"extends": ["angular", "eslint:recommended",
"plugin:jasmine/recommended"],
"rules": {
"quotes": [ 2, "single"],
"strict": [2, "global"],
"semi": ["error", "always"],
"angular/on-watch": "warn"
}
}
我收到以下错误:
3:1错误'describe'未定义no-undef
3:1 error 'describe' is not defined no-undef
4:5错误'it'未定义为un-undef
4:5 error 'it' is not defined no-undef
5:9错误'期望'未定义no-undef
5:9 error 'expect' is not defined no-undef
7:5错误'it'未定义为no-undef
7:5 error 'it' is not defined no-undef
未定义8:9错误期望" no-undef
8:9 error 'expect' is not defined no-undef
在我的package.json
中,我的eslint
版本是2.3.0
,而eslint-plugin-jasmine
的版本是1.8.1
.对于eslint-config-angular
,我也有0.5.0
版本,对于eslint-plugin-angular
,也有1.0.0
版本.
And in my package.json
I have version 2.3.0
for eslint
and 1.8.1
for eslint-plugin-jasmine
. I also have version 0.5.0
for eslint-config-angular
and 1.0.0
for eslint-plugin-angular
.
我也尝试了在我的eslint
文件中未指定"plugins": ["jasmine"]
的情况,但是随后出现一条错误消息,告诉我未定义茉莉花规则(例如Definition for rule 'jasmine/no-focused-tests' was not found
).
I have also tried without specifying the "plugins": ["jasmine"]
in my eslint
file but then I get an error telling me the jasmine rules are not defined (eg Definition for rule 'jasmine/no-focused-tests' was not found
).
推荐答案
添加
"env": {
"jasmine": true
}
解决了问题.这是我通过eslint茉莉花插件的github页面得到的建议.
solved the problem. This was the suggestion that i got through the github page of the eslint jasmine plugin.
这篇关于Eslint角和茉莉花:未定义no-undef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!