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

Radex picture Radex · Sep 18, 2017 · Viewed 29.2k times · Source

I need to disable some variable checks in ESLint.

Currently, I am using this code, but am not getting the desired result:

/* eslint no-unused-vars: ["error", { "caughtErrorsIgnorePattern": "Hey" }] */
export type Hey = {
  a: string,
  b: object
}

Two questions:

  • Is there a variant which can enable no-unused-vars for a block of code?

Something like...

/* eslint rule disable"*/

// I want to place my block of code, here

/* eslint rule disable"*/
  • Or could I make Hey a global variable so that it can be ignored everywhere?

Answer

Ville Venäläinen picture Ville Venäläinen · Sep 18, 2017

Just use pair of lines:

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

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

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