如何禁用esLint的缩进检查?

Dav*_*art 34 eslint

缩进规则似乎无法禁用; 如何(在配置设置中)禁用此规则?谢谢.

Vin*_*ack 56

"off"在您的配置中将规则设置为:

"rules": {
  "indent": "off"
}
Run Code Online (Sandbox Code Playgroud)

您可以在此处阅读更多文档.

  • `"缩进":0`显然有效,但为了便于阅读和与官方文档保持一致,推荐的写入方式是"缩进":"关闭"`. (14认同)
  • http://shripalsoni.com/blog/configure-eslint-in-visual-studio-code/ 把它放在```.eslintrc``` (2认同)

Gia*_*ati 10

对于缩进,我通常在配置中激活它并仅在某些需要花哨缩进的文件中禁用它,因此我使用注释

/* eslint-disable indent */
Run Code Online (Sandbox Code Playgroud)

这是值得大家注意的是这个作品也有standardjs,我用了很多,以及任何其他棉短绒搭载eslint.例如,我创建了一个较轻的standardjs版本,称为标准js减去React部分的标准(是的,这是自动推广部分,但我希望分享这个对我以外的许多人都有用:)使用了很棒的标准引擎这依赖于eslint,所以一切都工作,没有额外的代码行.


Saa*_*ran 5

我必须添加更多规则。为react和关闭掉毛jsx-indent

"rules": {
    "indent": "off",
    "react/jsx-indent": "off",
    "react/jsx-indent-props": "off"
}
Run Code Online (Sandbox Code Playgroud)