首页 > 解决方案 > React eslint 的意外行为

问题描述

我正在尝试在 React App 中进行一些更改,但我正在编译失败并给我这些错误

 Expected indentation of 2 spaces but found 4              indent
  Line 7:1:   Expected indentation of 2 spaces but found 4              indent
  Line 8:9:   Expected indentation of 6 space characters but found 8    react/jsx-indent
  Line 9:13:  Expected indentation of 10 space characters but found 12  react/jsx-indent
  Line 11:1:  Expected indentation of 2 spaces but found 4              indent

如果我添加额外的空间,我什至会得到一个错误,请分享我如何删除这些限制。

标签: reactjsjsxeslint

解决方案


两种选择

  • 禁用 lint
  • 改变你的 Eslint 规则

如果您使用 VS 代码作为编辑器,则只需运行文档格式命令,例如

option+shift+F [for mac]

alt+shift+F[用于窗户]


推荐阅读