gpt4 book ai didi

javascript - 无法加载配置 "prettier"以从

转载 作者:行者123 更新时间:2023-12-05 00:31:07 25 4
gpt4 key购买 nike

我使用 Prettier 作为格式化程序,所以我配置了 eslint-plugin-prettier .我做了一切从this guide但是当我尝试运行 ng lint 时,我收到了这个错误:

An unhandled exception occurred: Failed to load config "prettier" to extend from.
Referenced from: ...\node_modules\eslint-plugin-prettier\eslint-plugin-prettier.js
这是我的 .eslintrc.json :
{
"root": true,
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["tsconfig.json", "e2e/tsconfig.json"],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:prettier/recommended"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@angular-eslint/template/recommended"],
"rules": {}
},
{
"files": ["*.html"],
"excludedFiles": ["*inline-template-*.component.html"],
"extends": ["plugin:prettier/recommended"],
"rules": {
"prettier/prettier": ["error", { "parser": "angular" }]
}
}
]
}
来自我的 package.json :
"devDependencies": {
"@angular-devkit/build-angular": "^12.2.13",
"@angular-eslint/builder": "12.7.0",
"@angular-eslint/eslint-plugin": "12.7.0",
"@angular-eslint/eslint-plugin-template": "12.7.0",
"@angular-eslint/schematics": "12.7.0",
"@angular-eslint/template-parser": "12.7.0",
"@angular/cli": "~12.2.13",
"@angular/compiler-cli": "~12.2.13",
"@angular/language-service": "~12.2.13",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"@types/lodash-es": "^4.17.4",
"@types/node": "^12.20.4",
"@typescript-eslint/eslint-plugin": "4.28.2",
"@typescript-eslint/parser": "4.28.2",
"eslint": "^7.26.0",
"eslint-plugin-prettier": "^4.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.8",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ncp": "^2.0.0",
"prettier": "^2.4.1",
"protractor": "~7.0.0",
"rimraf": "^3.0.2",
"ts-node": "~8.3.0",
"typescript": "^4.3.5"
}

最佳答案

我通过安装 eslint-config-prettier 解决了这个问题作为开发依赖项(没有代码更改 - 它在安装后开箱即用)。

npm install --save-dev eslint-config-prettier

关于javascript - 无法加载配置 "prettier"以从,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70126114/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com