有jshint忽略某些文件的建立Twitter的引导时, [英] Have jshint ignore certain files when building Twitter Bootstrap

查看:282
本文介绍了有jshint忽略某些文件的建立Twitter的引导时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Twitter的引导与其它第三方的JS库,如 html5.js 从Word preSS'二十十二的主题时经常出现这种问题,在构建失败,因为 jshint (或的JSLint 结核病的previous版本我认为)抛出一个错误由于第三方JS库,如:

I often have this problem when using Twitter Bootstrap with other 3rd-party JS libraries, such as html5.js from WordPress' "Twenty Twelve" theme, where the build fails because jshint (or jslint in previous versions of TB I think) throws an error due to the third-party JS library, e.g.

\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

我想避免修改第三方库或修改TB的Makefile,因为这将导致在未来的升级问题;是我把第三方的JS文件到一个单独的文件夹唯一的选择。

I'd like to avoid modifying third-party libraries or modify TB's Makefile, as that'll cause problems for upgrades in the future; is my only option to put 3rd-party JS files into a separate folder.

有没有办法让jshint或TB的构建过程中忽略某些JS文件(或许通过一些 .jshintrc 的配置,我不知道吗?)?

Is there a way to get jshint or TB's build process to ignore certain JS files (perhaps through some .jshintrc configuration I'm not aware of?)?

推荐答案

因此​​,有忽略jshint文件的选项,但它没有设置在 .jshintrc 而是一个单独的文件 .jshintignore ,这是有道理的。然而,虽然jshint会寻找 .jshintrc 在项目的子目录, .jshintignore 必须在项目的根。因此,与Twitter的引导, .jshintrc / JS ,而 .jshintignore 需要放在 /

So there is an option to ignore files in jshint, but it's not set within .jshintrc but rather a separate file .jshintignore, which makes sense. However, while jshint will look for .jshintrc in your project's subdirectories, .jshintignore needs to be in the project root. So with Twitter Bootstrap, .jshintrc is in /js while .jshintignore needs to be placed in /.

所以要解决这个问题,我的问题 / jshintignore 需要包含:

So to solve the problem in my question /.jshintignore needs to contain:

js/html5.js
js/theme-customizer.js

这就是它!

这篇关于有jshint忽略某些文件的建立Twitter的引导时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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