简体   繁体   中英

What is the first argument to eslint "indent" rule

I have a simple config on the project that uses 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").
What about the first '2'?

Old documentation uses '2' here while New documentation uses "error"

"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
  • "warn" or 1 - turn the rule on as a warning (doesn't affect exit code)
  • "error" or 2 - turn the rule on as an error (exit code is 1 when triggered)

2 is the same as "error".

I found a reference on the github repository: https://github.com/eslint/eslint#configuration

"off" or 0 - turn the rule off

"warn" or 1 - turn the rule on as a warning (doesn't affect exit code)

"error" or 2 - turn the rule on as an error (exit code will be 1)

This explain all options for the first param.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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