简体   繁体   English

如何使jshint缩进选项工作

[英]How can I make jshint indent options work

jslint can check indent by run 'jslint --indent 4 test.js', but I don't get it work in jshint. jslint可以通过运行'jslint --indent 4 test.js'检查缩进,但我不能在jshint中使用它。 I do it as the follow steps. 我按照以下步骤进行操作。

  1. install jshint through "npm install -g jshint" 通过“npm install -g jshint”安装jshint
  2. edit ~/.jshintrc, my jshintrc looks like 编辑〜/ .jshintrc,我的jshintrc看起来像
     {..., "indent":4, "white":false, ...} {...,“缩进”:4,“白色”:假,...} 
  3. edit js file test.js 编辑js文件test.js
    \n/ jshint indent:4 / / jshint缩进:4 /\nvar condition, doSth; var condition,doSth;\nif (condition) 如果(条件)\ndoSth(); doSth(); // expected to be invalid //预计无效\n
  4. run jshint test.js, but the indent checking is not working. 运行jshint test.js,但缩进检查不起作用。 The 2 spaces started line can pass the check. 开始行的2个空格可以通过检查。

It's a version problem. 这是一个版本问题。 I use 2.5.0 while 2.4 works. 我使用2.5.0而2.4工作。

Take a look at https://github.com/jshint/jshint/releases/tag/2.5.0 : 看看https://github.com/jshint/jshint/releases/tag/2.5.0

We decided to label it 2.5.0 because—while it's backwards compatible—there are a few major changes. 我们决定将它标记为2.5.0因为 - 虽然它向后兼容 - 但有一些重大变化。

The following options were removed: nomen, onevar, passfail, white, gcl, smarttabs, trailing. 删除了以下选项: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; 如果你的配置或文件中有这些选项,JSHint不会出错; it will simply ignore them. 它会简单地忽略它们。

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. 我们还通过添加对模板文字的基本支持来改进我们的ES6支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM