innerWang / blogs

1 stars 0 forks source link

windows 下运行项目 提示 Delete `CR` prettier/prettier #29

Open innerWang opened 4 years ago

innerWang commented 4 years ago

package.json相关信息:

"eslint": "5.4.0",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-prettier": "^2.6.2",
"prettier": "^1.14.2",

.eslintrc.js相关配置:

{
  plugins: [
    "react-hooks"
  ],
  extends: [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:prettier/recommended",
    "prettier/react"
  ],
  rules: {
    "prettier/prettier": [
      "error",
      {
        singleQuote: true,
        semi: false,
      }
    ]
  }
}

目前发现的解决方法:

若未安装依赖,未启动项目,则按照步骤1、2操作即可; 若已安装依赖并运行项目,按照步骤1、2、3操作。

修改完之后的.eslintrc.js

{
  plugins: ["react-hooks", "prettier"],
  extends: ["eslint:recommended", "plugin:react/recommended", "prettier"],
  rules: {
    "prettier/prettier": "error",
    "react/prop-types": 0,
    "react-hooks/rules-of-hooks": "error"
  }
}

新增的.prettierrc:

{
  "singleQuote": true,
  "semi": false,
  "endOfLine": "auto"
}
innerWang commented 4 years ago

CRA2 使用 prettier use-both方案的

对于提示该错误的项目,已经安装依赖的,再配置.prettierrc然后eslint --fix并不好使,删掉node_modules重新安装可行