我正在尝试为我的项目设置命名约定。
我希望ESLint对snake_case中的一些变量发出警告,例如:
const { order_id } = req.params;我删除了typescript-eslint/camelcase,因为它已经过时,并尝试设置naming-convention,并为boolean添加了一个新的error规则。
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
types: ['boolean'],
format: ['PascalCase'],
prefix: ['is', 'should', 'has', 'can', 'did', 'will'],
},
],如何为snake_case变量添加警告?
发布于 2020-07-15 22:48:56
如果你想让ESLint警告你camelCase中没有的变量名,就像下面这样简单:
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "variable",
format: ["camelCase"]
},
],VS代码中显示的相应警告:

https://stackoverflow.com/questions/62903691
复制相似问题