Eslint angular 和 jasmine:未定义 no-undef [英] Eslint angular and jasmine: is not defined no-undef

查看:37
本文介绍了Eslint angular 和 jasmine:未定义 no-undef的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 angular、eslint:recommended 和 jasmine 插件推荐的设置来整理我的 angular 代码.但是我得到的不是茉莉花东西上的定义错误.我的 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 错误描述"未定义 no-undef

3:1 error 'describe' is not defined no-undef

4:5 错误它"未定义 no-undef

4:5 error 'it' is not defined no-undef

5:9 错误 'expect' 未定义 no-undef

5:9 error 'expect' is not defined no-undef

7:5 错误它"未定义 no-undef

7:5 error 'it' is not defined no-undef

8:9 错误 'expect' 未定义 no-undef

8:9 error 'expect' is not defined no-undef

在我的 package.json 我有 eslint 的版本 2.3.01.8.1 的版本eslint-plugin-jasmine.我也有 0.5.0 版本 eslint-config-angular1.0.0 版本 eslint-plugin-angular.

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"] 但我收到一条错误消息,告诉我 jasmine 规则未定义(例如未找到规则jasmine/no-focused-tests"的定义).

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 jasmine插件的github页面得到的建议.

solved the problem. This was the suggestion that i got through the github page of the eslint jasmine plugin.

这篇关于Eslint angular 和 jasmine:未定义 no-undef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆