Angular v13 .eslintrc.json eslint-plugin-rxjs-angular 配置

Angular v13 .eslintrc.json configuration for eslint-plugin-rxjs-angular

我想在我的 Angular v13 项目中使用 eslint-plugin-rxjs-angular。 在他们的 github page 上写着。

Configure the parser and the parserOptions for ESLint. Here, I use a .eslintrc.js file for the configuration:

然后,有一个片段。

const { join } = require("path");
module.exports = {
  parser: "@typescript-eslint/parser",
  parserOptions: {
    ecmaVersion: 2019,
    project: join(__dirname, "./tsconfig.json"),
    sourceType: "module"
  },
  plugins: ["rxjs-angular"],
  extends: [],
  rules: {
    "rxjs-angular/prefer-async-pipe": "error"
  }
};

如何在我的 .eslintrc.json 文件中实现上面的 .eslintrc.js 配置,我在下面添加了什么?

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

如果我没理解错的话,就是这个方法。
我通过@angular-eslint 扩展的预制配置负责幕后的解析器选项。 因此,我唯一要做的就是:

"files": ["*.ts"] 覆盖中,我添加了

"plugins": ["rxjs-angular"],  

"rxjs-angular/prefer-async-pipe": "error"  

在规则部分。