简体   繁体   中英

How to configure Eslint indent rules for 3 space?

I like to use my Javascript file indentation to 3 spaces. But Eslint doesn't like this way and it gives me some indentation warning. 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? And also what if I don't want Eslit to give me any indentation error.

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

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