網站搜尋

angular - eslint: rxjs/no-unsafe-takeuntil 問題


我正在嘗試向我的 Angular 專案中添加一條規則:rxjs/no-unsafe-takeuntil

  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "module": "es2020",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "allowJs": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "es2016",
      "es2015",
      "dom"
    ]
  },
  "include": [
    "src/**/*.d.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

tsconfig.json

const { join } = require("path");

module.exports = {
  parser: "@typescript-eslint/parser",
  parserOptions: {
    ecmaVersion: 2019,
    project: join(__dirname, "./tsconfig.json"),
    sourceType: "module"
  },
  plugins: ["rxjs"],
  extends: [],
  rules: {
    "rxjs/no-unsafe-takeuntil": "error"
  }
};

eslintrc.js

我有 .eslintrc.json 除此之外。

我對一系列文件收到 解析錯誤:@typescript-eslint/parser 已設定 "parserOptions.project"。

如何修理它?

答案#1

有同樣的問題,是因為沒有正確取得 tsconfig.json。建議檢查它是否在正確的位置。