pixel
pixel

Reputation: 26441

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)

Upvotes: 2

Views: 2170

Answers (2)

Mohsen Taleb
Mohsen Taleb

Reputation: 1057

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

Upvotes: 0

mtbno
mtbno

Reputation: 600

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.

Upvotes: 3

Related Questions