简体   繁体   English

如何为 3 个空格配置 Eslint 缩进规则?

[英]How to configure Eslint indent rules for 3 space?

I like to use my Javascript file indentation to 3 spaces.我喜欢使用我的 Javascript 文件缩进 3 个空格。 But Eslint doesn't like this way and it gives me some indentation warning.但是 Eslint 不喜欢这种方式,它给了我一些缩进警告。 How should I fix it?我应该如何解决它?

And when we work with team other team members maybe configure their editor and formatter differently.当我们与团队合作时,其他团队成员可能会以不同的方式配置他们的编辑器和格式化程序。 In this case how should I configure Eslint?在这种情况下我应该如何配置 Eslint? And also what if I don't want Eslit to give me any indentation error.如果我不希望 Eslit 给我任何缩进错误怎么办。

error  Expected indentation of 2 spaces but found 3

warning  Expected indentation of 2 spaces but found 3 spaces
warning  Expected indentation of 4 spaces but found 6 spaces
warning  Expected indentation of 4 spaces but found 6 spaces
warning  Expected indentation of 2 spaces but found 3 spaces

Clarification from comments:评论澄清:

"I don't use prettier" “我不使用更漂亮的”

you can use the below code to configure it你可以使用下面的代码来配置它

"indent": ["error", 4]   // Indent with 4 spaces

"react/jsx-indent": ["error", 4] // Indent JSX with 4 spaces

"react/jsx-indent-props": ["error", 4]   // Indent props with 4 spaces

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

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