typescript - @typescript-eslint/命名约定 : How to mix error and warn rules?

标签 typescript eslint

我正在尝试为我的项目设置命名约定。
我在 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 中显示的相应警告:
enter image description here

关于typescript - @typescript-eslint/命名约定 : How to mix error and warn rules?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62903691/

相关文章:

javascript - TypeScript "Compile on save"功能在 Visual Studio 2015 中不起作用

angular - 在 .ts 文件中使用 ngx-translate

javascript - Angular2,子属性和 elvis 运算符

javascript - 如何将eslint配置正确添加到NuxtJS?

reactjs - ESLint 详尽-deps : ignore value that came from a ref

javascript - 类切换在组件之间不起作用 Angular 4

Angular - 禁用输入的 Karma 测试无法正常工作

node.js - eslint 忽略模式不起作用

javascript - 如何让 VS Code 识别 ES7 绑定(bind)运算符

node.js - 如何修复 eslint 配置?