我正在尝试为我的项目设置命名约定。
我在 snake_case
中有一些变量我希望 ESLint 警告我,例如:
const { order_id } = req.params;
我删除了 typescript-eslint/camelcase
因为它已被弃用并试图设置 naming-convention
并添加了一个新的 error
bool 规则。 '@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
types: ['boolean'],
format: ['PascalCase'],
prefix: ['is', 'should', 'has', 'can', 'did', 'will'],
},
],
如何为 snake_case
添加警告变量?
最佳答案
如果您希望 ESLint 警告您有关不在驼峰式大小写中的变量名称,则很简单:
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "variable",
format: ["camelCase"]
},
],
VS Code 中显示的相应警告:关于typescript - @typescript-eslint/命名约定 : How to mix error and warn rules?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62903691/