【问题标题】:Unexpected behavior from React eslintReact eslint 的意外行为
【发布时间】:2020-08-27 15:18:18
【问题描述】:

我正在尝试对 React 应用程序进行一些更改,但我正在编译失败并给我这些错误

 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

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

【问题讨论】:

  • 你要么改变 ESLINT 规则,要么改变你的编辑器设置 :)
  • @Eddy 尝试使用npm run lint -- --fix 修复您遇到的所有 ESLint 错误。

标签: reactjs jsx eslint


【解决方案1】:

两个选项

  • 禁用 lint
  • 更改您的 Eslint 规则

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

option+shift+F [for mac]

alt+shift+F [适用于 Windows]

【讨论】:

    猜你喜欢
    • 2018-04-16
    • 2023-03-24
    • 2021-10-08
    • 2021-07-29
    • 1970-01-01
    • 2020-09-06
    • 1970-01-01
    • 2018-11-27
    • 2018-03-22
    相关资源
    最近更新 更多