Laj*_*jna 10 lint eslint angular
我的 Angular 10 项目在运行 ng lint 时失败
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'.
Run Code Online (Sandbox Code Playgroud)
它仍然对文件进行 lint 检查,并将警告和错误打印到控制台。但我想在某个时候将其集成到我们的 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"]
}
}
}
Run Code Online (Sandbox Code Playgroud)
和 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.
*/
}
}
]
Run Code Online (Sandbox Code Playgroud)
}
感谢任何帮助
小智 8
尝试用以下内容替换或编辑 angular.json 文件中的“lint”块
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"eslintConfig": ".eslintrc.json",
"lintFilePatterns": ["**/*.spec.ts", "**/*.ts"]
}
}
Run Code Online (Sandbox Code Playgroud)
或者您的 eslint 配置文件存储在何处。
| 归档时间: |
|
| 查看次数: |
6172 次 |
| 最近记录: |