简体   繁体   English

typescript 中的 eslint 解析错误,lint 没有得到 parserOptions 配置

[英]Parsing error with eslint in typescript, lint doesnt get the parserOptions config

Im not sure why i get this error我不确定为什么会收到此错误

You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project"

this is my config这是我的配置

tsconfig 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"
  ]
}

.eslintrc.json .eslintrc.json

{
  "extends": "standard-with-typescript",
  "parserOptions": {
    "projects": "./tsconfig.json"
  },
  "rules": {
    "@typescript-eslint/consistent-type-definitons": "off",
    "@typescript-eslint/strict-boolean-expressions": "off"
  }
}

also i have this AccountModel class我也有这个 AccountModel class

export type AccountModel = {
    accessToken: string
}

which vscode points an error sayng "Parse error: Type expected" what im missing?哪个 vscode 指出错误说“解析错误:预期类型”我缺少什么?

Go to your eslintrc.json and try this configuration: Go 到您的 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
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 解析错误:“parserOptions.project”已为@typescript-eslint/parser 设置。 该文件与您的项目配置不匹配:jest.config.js - Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config: jest.config.js 解析错误:“parserOptions.project”已为 @typescript-eslint/parser 设置为 gatsby/typescript - Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser for gatsby/typescript 如何修复“解析错误:“parserOptions.project”已为 @typescript-eslint/parser 设置。 在 gatsby-config 和 Gatsby-node.js 中 - How fix 'Parsing error: “parserOptions.project” has been set for @typescript-eslint/parser.' inside gatsby-config and Gatsby-node.js 解析错误:已为 @typescript-eslint/parser 设置“parserOptions.project”。 该文件与您的项目配置不匹配:.eslintrc.js - Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config: .eslintrc.js &#39;解析错误:已为@typescript-eslint/parser 设置了“parserOptions.project”是什么意思。 IntelliJ IDE 系列中的错误? - What means 'Parsing error: “parserOptions.project” has been set for @typescript-eslint/parser.' error in IntelliJ IDEs family? 我的“.eslintrc.js”文件出错 - “解析错误:已为@typescript-eslint/parser 设置了“parserOptions.project”。 - Error with my ".eslintrc.js" file - "Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser." (ESLint/赛普拉斯): 解析错误: ESLint 被配置为在 ` 上运行<tsconfigrootdir> /component/TestComponent.cy.ts` 使用 `parserOptions.project`</tsconfigrootdir> - (ESLint/Cypress): Parsing error: ESLint was configured to run on `<tsconfigRootDir>/component/TestComponent.cy.ts` using `parserOptions.project` 预计打字稿 eslint 解析错误“]” - typescript eslint parsing error "]" expected ESLint 配置中的“parser”和“parserOptions.parser”有什么区别? - What the difference between "parser" and "parserOptions.parser" in ESLint config? 为 ESLint 和 Airbnb typescript 设置配置 parserOptions 或解析器 package - Configure parserOptions or parser package for ESLint and Airbnb typescript setup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM