问题描述
jslint可以通过运行'jslint --indent 4 test.js'来检查缩进,但是我无法在jshint中使用它.我按照以下步骤进行操作.
jslint can check indent by run 'jslint --indent 4 test.js', but I don't get it work in jshint.I do it as the follow steps.
- 通过"npm install -g jshint"安装jshint
- 编辑〜/.jshintrc,我的jshintrc看起来像
- install jshint through "npm install -g jshint"
- edit ~/.jshintrc, my jshintrc looks like
{..., "indent":4, "white":false, ...}
/jshint indent:4/
var condition, doSth;
if (condition)
doSth(); // expected to be invalid
推荐答案
这是版本问题.我使用2.5.0,而2.4可以正常工作.
It's a version problem. I use 2.5.0 while 2.4 works.
看看 https://github.com/jshint/jshint/releases/tag/2.5 .0 :
以下选项已删除:密码,onevar,密码失败,白色, gcl,smarttabs,尾随.除此之外,缩进不再 提供有关缩进级别的警告.您仍然可以使用它来 设置制表符宽度,但仅用于以下位置的字符位置 其他警告.如果您有这些选项,JSHint不会出错 配置或您的文件;它只会忽略它们.
The following options were removed: nomen, onevar, passfail, white, gcl, smarttabs, trailing. In addition to that, indent no longer provides warnings about indentation levels. You can still use it to set your tab-width but it will be used only for character locations in other warnings. JSHint won't error if you have these options in your config or your files; it will simply ignore them.
由于我们的贡献者,我们修复了解析器中的许多错误.我们 通过添加对模板的基本支持,还改善了我们对ES6的支持 文字.
Thanks to our contributors, we fixed a lot of bugs in our parser. We also improved our ES6 support by adding basic support for template literals.
这篇关于我怎样才能使jshint缩进选项起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!