Typescript complaining about "Parsing error: Enum member names cannot start with lowercase 'a' through 'z'"
Typescript complaining about "Parsing error: Enum member names cannot start with lowercase 'a' through 'z'"
在我的打字稿项目中,我有以下枚举类型:
export enum ModelAttributeTypes {
binary = 'binary',
binarySet = 'binarySet',
bool = 'bool',
list = 'list',
map = 'map',
number = 'number',
numberSet = 'numberSet',
string = 'string',
stringSet = 'stringSet',
_null = '_null'
}
我的项目没有编译错误Parsing error: Enum member names cannot start with lowercase 'a' through 'z'
。
我无法自行更新枚举类型,因为它是由第三方框架生成的。
如何禁用这条抱怨 Parsing error: Enum member names cannot start with lowercase 'a' through 'z'
.
的规则
这是我与打字稿相关的开发依赖项:
"@babel/cli": "^7.14.8",
"@babel/core": "^7.15.0",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",
"@babel/plugin-transform-runtime": "^7.15.0",
"@babel/plugin-transform-typescript": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/preset-flow": "^7.14.5",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@dazn/lambda-powertools-logger": "^1.28.1",
"@testing-library/cypress": "^7.0.7",
"@testing-library/dom": "^7.31.2",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"@types/react": "^17.0.18",
"@types/react-dom": "^17.0.9",
"@types/styled-components": "^5.1.12",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"babel-plugin-add-module-exports": "^1.0.4",
"eslint-plugin-cypress": "^2.11.3",
"eslint-plugin-jest-dom": "^3.9.0",
"eslint-webpack-plugin": "2.4.1",
"typescript": "^4.3.5",
这是我的 eslint
配置。
{
"plugins": ["jest-dom"],
"extends": ["plugin:cypress/recommended", "plugin:jest-dom/recommended", "eslint:recommended"],
"parser": "babel-eslint",
"rules": {
"jest-dom/prefer-checked": "error",
"jest-dom/prefer-enabled-disabled": "error",
"jest-dom/prefer-required": "error",
"jest-dom/prefer-to-have-attribute": "error",
"no-unused-vars": "off",
"max-len": ["warn", { "code": 120 }]
},
"env": {
"browser": true,
"node": true,
"es6": true
}
}
还有我的tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"target": "es6",
"lib": ["es2015", "dom.iterable", "es2016.array.include", "es2017.object", "dom"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "ES6",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"types": ["cypress", "@testing-library/cypress"],
"strict": true
},
"include": [
"src/**/*",
"cypress/integration/auth.spec.js",
"cypress/integration/home_page_spec.js",
"cypress/integration/cypress_access_local_storage.js",
"custom.back.ts"
],
"exclude": [".history/**/*"]
}
任何人都可以帮助我解释为什么我总是收到 Parsing error: Enum member names cannot start with lowercase 'a' through 'z'
以及我该如何解决它?
已解决,是eslint导致的错误。通过将不符合规则的文件添加到 .eslintignore
来解决它
在我的打字稿项目中,我有以下枚举类型:
export enum ModelAttributeTypes {
binary = 'binary',
binarySet = 'binarySet',
bool = 'bool',
list = 'list',
map = 'map',
number = 'number',
numberSet = 'numberSet',
string = 'string',
stringSet = 'stringSet',
_null = '_null'
}
我的项目没有编译错误Parsing error: Enum member names cannot start with lowercase 'a' through 'z'
。
我无法自行更新枚举类型,因为它是由第三方框架生成的。
如何禁用这条抱怨 Parsing error: Enum member names cannot start with lowercase 'a' through 'z'
.
这是我与打字稿相关的开发依赖项:
"@babel/cli": "^7.14.8",
"@babel/core": "^7.15.0",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",
"@babel/plugin-transform-runtime": "^7.15.0",
"@babel/plugin-transform-typescript": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/preset-flow": "^7.14.5",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@dazn/lambda-powertools-logger": "^1.28.1",
"@testing-library/cypress": "^7.0.7",
"@testing-library/dom": "^7.31.2",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"@types/react": "^17.0.18",
"@types/react-dom": "^17.0.9",
"@types/styled-components": "^5.1.12",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"babel-plugin-add-module-exports": "^1.0.4",
"eslint-plugin-cypress": "^2.11.3",
"eslint-plugin-jest-dom": "^3.9.0",
"eslint-webpack-plugin": "2.4.1",
"typescript": "^4.3.5",
这是我的 eslint
配置。
{
"plugins": ["jest-dom"],
"extends": ["plugin:cypress/recommended", "plugin:jest-dom/recommended", "eslint:recommended"],
"parser": "babel-eslint",
"rules": {
"jest-dom/prefer-checked": "error",
"jest-dom/prefer-enabled-disabled": "error",
"jest-dom/prefer-required": "error",
"jest-dom/prefer-to-have-attribute": "error",
"no-unused-vars": "off",
"max-len": ["warn", { "code": 120 }]
},
"env": {
"browser": true,
"node": true,
"es6": true
}
}
还有我的tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"target": "es6",
"lib": ["es2015", "dom.iterable", "es2016.array.include", "es2017.object", "dom"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "ES6",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"types": ["cypress", "@testing-library/cypress"],
"strict": true
},
"include": [
"src/**/*",
"cypress/integration/auth.spec.js",
"cypress/integration/home_page_spec.js",
"cypress/integration/cypress_access_local_storage.js",
"custom.back.ts"
],
"exclude": [".history/**/*"]
}
任何人都可以帮助我解释为什么我总是收到 Parsing error: Enum member names cannot start with lowercase 'a' through 'z'
以及我该如何解决它?
已解决,是eslint导致的错误。通过将不符合规则的文件添加到 .eslintignore