Lucas P.
Lucas P.

Reputation: 145

Disabling tslint for a block of code with tslint:disable does not work

I'm trying to disable TSlint (Version: typescript 3.5.2, tslint 5.18.0) for a block of code in a VueJS project but it doesn't seems to work (it still displays errors and warning for this block at compilation with npm run serve)

I've already tried to use commented tslint:disable and eslint-disable without success.

Thanks for your help

Upvotes: 7

Views: 8006

Answers (3)

Tonnio
Tonnio

Reputation: 655

You can also disable a specific rule for a block of code like that:

// tslint:disable:max-line-length
...your code here
// tslint:enable:max-line-length

Upvotes: 3

Renjith P N
Renjith P N

Reputation: 4251

Recently I have faced same issue in my Angular project below is how I solved my problem.

  // tslint:disable
  (event.keyCode >= A && event.keyCode <= Z) ||
  (event.keyCode >= ZERO && event.keyCode <= NINE) ||
  event.keyCode === SPACE ||
  (this.preventHomeEndKeyPropagation &&
  (event.keyCode === HOME || event.keyCode === END))
  // tslint:enable

Upvotes: 8

Serg The Bright
Serg The Bright

Reputation: 874

The one way left: use // @ts-ignore over every line you want to skip checking (i hope the block is not too large)

Upvotes: 3

Related Questions