【发布时间】:2020-12-22 22:27:56
【问题描述】:
我们正在使用 Angular 编写代码,并且只希望允许小写首字母,Camel 大小写。例如,ProductName 应该显示一个显示警告/错误(因为它是大写的)。
如何在 TSLint 中只允许驼峰式,不允许 Pascal(大写)?
this.product.ProductName = 5;
以下不显示使用错误,仅在Class组件本身,
export class Product {
ProductId: number;
ProductName: string;
}
TS Lint 设置:
"variable-name": {
"options": [
"ban-keywords",
"check-format"
]
},
【问题讨论】:
-
正如您在该链接中看到的那样,默认情况下它不允许 Pascal 大小写,只有驼峰大小写和全部大写。似乎没有办法禁止所有大写字母。 TSLint 已被弃用,取而代之的是 ESLint...code.visualstudio.com/api/advanced-topics/…
-
@MarkThomas51 - 我没有对你投反对票。但是,是的,我知道你只是在做你的工作。 +1 ;) 根据 Heretic Monkey 的建议,您可能可以使用 ESLint 正则表达式完成此操作:require identifiers to match a specified regular expression (id-match)
标签: angular typescript tslint angular10