我有我在Axios中使用的TypeScript接口,它们很难看,因为我的API以这种方式要求它们:
interface MyImage {
URI: string,
Width?: number,
Height?: number,
}是否有一种方法可以禁用整个接口的eslint规则(naming-convention) (我在一个文件中有很多)
发布于 2021-02-18 21:20:23
通过关闭接口的格式来覆盖文件顶部的规则,尝试如下:
/* eslint @typescript-eslint/naming-convention: ["off", { "selector": "interface", "format": ["camelCase"] }] */原来的答案:
您必须找到强制执行样式的规则名,我猜是@typescript-eslint/camelcase。
当您找到规则名称时,可以通过写入来关闭当前文件的规则。
/* eslint-disable @typescript-eslint/camelcase */在你档案的顶端。
发布于 2022-03-01 07:47:47
由于在每个文件上禁用eslint似乎并不是最方便的方法,所以您可以对您的.eslintrc进行一些更改,并以更可维护的方式对整个项目的所有文件进行修改。
这里已经回答了这个问题:Turn off eslint camelCase for typescript interface identifiers
https://stackoverflow.com/questions/66268243
复制相似问题