![](/img/trans.png)
[英]Failed to load plugin 'prettier' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-prettier'
[英]What is the purpose of eslint-plugin-prettier?
我已經在我的 eslint 配置中安裝了 airbnb 風格指南。 所以對於airbnb,建議對字符串使用單引號。 但是通過在擴展中添加 plugin:prettier/recommended 會禁用單引號。 那么我如何確保遵守規則。
.eslintrc.json
{
"env": {
"browser": true,
"es2021": true,
"jest": true
},
"extends": [
"eslint:recommended",
"airbnb-base",
"airbnb",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["react"],
"rules": {
"react/react-in-jsx-scope": 0,
"react/jsx-filename-extension": 0,
"no-unused-vars": "error",
"no-console": "error",
"import/prefer-default-export": 0
}
}
你應該能夠在規則中覆蓋
"rules": {
'prettier/prettier': ['error', { singleQuote: true }]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.