gpt4 book ai didi

javascript - 如何使 jshint 缩进选项起作用

转载 作者:IT老高 更新时间:2023-10-28 23:15:56 25 4
gpt4 key购买 nike

jslint 可以通过运行“jslint --indent 4 test.js”来检查缩进,但我无法在 jshint 中使用它。我按照以下步骤进行操作。

  1. 通过“npm install -g jshint”安装jshint
  2. 编辑 ~/.jshintrc,我的 jshintrc 看起来像
    {..., "indent":4, "white":false, ...}
  3. 编辑js文件test.js
    /jshint indent:4/var condition, doSth;if (condition)doSth(); // expected to be invalid
  4. 运行 jshint test.js,但缩进检查不起作用。 2个空格开始的行可以通过检查。

最佳答案

这是版本问题。我使用 2.5.0 而 2.4 工作。

看看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.

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.

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.

关于javascript - 如何使 jshint 缩进选项起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23097316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com