17

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.

Alexey Petrushin
  • 1,311
  • 3
  • 10
  • 24

2 Answers2

30

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 } }
cartant
  • 57,105
  • 17
  • 163
  • 197
  • 5
    Does this still work? (it doesn't for me - Failed to compile due to an unused var :( – Rune Jeppesen Oct 31 '17 at 15:33
  • The TSLint [`no-var-keyword` rule](https://palantir.github.io/tslint/rules/no-var-keyword/) 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. – cartant Oct 31 '17 at 20:00
5

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.

cs_pupil
  • 2,782
  • 27
  • 39