【发布时间】:2021-06-19 23:02:28
【问题描述】:
运行 ng lint 时,我的 angular 10 项目的 Linting 失败
node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng lint
它失败了,返回码 1 并说:
Schema validation failed with the following errors:
Data path "" should have required property 'lintFilePatterns'.
它仍然会检查文件,并将警告和错误打印到控制台。但我想在某个时候将其集成到我们的 CI 中。
下面是我的 angular.json lint 配置以及我的 eslint 配置
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
},
"configurations": {
"dev": {
"builder": "@angular-eslint/builder:lint",
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
}
}
}
还有 eslintrc.js
module.exports = {
"root": true,
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json",
"e2e/tsconfig.json"
],
"createDefaultProgram": true,
"tsconfigRootDir": __dirname,
},
"extends": [
"plugin:@angular-eslint/recommended",
// This is required if you use inline templates in Components
"plugin:@angular-eslint/template/process-inline-templates",
'plugin:@typescript-eslint/recommended',
],
"rules": {
/**
* Any TypeScript source code (NOT TEMPLATE) related rules you wish to use/reconfigure over and above the
* recommended set provided by the @angular-eslint project would go here.
*/
"@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": {
/**
* Any template/HTML related rules you wish to use/reconfigure over and above the
* recommended set provided by the @angular-eslint project would go here.
*/
}
}
]
}
感谢任何帮助
【问题讨论】: