【问题标题】:ESlint & Angular 13: Unable to turn off typescript-eslint/typedefESlint & Angular 13:无法关闭 typescript-eslint/typedef
【发布时间】:2022-01-13 00:15:50
【问题描述】:

我在 Angular 13 中创建了一个新项目。我执行以下命令在项目中配置 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 Code。我打了自己的脸。我无法摆脱代码中的以下错误:

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

使用 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"
  }
}

【问题讨论】:

  • 你能分享你的package.json吗?我复制了 eslint 文件,它按预期工作。
  • 添加了 package.json 快照

标签: angular typescript eslint eslintrc typescript-eslint


【解决方案1】:

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

ng add @angular-eslint/schematic

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

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

【讨论】:

    猜你喜欢
    • 2023-03-14
    • 2021-11-29
    • 2019-06-28
    • 2017-11-05
    • 2020-11-10
    • 2020-11-20
    • 2019-07-30
    • 2020-07-16
    • 2021-06-08
    相关资源
    最近更新 更多