[英]Having Angular Migrate TSLint to ESLint Banana-In-Box Error
I'm running into significant issues with my migration from TSLint to ESLint for my Angular project.我的 Angular 项目从 TSLint 迁移到 ESLint 时遇到了重大问题。 The way I'm working is I'm creating a brand new project (currently in Angular 9), and then I upgrade to Angular 10.2.
我的工作方式是创建一个全新的项目(目前在 Angular 9 中),然后升级到 Angular 10.2。 I have followed the guidelines in @angular-eslint/schematic process , and I have run the npx tslint-to-eslint-config.
我遵循了@angular-eslint/schematic process 中的指导方针,并且我已经运行了 npx tslint-to-eslint-config。 However, when I try to run ESLint via my Visual Studio Code extension, I get the following error as it tries to ESLint my app.component.ts file:
但是,当我尝试通过我的 Visual Studio Code 扩展程序运行 ESLint 时,我收到以下错误,因为它尝试 ESLint 我的 app.component.ts 文件:
Error while loading rule '@angular-eslint/template/banana-in-box': You have used a rule which requires '@angular-eslint/template-parser' to be used as the 'parser' in your ESLint config.
The following is my.eslintrc.js file configuration:以下是 my.eslintrc.js 文件配置:
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"ignorePatterns": ["node_modules/**/*", "**/node_modules/**/*", "dist/**/*"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"eslint-plugin-import",
"eslint-plugin-jsdoc",
"@angular-eslint/eslint-plugin",
"@angular-eslint/eslint-plugin-template",
"eslint-plugin-prefer-arrow",
"@typescript-eslint",
"@typescript-eslint/tslint"
],
"rules": {
...
"@angular-eslint/template/banana-in-box": "error",
...
},
root: true,
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": [
"tsconfig.*?.json",
"e2e/tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/ng-cli-compat",
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/component-selector": [
"error", { "type": "element", "prefix": "app", "style": "kebab-case" }
],
"@angular-eslint/directive-selector": [
"error", { "type": "attribute", "prefix": "app", "style": "camelCase" }
],
"@typescript-eslint/explicit-member-accessibility": [
"off", { "accessibility": "explicit" }
],
"arrow-parens": [
"off",
"always"
],
"import/order": "off"
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {}
},
{
"files": ["*.component.html"],
"extends": ["plugin:@angular-eslint/template/recommended"],
"rules": {
"max-len": ["error", { "code": 200 }]
}
},
{
"files": ["*.component.ts"],
"extends": ["plugin:@angular-eslint/template/process-inline-templates"]
}
]};
Every time I try to add that template as an extension, it gives me another error.每次我尝试将该模板添加为扩展时,都会出现另一个错误。 The only thing that stops the error is if I comment that rule out.
唯一能阻止错误的是,如果我评论排除。 Can someone help me figure out how to get this rule to work and eliminate this error?
有人可以帮我弄清楚如何让这个规则起作用并消除这个错误吗?
Replacing the section parser
did the trick for me:替换部分
parser
对我有用:
Your config:你的配置:
"parser": "@typescript-eslint/parser",
Should replace with应该替换为
"parser": "@angular-eslint/template-parser",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.