将angular从9升级到10并运行npm run lint
之后,我得到了
实验
> ng lint --fix
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(tsConfig).
我的angular.json是:
..."lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"eslintConfig": ".eslintrc.js",
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": ["**/node_modules/**"]
}
},...
这是我的package.json-devDependencies:
..."@angular-devkit/build-angular": "~0.1001.1",
"@angular-eslint/builder": "0.3.0-beta.1",
"@angular-eslint/eslint-plugin": "0.0.1-alpha.32",
"@angular-eslint/eslint-plugin-template": "0.0.1-alpha.32",
"@angular-eslint/template-parser": "0.0.1-alpha.32",
"@angular/cli": "~10.1.0",
"@angular/compiler-cli": "~10.1.1",
"@angular/language-service": "~10.1.1",
"@types/file-saver": "^2.0.1",
"@types/google-libphonenumber": "^7.4.19",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@typescript-eslint/eslint-plugin": "2.31.0",
"@typescript-eslint/parser": "2.31.0",
"codelyzer": "^5.2.2",
"eslint": "^7.6.0",
"eslint-config-airbnb-typescript": "^8.0.2",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-prettier": "^3.1.4",...
当我用'lintFilePatterns'替换'tsConfig'时,cli会说:
error Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: tsconfig.app.json.
The extension for the file (.json) is non-standard. You should add "parserOptions.extraFileExtensions" to your config
我应该更新什么?
答案 0 :(得分:3)
我在Angular 8中也遇到了同样的问题。问题是在angular-eslint中的构建器不支持tsConfig选项:https://github.com/angular-eslint/angular-eslint/blob/master/packages/builder/src/schema.d.ts
我的解决方案是仅删除tsConfig并将其“ include”文件复制到“ lintFilePatterns”。我在项目根目录创建了.eslintignore,在其中列出了我拥有的所有“排除”文件(即node_modules)。
我的angular.json:
..."lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"eslintConfig": ".eslintrc.js",
"lintFilePatterns": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
},...
然后是.eslintignore
node_modules/*
那让ng lint为我工作
答案 1 :(得分:0)
粘在文档https://github.com/angular-eslint/angular-eslint
上,问题出在angular的版本上。
当前,angular-eslint
支持旧的打字稿(<= 3.10),因此我们需要使用角度版本<10.0.6(10.1.x使用的是打字稿4.0)。
我认为我需要等待兼容性,在解决此冲突时会更新。如果遇到与我相同的问题,可以尝试将angular降级到v10.0.6,如果可以解决,可以将解决方案放在这里,我很高兴。 :D
答案 2 :(得分:0)
您应该启动以下命令:
ng g @angular-eslint/schematics:convert-tslint-to-eslint {{YOUR_PROJECT_NAME_GOES_HERE}}