When working with TypeScript, I prefer to use snake_case for properties within my Interfaces or Types. To enforce this rule, I have configured the ESLint rule camelcase
as follows:
'camelcase': ["error", {properties: "never"}],
Even though the ESLint documentation mentions that this rule applies, it seems to only work for JavaScript objects and not for interfaces and types.
export const test = {
a_b: 1, // This is fine, 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)
}
The error disappears when I turn the rule 'off'
, but then it doesn't apply to .ts files anymore.
So, how can I continue to use snake_case convention inside TypeScript? Any suggestions are appreciated. Thank you.