Questions tagged [tslint]

tslint is a static analysis linter for TypeScript.

tslint is a linter for the language, similar to jslint.

Use this tag on questions about:

  • installation
  • command-line options
  • default/built-in rules
  • rule flags
  • Custom formatters
  • creation of custom rules

Github home of tslint
NPM home of tslint

1054 questions
16
votes
3 answers

tslint error Shadowed name: 'Observable'

I am getting the following error when running tslint that I wasn't getting before.. ERROR: C:/...path..to../observable-debug-operator.ts[27, 13]: Shadowed name: 'Observable' I followed this tutorial for adding a debug operator to Observable and it…
Devin Crossman
  • 7,454
  • 11
  • 64
  • 102
15
votes
3 answers

don't use object as a type

I am getting the lint error: don't use object as a type When I use object as a type, example follows: export const myFunc = (obj: object): string => { return obj.toString() } Any idea what type I should give to an object with unknown…
danday74
  • 52,471
  • 49
  • 232
  • 283
15
votes
3 answers

tslint not excluding node_modules in angular project

I tried to perform the following to exclude node_modules from tslint. But none of them resolved the issue. I am confused if it is because of the way I call the node_modules folder. First attempt - Added the following in tsconfig.json and…
Philip John
  • 5,275
  • 10
  • 43
  • 68
15
votes
3 answers

What is the tslint blacklist and why does angular-cli default rxjs on the list in tslint.json?

By default with an angular-cli project the tslint settings come packed with things that go squiggle. I recently was approached by a new developer that I had configure their tslint instance in Atom. I was asked about the following line: import {…
beauXjames
  • 8,222
  • 3
  • 49
  • 66
15
votes
1 answer

How to enable type checking in TSLint under WebStorm?

I have some rules in my tslint.json that require the --type-check functionality. WebStorm doesn't give me a way to add the command-line argument and to the TSLint plugin. It also doesn't give me a way to enable it from the GUI. As a result TSLint…
Hristo Kolev
  • 1,486
  • 1
  • 16
  • 33
14
votes
2 answers

Prettier reformats if / else into single line

I am trying Prettier out in a project using React and Typescript. However I am having a problem configuring multi-line if / else statements. When I write: if (x >=0) { // Do something } else { // Do something else } Prettier reformats it to: if…
Felipe
  • 6,312
  • 11
  • 52
  • 70
14
votes
2 answers

bash: tslint: command not found

I tried use tslint --fix but get bash: tslint: command not found.... I installed tslint using command: yarn global add tslint typescript. My machine use Centos 7.
Edgaras Karka
  • 7,400
  • 15
  • 61
  • 115
14
votes
4 answers

TSLint in Visual Studio 2015/2017?

My organization uses TSLint pretty heavily for quality-checking our Typescript code, and it provides a valuable service to us! However, we use Visual Studio 2015 & 2017 as our main IDE and the only way to get the linting results it to run a…
Chris Barr
  • 29,851
  • 23
  • 95
  • 135
14
votes
3 answers

How to exclude a folder from tslint?

I like to exclude the test folder form linting with tslint in vscode. So I have placed an exclude into my tslint.json config file. Unfortunately the exclude statement is not working. Does any one know how to set the exclude up? { "exclude":…
Michael Hoeller
  • 22,018
  • 10
  • 39
  • 66
14
votes
4 answers

Is it possible to configure TSLint in Visual Studio 2015?

TSLint is complaining that single-quotes should be double-quotes. Our team prefers to use single-quotes to wrap string literals. I see that TSLint is configurable to set the mode to single-quote, but I cannot find a way to set these rules in Visual…
crush
  • 16,713
  • 9
  • 59
  • 100
13
votes
2 answers

Angular TSLint - Cannot find builder "@angular-devkit/build-angular:tslint"

When I try to run command ng lint --fix cli throws this error: An unhandled exception occurred: Cannot find builder "@angular-devkit/build-angular:tslint". See "C:\Users\MOE89A~1.ZAR\AppData\Local\Temp\ng-Ijc3an\angular-errors.log" for further…
Mahdi Zarei
  • 5,644
  • 7
  • 24
  • 54
13
votes
5 answers

How to run @angular-eslint/schematics:convert-tslint-to-eslint

I'm trying to switch an Angular project from TSLint to ESLint, following the instructions in angular-eslint Github repo. I ran ng add @angular-eslint/schematics which added the following dependencies to my package.json: …
Rene Saarsoo
  • 13,580
  • 8
  • 57
  • 85
13
votes
1 answer

How to run tslint.json?

I am newbie to typescript. I have tslint.json file created but don't have an idea about how to run this file using command line. Please advise which command do I need to use to run this config
Hemadri Dasari
  • 32,666
  • 37
  • 119
  • 162
13
votes
1 answer

How to have TSLint resolve indirect typing dependencies with Yarn workspaces?

Context Yarn workspaces provide for a convenient way to depend on packages in a mono-repo. When package A depends on package B, the interfaces etc. defined in package B are appropriately resolved in package A. Problem I am facing an issue where if…
Tom
  • 8,536
  • 31
  • 133
  • 232
13
votes
3 answers

How to disable Named imports must be alphabetized - tslint

How to disable Named imports must be alphabetized - tslint ? I am getting error: Named imports must be alphabetized. I don't know how to disable this error. My tsconfig.json configuration is: { "compilerOptions": { "baseUrl": ".", …
fowulofito
  • 131
  • 1
  • 3