【问题标题】:Turning off eslint rule for an interface?关闭接口的 eslint 规则?
【发布时间】:2021-05-21 21:27:27
【问题描述】:

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

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

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

【问题讨论】:

    标签: typescript eslint typescript-eslint


    【解决方案1】:

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

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

    原答案:

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

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

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

    在文件的顶部。

    【讨论】:

      猜你喜欢
      • 2020-03-25
      • 2023-01-05
      • 2015-02-28
      • 1970-01-01
      • 2016-04-18
      • 2020-08-13
      • 2016-08-28
      • 1970-01-01
      相关资源
      最近更新 更多