How can I use ESLint no-unused-vars for a block of code?

To disable the @typescript-eslint/no-unused-vars warning:

  • For the current line:
const unusedVar = 1; // eslint-disable-line @typescript-eslint/no-unused-vars
  • For the next line:
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const unusedVar = 1;
  • For a block:
/* eslint-disable @typescript-eslint/no-unused-vars */
const unusedVar1 = 1;
const unusedVar2 = 2;
/* eslint-enable @typescript-eslint/no-unused-vars */

Original answer

Just use pair of lines:

/* eslint-disable no-unused-vars */

// ... your code here with unused vars...

/* eslint-enable no-unused-vars */

Alternatively, you can disable the rule for one line:

// Based on your Typescript example

export type Hey = { // eslint-disable-line no-unused-vars
  a: string,
  b: object
}