我有一个项目,同时安装了prettier和eslint。问题是,当我保存文件时,eslint会自动更改文件的格式,并且似乎有一些规则与prettier冲突。解决方案是什么?
这是prettier格式:
保存后,文件会变成这样:
此外,这是eslintrc文件。
这是prettier格式:
![进入图像描述](https://istack.dev59.com/kXDa4.webp)
![进入图像描述](https://istack.dev59.com/Npfpe.webp)
{
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }]
},
"overrides": [
{
"files": ["**/*.tsx"],
"rules": {
"react/prop-types": "off"
}
}
],
"settings": {
"react": {
"version": "detect"
}
},
"ignorePatterns": ["coverage/", "node_modules/", "src/serviceWorker.ts"]
}