简体   繁体   English

Eslint 出现意外的“EnumInvalidMemberName”错误

[英]Eslint rises unexpected "EnumInvalidMemberName" error

I'm triyng to config eslint for gatsby app with TS and during the integration faced linter issue Parsing error: Enum member names cannot start with lowercase 'a' through 'z'.我正在尝试使用 TS 为 gatsby 应用程序配置 eslint,并且在集成期间面临 linter 问题Parsing error: Enum member names cannot start with lowercase 'a' through 'z'.

It comes during linter run, but I didn't see any rules how to disable it since I'm not going to follow that rule (legacy copde base)它是在 linter 运行期间出现的,但我没有看到任何如何禁用它的规则,因为我不会遵循该规则(遗留 copde 基础)

例子

Does anybody know how to disable/override this rule?有人知道如何禁用/覆盖此规则吗?

"dependencies": {
        "gatsby": "^4.11.2",
        "react": "^17.0.2",
},
"devDependencies": {
        "@babel/preset-env": "^7.18.2",
        "@babel/preset-react": "^7.17.12",
        "@testing-library/jest-dom": "^5.16.4",
        "@testing-library/react": "^12.1.5",
        "@testing-library/react-hooks": "^8.0.1",
        "@types/node": "^18.0.6",
        "@types/react": "^17.0.2",
        "@types/react-dom": "^17.0.2",
        "@typescript-eslint/eslint-plugin": "^5.30.7",
        "@typescript-eslint/parser": "5.0.0",
        "babel-eslint": "^10.1.0",
        "babel-jest": "^28.1.0",
        "babel-preset-gatsby": "^2.15.0",
        "eslint": "^7.32.0",
        "eslint-config-prettier": "^8.5.0",
        "eslint-plugin-react": "^7.30.1",
        "eslint-webpack-plugin": "^3.2.0",
        "identity-obj-proxy": "^3.0.0",
        "jest": "^28.1.0",
        "jest-environment-jsdom": "^28.1.2",
        "prettier": "^2.7.1",
        "ts-jest": "^28.0.7",
        "typescript": "^4.7.4"
    },

Looks like my issue was that I used to have not propriate parserfor ts files: once I switch babel-eslint to @typescript-eslint/parser the issue is solved.看起来我的问题是我曾经没有适当的 parserfor ts 文件:一旦我将babel-eslint切换到@typescript-eslint/parser问题就解决了。

//.eslintrc
{
-  "parser": "babel-eslint"
+  "parser": "@typescript-eslint/parser"
}

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

相关问题 ESLint:解析错误:意外的令牌: - ESLint: Parsing error: Unexpected token : 解析错误:意外的保留字“接口”。 eslint - Parsing error: Unexpected reserved word 'interface'. eslint React typescript eslint 错误解析错误:意外的令牌? 如何解决这个问题? - React typescript eslint error Parsing error: Unexpected token ! How to fix this? ESLINT 意外的顶级属性“导入/订购”错误 - ESLINT Unexpected top-level property "import/order" error 错误 'this' 到局部变量 @typescript-eslint/no-this-alias 的意外别名 - ERROR Unexpected aliasing of 'this' to local variable @typescript-eslint/no-this-alias ESlint 在 TypeScript 转换运算符“as”上解析错误“意外标记” - ESlint parsing error "Unexpected token" on TypeScript cast operator "as" 使用 Gsap 的 ScrollTo 插件时出现意外的令牌 eslint 错误 - Getting Unexpected token eslint error when using Gsap's ScrollTo plugin 当 Eslint 解析 Tsx/Ts 文件 'public' 令牌时,总是显示 'Parsing error: Unexpected token' - When Eslint parse Tsx/Ts file 'public' token, always shows 'Parsing error: Unexpected token' 意外的令牌,预期的“,” Eslint Typescript with Vue - Unexpected token, expected "," Eslint Typescript with Vue 预计打字稿 eslint 解析错误“]” - typescript eslint parsing error "]" expected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM