【问题标题】:Angular TSLint: Only allow camelCase, do Not allow Pascal caseAngular TSLint:只允许骆驼大小写,不允许帕斯卡大小写
【发布时间】: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"
 ]

},

https://palantir.github.io/tslint/rules/variable-name/

【问题讨论】:

标签: angular typescript tslint angular10


【解决方案1】:

设置允许帕斯卡大小写。

"variable-name": {
  "options": [
    "ban-keywords",
    "check-format",
    "allow-pascal-case",
    "allow-leading-underscore"
  ]
},

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-30
    • 2021-07-20
    • 2015-10-10
    • 2021-08-31
    • 1970-01-01
    • 1970-01-01
    • 2022-10-12
    相关资源
    最近更新 更多