关闭接口的 eslint 规则?

时间:2021-02-18 21:13:36

标签: typescript eslint typescript-eslint

我有在 Axios 中使用的 TypeScript 接口,它们很丑,因为我的 API 以这种方式需要它们:

interface MyImage {
  URI: string,
  Width?: number,
  Height?: number,
}

有没有办法为整个界面禁用 eslint 规则(naming-convention)(我在一个文件中有很多)

1 个答案:

答案 0 :(得分:2)

通过关闭接口格式来覆盖文件顶部的规则,试试这个:

/* eslint @typescript-eslint/naming-convention: ["off", { "selector": "interface", "format": ["camelCase"] }] */

原答案:

您必须找到强制执行样式的规则名称,我猜是 @typescript-eslint/camelcase

找到规则名称后,可以通过写入为当前文件关闭规则

/* eslint-disable @typescript-eslint/camelcase */

在文件的顶部。

相关问题