我需要对接口或类型中的属性使用snake_case。我camelcase
用
'camelcase': ["error", {properties: "never"}],
正如它在文档中提到的那样。它不适用于接口和类型,但适用于 JS 对象。
export const test = {
a_b: 1, // OK. No error
};
export interface ITest {
a_b: number, // Identifier 'a_b' is not in camel case.eslint(camelcase)
}
export type TTest = {
a_b: number, // Identifier 'a_b' is not in camel case.eslint(camelcase)
}
当我将规则设置为 时,错误消失'off'
,因此此规则适用于 .ts 文件。
那么如何在 TS 中使用 snake_case 呢?谢谢。