简体   繁体   English

eslint“缩进”规则的第一个参数是什么

[英]What is the first argument to eslint "indent" rule

I have a simple config on the project that uses eslit我在使用 eslit 的项目上有一个简单的配置

"rules": {
    "indent": [2, 2, {"SwitchCase": 1}]
}

According to documentation, second '2' is for number of spaces used for indent (can be set to 4 or 6 or "tab").根据文档,第二个“2”是用于缩进的空格数(可以设置为 4 或 6 或“制表符”)。
What about the first '2'?第一个“2”呢?

Old documentation uses '2' here while New documentation uses "error"旧文档在此处使用“2”,而新文档使用“错误”

"indent": ["error", "tab"]

Both say nothing about it.两者都没有说什么。 What is it for?它是做什么用的?

See the general documentation for configuring rules :请参阅配置规则的一般文档

  • "off" or 0 - turn the rule off "off" 或 0 - 关闭规则
  • "warn" or 1 - turn the rule on as a warning (doesn't affect exit code) "warn" 或 1 - 打开规则作为警告(不影响退出代码)
  • "error" or 2 - turn the rule on as an error (exit code is 1 when triggered) "error" 或 2 - 将规则作为错误打开(触发时退出代码为 1)

2 is the same as "error". 2 与“错误”相同。

I found a reference on the github repository: https://github.com/eslint/eslint#configuration我在github存储库上找到了一个参考: https : //github.com/eslint/eslint#configuration

"off" or 0 - turn the rule off "off" 或 0 - 关闭规则

"warn" or 1 - turn the rule on as a warning (doesn't affect exit code) "warn" 或 1 - 打开规则作为警告(不影响退出代码)

"error" or 2 - turn the rule on as an error (exit code will be 1) "error" 或 2 - 将规则作为错误打开(退出代码将为 1)

This explain all options for the first param.这解释了第一个参数的所有选项。

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

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