Lès*_*sté 39 makefile build jslint jshint twitter-bootstrap
当我将Twitter Bootstrap与其他第三方JS库一起使用时,我常常遇到这个问题,例如html5.js
来自WordPress的"Twenty Twelve"主题,其中构建失败,因为jshint
(或者jslint
我以前认为TB的先前版本)由于第三个而引发错误-party JS库,例如
\n##################################################
Building Bootstrap...
##################################################\n
js/html5.js: line 3, col 122, Expected ')' to match '(' from line 3 and instead
saw ','.
js/html5.js: line 3, col 140, Expected an identifier and instead saw ')'.
js/html5.js: line 4, col 101, eval is evil.
js/html5.js: line 6, col 369, Confusing use of '!'.
js/html5.js: line 6, col 422, Confusing use of '!'.
js/html5.js: line 7, col 61, 'b' is already defined.
js/theme-customizer.js: line 26, col 26, Use '===' to compare with ''.
7 errors
make: *** [build] Error 1
Run Code Online (Sandbox Code Playgroud)
我想避免修改第三方库或修改TB的Makefile,因为这会在将来导致升级问题; 是我将第三方JS文件放入单独文件夹的唯一选择.
有没有办法让jshint或TB的构建过程忽略某些JS文件(可能通过.jshintrc
我不知道的某些配置?)?
Lès*_*sté 96
因此,有一个选项可以忽略jshint中的文件,但它没有设置在内.jshintrc
,而是一个单独的文件.jshintignore
,这是有道理的.但是,虽然jshint将.jshintrc
在项目的子目录中查找,但.jshintignore
需要在项目根目录中.因此,与Twitter的引导,.jshintrc
是/js
同时.jshintignore
需要放置在/
.
所以要在我的问题中解决问题/.jshintignore
需要包含:
js/html5.js
js/theme-customizer.js
Run Code Online (Sandbox Code Playgroud)
就是这样!
Jus*_*tin 34
作为Lèsemajesté 答案的补充,您也可以在JS中编写这些注释,jshint将忽略其间的代码:
// Code here will be linted with JSHint.
/* jshint ignore:start */
// Code here will be linted with ignored by JSHint.
/* jshint ignore:end */
Run Code Online (Sandbox Code Playgroud)
或者,如果您只是希望JSHint不检查单行:
// jshint ignore:line
Run Code Online (Sandbox Code Playgroud)
参考:jshint docs
归档时间: |
|
查看次数: |
29823 次 |
最近记录: |