3

我正在尝试制作简单的组件。但是当我点击ctrl + s它时:

在此处输入图像描述

警告和错误是这样的:

[eslint] 预期结束标记以匹配开头的缩进。(react/jsx-closing-tag-location) [eslint] 预期缩进 4 个空格字符,但找到 2 个。 (react/jsx-indent)

我的.eslintrc

{
  "extends": "airbnb",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true,
      "experimentalObjectRestSpread": true
    }
  },
  "rules": {
    "max-len": ["warn", 120],
    "indent": ["warn", 2],
    "react/jsx-indent": ["warn", 4],
    "react/forbid-prop-types": 0,
    "semi": [2, "never"],
    "no-underscore-dangle": 0,
    "no-console": 0,
    "linebreak-style": 0,
    "comma-dangle": [2, {
      "arrays": "never",
      "objects": "always",
      "imports": "never",
      "exports": "never",
      "functions": "ignore"
    }]
  },
  "globals": {
    "localStorage": true
  },
  "env": {
    "browser": true,
    "node": true
  }
}

怎么了?

4

2 回答 2

0

你确定你没有启用其他格式化程序 - 比如 prettier - 吗?

于 2022-02-25T15:29:05.970 回答
-1

在您的 gif 中,永远不会以相同的缩进关闭。那应该这样做:

const App = () => (
  <button>
    <span>asd</span>
  </button>
)

在你的 gif 中,你有

const App = () => (
   <button>
     <span>asd</span>
     </button>
)

或者

const App = () => (
     <button>
       <span>asd</span>
   </button>
)
于 2018-04-03T15:04:56.327 回答