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
83
votes
6 answers

Auto fix TSLint Warnings

[64, 1]: space indentation expected [15, 27]: Missing semicolon [109, 36]: missing whitespace [111, 24]: missing whitespace [70, 1]: Consecutive blank lines are forbidden I keep getting warnings like these from TSLint. There…
ANKIT HALDAR
  • 1,365
  • 1
  • 10
  • 17
79
votes
7 answers

TSLint Error "Exceeds maximum line length of 120"

In my Angular2 App I'm importing one component like this: import { PersonsSingleAccountComponent} from '../persons-information/fragments/persons-single-account/persons-single-account-bookings/persons-single-account-bookings.component' It is…
Sunny
  • 1,167
  • 5
  • 15
  • 27
74
votes
4 answers

Angular2 - HTTP RequestOptions HEADERS

I currently have an issue with tslint and was hoping someone could point me in the right direction. I'm trying to send an HTTP GET request using HTTP provided by the Angular2 framework. With this request, I must specify the content-type and the…
Zander17
  • 1,894
  • 5
  • 23
  • 31
74
votes
3 answers

How to lint entire folder using tslint

Is that possible to lint entire folder using tslint? Using eslint it is possible to do eslint ./src to validate whole folder. When i try to do the same for tslint - i am getting an error Error: EISDIR: illegal operation on a directory. In their…
ValeriiVasin
  • 8,628
  • 11
  • 58
  • 78
69
votes
2 answers

[tslint]Expected a 'for-of' loop instead of a 'for' loop with this simple iteration (prefer-for-of)

I have got a tslint error to my for loop when I try to resolve it it says to convert to for-of. I have seen many docs but its not helpful.How can I solve the lint error and I cannot do tslint:disable-next-line:prefer-for-of for (let i = 0; i <…
Juke
  • 1,306
  • 2
  • 11
  • 27
68
votes
4 answers

Typescript : require statement not part of an import statement

Typescript version 2.2.2 I wrote this require in my UserRoutzr.ts const users = require(path.join(process.cwd() + "/data")); TSLint is raising the following warning: require statement not part of an import statement if I changed it to…
user762579
56
votes
10 answers

How to fix the issue not all the code paths return value?

I have an error in the code that I am trying to resolve. I think it needs a return statement but I have that already outside of the forEach loop but it still throws the error: not all the code path return the value How to fix below…
hussain
  • 6,587
  • 18
  • 79
  • 152
51
votes
7 answers

Making Sense of 'No Shadowed Variable' tslint Warning

I have a function that checks for the current stage in a sequential stream, based on a particular discipline that is passed in, and, according to that value, assigns the next value in my Angular 2 app. It looks something like this: private…
Rey
  • 1,393
  • 1
  • 15
  • 24
50
votes
3 answers

TSLint : variable name must be in camelcase or uppercase

I have some variable names starting with leading underscore , I still get this warning after updating my tslint.json tslint.json { "extends": "tslint:recommended", "rules": { "variable-name": [ true, "ban-keywords", …
user762579
48
votes
3 answers

How to order imports with tslint's import-ordering rule

On my project tslint's "import-ordering" rule is used import CopyLensModal from './CopyLensModal'; import FetchStatus from '../../../../../state/generic/models/FetchStatus'; import FlexRow from '../../../../generic/components/FlexRow'; import…
Denis
  • 2,429
  • 5
  • 33
  • 61
47
votes
3 answers

TypeScript linter warning: no-unused-variable is deprecated; but I'm not using this config

Today I see this warning in a project being refreshed after 3 months. no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead. But my tsconfig.json does not seem to use this. { "compilerOptions":…
realtebo
  • 23,922
  • 37
  • 112
  • 189
45
votes
7 answers

How can I use TSLint in VS Code?

I have installed TSLint in VSCode and created a tslint.json file next to tsconfig.json. But TSLint is not working. For example, I added "curly": true to tslint.json, but when I write a if statement without curly braces, VS Code doesn't give any…
Zen
  • 5,065
  • 8
  • 29
  • 49
44
votes
4 answers

How to ignore/exclude some files/directory from linting in angular cli

Similar to this question I am running the following command to linting my angular2 typeScript code. ng lint It is proving all the linting error nicely. But I want my vendor folder (let say "src/app/quote/services/generated/**/*") should not get…
Partha Sarathi Ghosh
  • 10,936
  • 20
  • 59
  • 84
42
votes
3 answers

Why are bitwise operators not allowed in tslint?

We can't use bitwise operators in templates, but why are they not allowed by tslint within TypeScript code? "no-bitwise": true,
Mick
  • 8,203
  • 10
  • 44
  • 66
42
votes
1 answer

Proper explanation for NodeJS/Typescript Export / Import?

Could someone please explain exactly how exports and imports work in NodeJS using Typescript? My setup is: NodeJS Everything in Typescript TSLint Typings I am messing about with exports/imports instead of doing some proper coding, its driving me…
Tomas
  • 2,676
  • 5
  • 41
  • 51
1
2
3
70 71