【问题标题】:Is there an indent option for jslint or has it been removed?jslint 是否有缩进选项或已被删除?
【发布时间】:2021-08-12 08:31:16
【问题描述】:

缩进选项似乎不再被识别。

http://linterrors.com/js/option-indent

这仍然是 jslint 的一个选项还是已被删除?

我尝试使用网络界面here 以多种语法对其进行设置,但我不断收到错误消息。

错误的选项“缩进”。

/*jslint
    bitwise,
    browser:true,
    indent: 2
*/

function test () {
  const test = "hello SO";
}

研究:

github 上的更新日志似乎很小,并没有提及。

【问题讨论】:

  • 一定是被删了,因为任何时候有人提出再添加,作者都会回复“不,谢谢。”here,或here )。如果您想要更可定制的东西,ESLint 提供了很多选项,这就是我使用的选项
  • 两个都读过,但似乎仍然模棱两可。
  • 它是removed in 2015 in this commit(打开jslint.js 文件的差异并查找“缩进”)。这是allowed options as of nowindent 不是其中的一部分。现在还有另一个:white,它只是一个接受空格而不是制表符的布尔值,但这会禁用缩进检查
  • 感谢帮助。您究竟是如何找到这些信息的?我无法从这两个链接中辨别出任何东西。我只是查看了更新日志并没有发现任何相关内容 - 更新添加到问题。你怎么知道在更新日志之外寻找什么?你能分解你的过程吗?
  • 人类会犯错,有时会忘记做事。当手动编写文档时(也适用于变更日志),它不会以任何方式链接到其背后的实际代码。作者必须记住反映文档中的更改。源代码是您可以确定是最新的唯一参考。这就是为什么一个好的做法是从代码中自动生成文档而不是手动编写它。并根据提交消息生成更改日志。因此,任何时候我从文档中不清楚的地方,我只看代码

标签: javascript syntax whitespace lint jslint


【解决方案1】:

编辑:jslint 最近使用指令 /*jslint indent2*/ 添加了 2 空格缩进支持

我是jslint 维护者。玩弄了一个补丁重新引入指令 /*jslint indent2*/ 以使 jslint 更容易被已经使用 2 空格缩进 here 的项目访问。

您可以为它发布功能请求@https://github.com/jslint-org/jslint/issues 以加快进程。

最新的 jslint 有以下指令:

// Optional directives.
// .... /*jslint beta*/ .......... Enable experimental features.
// .... /*jslint bitwise*/ ....... Allow bitwise operators.
// .... /*jslint browser*/ ....... Assume browser environment.
// .... /*jslint convert*/ ....... Allow conversion operators.
// .... /*jslint couch*/ ......... Assume CouchDb environment.
// .... /*jslint debug*/ ......... Include jslint stack-trace in warnings.
// .... /*jslint devel*/ ......... Allow console.log() and friends.
// .... /*jslint eval*/ .......... Allow eval().
// .... /*jslint for*/ ........... Allow for-statement.
// .... /*jslint getset*/ ........ Allow get() and set().
// .... /*jslint long*/ .......... Allow long-lines.
// .... /*jslint name*/ .......... Allow weird property-names.
// .... /*jslint node*/ .......... Assume Node.js environment.
// .... /*jslint single*/ ........ Allow single-quote strings.
// .... /*jslint test_internal_error*/ ... Test jslint's internal-error
// ........................................... handling-ability.
// .... /*jslint this*/ .......... Allow 'this'.
// .... /*jslint unordered*/ ..... Allow unordered cases, params, properties.
// .... /*jslint variable*/ ...... Allow unordered const and let declarations
// ................................... that are not at top of function-scope.
// .... /*jslint white: true...... Allow messy whitespace.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-19
    • 1970-01-01
    • 2012-03-17
    相关资源
    最近更新 更多