Is it possible to disable TSLint in tslint.json?
Asked Answered
O

2

18

I use react-scripts-ts to generate React App and it supplies TSLint.

It seems like there's no option to tell react-scripts-ts to exclude TSLint from the build pipeline. Is it possible to disable TSLint via tslint.json?

P.S.

It's possible to disable it by adding comment to the file, but I don't want to add such comment to every TS file in the project.

Orvieto answered 31/1, 2017 at 8:22 Comment(1)
how do you disable for a single file? (comment what?=Mcdermott
R
31

If you don't want any TSLint rules to be enforced and are prepared to edit the tslint.json file, you can just set its content to:

{}

With no rules defined, you will see this message written to the console:

No valid rules have been specified

But the TSLint process with terminate with an exit code of 0 and should not interfere with your build pipeline.

Or, if the message bugs you, define a single rule that's switched off:

{ "rules": { "no-var-keyword": false } }
Roo answered 2/2, 2017 at 2:41 Comment(2)
Does this still work? (it doesn't for me - Failed to compile due to an unused var :(Mcdermott
The TSLint no-var-keyword rule and config have not changed. It's possible that something in react-scripts-ts has changed and I don't have the answer to that.Roo
A
6

Using @cartant's answer, I got some annoying output in the console saying something like 'Tried to lint a file, but found no valid/enabled rules...' for every single file in my project.

Anyways, in my tslint.json file, if I changed the extends property:

  "extends": [
    "tslint:recommended"
  ],

to be an empty array:

  "extends": [],

It turned everything off for me and there was no longer any lint related warnings or noise in the console.

Albigenses answered 20/8, 2019 at 17:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.