简体   繁体   English

出现 Angular Migrate TSLint to ESLint Banana-In-Box 错误

[英]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.

相关问题 在Angular中用多个项目迁移TSLint到ESLint,ng lint命令挂起 - Migrate TSLint to ESLint in Angular with multiple projects, ng lint command hangs 将 tslint 迁移到 @angular-eslint/schematics:ERESOLVE 无法解析依赖树:@angular/compiler@12.1.2 - Migrate tslint to @angular-eslint/schematics: ERESOLVE unable to resolve dependency tree: @angular/compiler@12.1.2 Nx Angular TSLint 到 ESLint 迁移后的 Lint 错误 - Nx Angular Lint Error after TSLint to ESLint Migration 升级到 EsLint:angular.json 出错(原理图:convert-tslint-to-eslint) - Upgrading to EsLint: Error with angular.json (schematics:convert-tslint-to-eslint) Tslint 到 Eslint 迁移 - convert-tslint-to-eslint 命令后出错 - Tslint to Eslint migration - Error after convert-tslint-to-eslint command 如何运行@angular-eslint/schematics:convert-tslint-to-eslint - How to run @angular-eslint/schematics:convert-tslint-to-eslint 从 TSLint 迁移到 ESLint 和 ESLint 导致解析错误:Unexpected token &lt; and does not check.ts files in angular v12 - Migrated from TSLint to ESLint and ESLint causes parsing error: Unexpected token < and does not check .ts files in angular v12 带有 webcomponents 的 Angular 香蕉盒装 (LitElement) - Angular banana-in-a-box with webcomponents (LitElement) Tslint 到 ESLint 迁移错误:未知选项 &#39;--remove-tslint-if-no-more-tslint-targets&#39; - Tslint to ESLint Migration Error : unknown option '--remove-tslint-if-no-more-tslint-targets' 如何手动更新 Angular 以使用 eslint 并删除 tslint - How to manually update Angular to use eslint and remove tslint
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM