【问题标题】:linq.js throws errors when grunt is executed执行 grunt 时 linq.js 抛出错误
【发布时间】:2014-03-15 22:32:14
【问题描述】:

在我的 index.html 中,我添加了这一行:

<script src="scripts/vendor/linq.js."></script>

我的 Web Storm IDE 说 linq.js 无法解析。

但路径肯定是正确的,我检查了很多次......

当我运行 grunt 时,它说有 51 个错误以:

开头

似乎 webstorm 有其他的代码格式,因为 grunt 正在使用......

app/scripts/vendor/linq.js
  line 12  col 5   Missing "use strict" statement.
  line 16  col 5   Expected '}' to have an indentation at 7 instead at 5.
  line 22  col 26  Strings must use singlequote.
  line 26  col 5   Expected '}' to have an indentation at 7 instead at 5.
...

可能是什么错误?

更新

查看图片 linq.js 的路径是否正确。

当我运行 grunt 时,它因 51 个问题而中止,见上文...

更新 2:

我现在已经删除了 &lt;script linq.js...&gt; 并重新运行 grunt 仍然是同样的错误。

所以在我看来,我有足够的理由在脚本文件夹下有一个 .js 文件,它在某种程度上没有正确格式化为 jshint 任务,因为在这里它被中止了。

我还是找到了这个链接:JSHint behave differently in Webstorm and Grunt

看起来和我很相似,我会试试看!

更新 3

这些是完整的错误列表:

我不想仅仅为了完成我的 IDE 的代码格式设置而更改第 3 方脚本,这太愚蠢了...

app/scripts/vendor/linq.js

 line 12  col 5   Missing "use strict" statement.
  line 16  col 5   Expected '}' to have an indentation at 7 instead at 5.
  line 22  col 26  Strings must use singlequote.
  line 26  col 5   Expected '}' to have an indentation at 7 instead at 5.
  line 29  col 25  Strings must use singlequote.
  line 35  col 28  Expected '===' and instead saw '=='.
  line 35  col 37  Expected '{' and instead saw 'return'.
  line 38  col 17  Expected 'var' to have an indentation at 15 instead at 17.
  line 39  col 17  Expected 'if' to have an indentation at 15 instead at 17.
  line 39  col 23  Expected '!==' and instead saw '!='.
  line 40  col 21  Expected 'return' to have an indentation at 17 instead at 21.
  line 41  col 17  Expected '}' to have an indentation at 15 instead at 17.
  line 43  col 17  Expected 'if' to have an indentation at 15 instead at 17.
  line 43  col 44  Strings must use singlequote.
  line 44  col 21  Expected 'var' to have an indentation at 17 instead at 21.
  line 44  col 51  Strings must use singlequote.
  line 44  col 56  Strings must use singlequote.
  line 46  col 21  Expected 'var' to have an indentation at 17 instead at 21.
  line 47  col 21  Expected 'var' to have an indentation at 17 instead at 21.
  line 48  col 21  Expected 'while' to have an indentation at 17 instead at 21.
  line 48  col 62  Expected '!==' and instead saw '!='.
  line 49  col 25  Expected 'var' to have an indentation at 19 instead at 25.
  line 50  col 25  Expected 'if' to have an indentation at 19 instead at 25.
  line 51  col 29  Expected 'maxLength' to have an indentation at 21 instead at 29.
  line 52  col 25  Expected '}' to have an indentation at 19 instead at 25.
  line 53  col 21  Expected '}' to have an indentation at 17 instead at 21.
  line 55  col 21  Expected 'var' to have an indentation at 17 instead at 21.
  line 56  col 21  Expected 'for' to have an indentation at 17 instead at 21.
  line 57  col 25  Expected 'var' to have an indentation at 19 instead at 25.
  line 57  col 40  Strings must use singlequote.
  line 58  col 25  Expected 'for' to have an indentation at 19 instead at 25.
  line 59  col 29  Expected 'dollar' to have an indentation at 21 instead at 29.
  line 59  col 42  Strings must use singlequote.
  line 60  col 25  Expected '}' to have an indentation at 19 instead at 25.
  line 61  col 25  Expected 'argArray' to have an indentation at 19 instead at 25.
  line 62  col 21  Expected '}' to have an indentation at 17 instead at 21.
  line 64  col 21  Expected 'var' to have an indentation at 17 instead at 21.
  line 64  col 71  Strings must use singlequote.
  line 66  col 21  Expected 'f' to have an indentation at 17 instead at 21.
  line 66  col 37  The Function constructor is a form of eval.
  line 66  col 53  Strings must use singlequote.
  line 67  col 21  Expected 'funcCache' to have an indentation at 17 instead at 21.
  line 68  col 21  Expected 'return' to have an indentation at 17 instead at 21.
  line 69  col 17  Expected '}' to have an indentation at 15 instead at 17.
  line 71  col 21  Expected 'var' to have an indentation at 17 instead at 21.
  line 72  col 21  Expected 'f' to have an indentation at 17 instead at 21.
  line 72  col 37  The Function constructor is a form of eval.
  line 72  col 56  Strings must use singlequote.
  line 73  col 21  Expected 'funcCache' to have an indentation at 17 instead at 21.
  line 74  col 21  Expected 'return' to have an indentation at 17 instead at 21.
  line 74  col 21  Too many errors. (2% scanned).

【问题讨论】:

  • 这些看起来像JSHint warnings。而且,linq.js 可能不遵循您项目的语法指南。那么,也许是ignore it
  • grunt 由于这个“警告”而中止,所以它们实际上不是警告。这是一个真正的问题。
  • 正如@JonathanLonowski 所说,您不应该对第 3 方库进行 linting。从您的 JSHint 任务中排除 vendor 子目录。
  • @JonathanLonowski 是的,我不得不忽略 linq.js。那是我问题的解决方案,但随后开始出现其他错误... ;-)

标签: javascript gruntjs webstorm


【解决方案1】:

script 标记的src 属性中的linq.js 之后有一个额外的.。 Grunt 错误看起来像是 linting 警告,而不是错误(更新:我的意思是,不是代码中的错误)。

【讨论】:

  • 我删除了多余的 .但仍然网络风暴说:未解析的变量或类型的linq。我已经上传了截图!
  • 似乎您出于某种原因在这些 URL 中注入了 javascript。请问你能附上你的.html吗?如果不可能,我建议创建支持票
  • 问题似乎是 webstorm 有其他代码格式作为 grunt 似乎使用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多