Search code examples
typescripteslinttypescript-eslint

Turning off eslint rule for an interface?


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)


Solution

  • 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.