[英]Why does typescript-eslint enforce camelCase for enumMember?
All enum examples in the TypeScript documentation write enum members as PascalCase, like: TypeScript 文档中的所有枚举示例都将枚举成员写为 PascalCase,例如:
enum Direction {
Up = 1,
Down,
Left,
Right,
}
But @typescript-eslint/naming-convention enforces camelCase (and rejects PascalCase), which means I have to write:但是@typescript-eslint/naming-convention强制使用camelCase(并拒绝PascalCase),这意味着我必须写:
enum Direction {
up = 1,
down,
left,
right,
}
Is there a reason why PascalCase should be forbidden for enum members?是否有理由禁止枚举成员使用 PascalCase?
The context is a brand new Angular 12 project with the recommended schematics:上下文是一个全新的 Angular 12 项目,带有推荐的原理图:
ng add @angular-eslint/schematics
This makes no sense to me.这对我来说毫无意义。
Is my set-up possibly wrong?我的设置可能有问题吗?
Why would the official naming convention be rejected?为什么官方命名约定会被拒绝?
Add this rule in to the rules section from your 'eslintrc' config file:将此规则添加到“eslintrc”配置文件中的规则部分:
"rules": {
...,
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE", "PascalCase"]
}
]
}
Try to change "selector" and "format" options as you need: naming-convention available options尝试根据需要更改“选择器”和“格式”选项: 命名约定可用选项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.