Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to disable TSLint in tslint.json?

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.

like image 827
Alexey Petrushin Avatar asked Jan 31 '17 08:01

Alexey Petrushin


People also ask

How do I disable Tslint?

In addition to global configuration, you may also enable/disable linting for a subset of lint rules within a file with the following comment rule flags: /* tslint:disable */ - Disable all rules for the rest of the file. /* tslint:enable */ - Enable all rules for the rest of the file.

What does Tslint json do?

TSLint is an extensible static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors. It is widely supported across modern editors & build systems and can be customized with your own lint rules, configurations, and formatters.

Is Tslint deprecated?

However, the TSLint team deprecated the project in 2019 and Angular followed suit in November 2020. Fortunately, thanks to tools from the Angular ecosystem migrating to ESLint is easier than you think.


2 Answers

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 } }
like image 90
cartant Avatar answered Oct 05 '22 21:10

cartant


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.

like image 41
cs_pupil Avatar answered Oct 05 '22 22:10

cs_pupil