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

标签 javascript node.js vue.js nuxt.js eslint

我喜欢使用 Javascript 文件缩进 3 个空格。但 Eslint 不喜欢这种方式,它给了我一些缩进警告。 我应该如何修复它?

当我们与团队合作时,其他团队成员可能会以不同的方式配置他们的编辑器和格式化程序。这种情况下我应该如何配置Eslint? 如果我不希望 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

评论的澄清:

“我不使用 prettier”

最佳答案

您可以使用以下代码进行配置

"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

关于javascript - 如何配置Eslint缩进规则为3个空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70530897/

相关文章:

javascript - 在 VueJS 中,你在哪里监听发出的事件?

javascript - 从页面隐藏 vue 路由器

javascript - 使用 JavaScript 读取浏览器窗口大小,然后将其传递给 C#

javascript - 将数组转换为修改后的对象

javascript - 在内容页面上触发 .Net 中的 OnLoad Javascript

node.js - 使用 mocha.js 加入来自多个文件的测试

node.js - 如何反编译Bytenode "jsc"文件?

javascript - 显示/隐藏单个 Div 的简便方法?

node.js - node express es6 sinon stub 中间件不工作

vue.js - 将 .vuepress 文件夹存储在另一个目录中