ESlint & Angular 13: 无法关闭 typescript-eslint/typedef

ESlint & Angular 13: Unable to turn off typescript-eslint/typedef

我在Angular13创建了一个新项目,我执行了以下命令在项目中配置typescript-eslint:

ng add @angular-eslint/schematic

以下是我的 .eslintrc.json 文件,我试图在其中“关闭”typescript-eslint/typedef 和 typescript-eslint/explicit-function-return-type:

{
  "root": true,
  "ignorePatterns": ["projects/**/*"],
  "overrides": [
    {
      "files": ["*.ts"],
      "parserOptions": {
        "project": ["tsconfig.json"],
        "createDefaultProgram": true
      },
      "extends": [
        "plugin:@angular-eslint/recommended",
        "plugin:@angular-eslint/template/process-inline-templates"
      ],
      "rules": {
        "@angular-eslint/directive-selector": [
          "error",
          {
            "type": "attribute",
            "prefix": "app",
            "style": "camelCase"
          }
        ],
        "@angular-eslint/component-selector": [
          "error",
          {
            "type": "element",
            "prefix": "app",
            "style": "kebab-case"
          }
        ],
        "@typescript-eslint/typedef": "off",
        "@typescript-eslint/explicit-function-return-type": "off"
      }
    },
    {
      "files": ["*.html"],
      "extends": ["plugin:@angular-eslint/template/recommended"],
      "rules": {}
    }
  ]
}

我已经重启了 ESlint 服务器。我已经重新启动 VS 代码。我打了自己的脸。我无法摆脱代码中的以下错误:

我不知道如何解决这个问题。

使用 package.json 快照进行更新

{
 
  "dependencies": {
    "@angular/animations": "~13.0.0",
    "@angular/common": "~13.0.0",
    "@angular/compiler": "~13.0.0",
    "@angular/core": "~13.0.0",
    "@angular/forms": "~13.0.0",
    "@angular/platform-browser": "~13.0.0",
    "@angular/platform-browser-dynamic": "~13.0.0",
    "@angular/router": "~13.0.0",
    "lodash-es": "^4.17.15",
    "luxon": "^2.3.0",
    "luxon-angular": "^5.0.0",
    "ngx-cookie-service": "^13.1.2",
    "ngx-mask": "^13.0.1",
    "rxjs": "~7.4.0",
    "tslib": "^2.3.0",
    "verge": "^1.10.2",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.0.1",
    "@angular-eslint/builder": "13.0.1",
    "@angular-eslint/eslint-plugin": "13.0.1",
    "@angular-eslint/eslint-plugin-template": "13.0.1",
    "@angular-eslint/schematics": "13.0.1",
    "@angular-eslint/template-parser": "13.0.1",
    "@angular/cli": "~13.0.1",
    "@angular/compiler-cli": "~13.0.0",
    "@types/jasmine": "~3.10.0",
    "@types/luxon": "^2.0.9",
    "@types/node": "^17.0.8",
    "@typescript-eslint/eslint-plugin": "5.3.0",
    "@typescript-eslint/parser": "5.3.0",
    "codelyzer": "^6.0.0",
    "del": "^6.0.0",
    "eslint": "^8.2.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "fs": "0.0.1-security",
    "gulp": "4.0.2",
    "gulp-image": "^6.3.1",
    "gulp-nop": "0.0.3",
    "gulp-plumber": "^1.2.1",
    "jasmine-core": "~3.10.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "prettier": "^2.5.1",
    "protractor": "~7.0.0",
    "rxjs-tslint-rules": "^4.34.0",
    "ts-node": "~8.3.0",
    "typescript": "~4.4.3"
  }
}

看来,当我运行以下命令时:

ng add @angular-eslint/schematics

设置过程未完成。 运行 以下命令确保执行了整个设置,从而消除了大部分错误:

ng add @angular-eslint/schematics --skip-confirmation

注意 - 参考 link angular-eslint/angular-eslint