在打字稿中使用 eslint 解析错误,lint 没有获取 parserOptions 配置

Dan*_*zes 6 typescript eslint

我不确定为什么会出现此错误

You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project"
Run Code Online (Sandbox Code Playgroud)

这是我的配置

tsconfig

{
  "compilerOptions": {
    "target": "es6",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "jsx": "react",
    "rootDir": "src",
    "baseUrl": "src",
    "paths": {
      "@/*": [
        "*"
      ]
    },
    "allowJs": true,
    "resolveJsonModule": true
  },
  "include": [
    "src"
  ],
  "exclude": [
    "src/main/test/cypress"
  ]
}
Run Code Online (Sandbox Code Playgroud)

.eslintrc.json

{
  "extends": "standard-with-typescript",
  "parserOptions": {
    "projects": "./tsconfig.json"
  },
  "rules": {
    "@typescript-eslint/consistent-type-definitons": "off",
    "@typescript-eslint/strict-boolean-expressions": "off"
  }
}
Run Code Online (Sandbox Code Playgroud)

我也有这个 AccountModel 类

export type AccountModel = {
    accessToken: string
}
Run Code Online (Sandbox Code Playgroud)

哪个 vscode 指出一个错误,说“解析错误:预期类型”我缺少什么?

小智 3

转到 eslintrc.json 并尝试以下配置:

{
  "extends": [
    "standard-with-typescript",
    "plugin:@typescript-eslint/recommended"
  ],
  "parserOptions": {
    "project": "./tsconfig.json",
    "ecmaVersion": 12,
    "sourceType": "module"
  },
  "plugins": [
    "@typescript-eslint"
  ],
  "rules": {
    "import/extensions": 1,
    "import/no-named-as-default": 0,
    "@typescript-eslint/strict-boolean-expressions": 0,
    "@typescript-eslint/explicit-module-boundary-types": 0
  }
}
Run Code Online (Sandbox Code Playgroud)