无法加载配置“更漂亮”以从
Posted
技术标签:
【中文标题】无法加载配置“更漂亮”以从【英文标题】:Failed to load config "prettier" to extend from 【发布时间】:2022-01-04 14:46:29 【问题描述】:我使用 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,还有recommended-configuration 【参考方案1】:我通过安装 eslint-config-prettier 作为开发依赖项解决了这个问题(没有代码更改 - 安装后它开箱即用)。
npm install --save-dev eslint-config-prettier
【讨论】:
以上是关于无法加载配置“更漂亮”以从的主要内容,如果未能解决你的问题,请参考以下文章