I have TypeScript interfaces that I use in Axios and they're ugly since my API requires them in that way:
interface MyImage {
URI: string,
Width?: number,
Height?: number,
}
Is there a way to disable eslint rule ( naming-convention
) for the whole interface (I have many of them inside one file)
Override the rule at the top of your file by turning the format off for interfaces, try this:
/* eslint @typescript-eslint/naming-convention: ["off", { "selector": "interface", "format": ["camelCase"] }] */
Original answer:
You'd have to find the rule name that's enforcing the style, I'm guessing it's the @typescript-eslint/camelcase
.
When you find the rule name, you can turn the rule off for the current file by writing
/* eslint-disable @typescript-eslint/camelcase */
at the top of your file.
Since disabling eslint on each file doesn't seem to be the most convenient approach, you can make some changes in your .eslintrc
and have it for all files across your project in a more maintainable way.
This has been already answered here: Turn off eslint camelCase for typescript interface identifiers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.