简体   繁体   English

我可以添加关于空行缩进的 ESlint 规则吗?

[英]Can I add ESlint rule about indent on empty lines?

在此处输入图像描述

I'm using 2 spaces for indentation and I want to keep it also no empty lines.我正在使用 2 个空格进行缩进,并且我希望它也没有空行。 Currently ESLint shows warning message Delete '··' (prettier/prettier) if there is an indent.当前 ESLint 显示警告消息Delete '··' (prettier/prettier)如果有缩进。

How can I add a rule disables warning about indent on empty lines?如何添加一条规则来禁用关于空行缩进的警告?

You could use the plugin indent-empty-lines to enforce indentation on empty lines.您可以使用插件indent-empty-lines在空行上强制缩进。

The rule indent-empty-lines enforces an indentation of 2 spaces by default.默认情况下,规则indent-empty-lines强制缩进 2 个空格。

If you need to configure this for a different number of spaces, eg 4, here is an example of the ESLint configuration:如果您需要为不同数量的空格配置它,例如 4,这里是 ESLint 配置的示例:

"rules": {
  "indent-empty-lines/indent-empty-lines": [ "error", 4]
}

More information about the configuration here .有关配置的更多信息,请点击此处

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

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