I keep getting error "space indentation expected" while running ng lint. It is a quite amount of lines that having the same issue in my application. How can I solve this warning? Is anyone having face the similar issue ?
Asked
Active
Viewed 3.2k times
21
-
This is not the most efficient way of doing it but above the line that's throwing the error, put the following line: `// tslint:disable-next-line:indent`. If you can find a way to decorate it at the top of the function then that will be a bit better. Afterwards run `ng lint --type-check` and see if your files pass linting. If this helped you in anyway please mark it as a solution as opposed to a comment. – Harold_Finch Nov 13 '17 at 09:43
-
Actually, there is an opened bug in the library. Please check out https://github.com/palantir/tslint/issues/2814. – minato namikaze Feb 21 '19 at 08:03
2 Answers
27
By default ng lint expects indentation to be 2 spaces. You can change these settings in your tslint.json.
If you want to use 4 spaces:
"indent": [
true,
"spaces",
4
]
If you want to use tabs (4 spaces wide):
"indent": [
true,
"tabs",
4
]
See this section of the docs for reference.

user3255061
- 1,757
- 1
- 30
- 50
14
If anyone came here because they're seeing this in vscode despite having a perfectly good tab at the start of the line do this: Hit F1, type 'tabs' and select 'Convert indentation to tabs' and that should resolve it.

zappa
- 791
- 8
- 16
-
2for me it was the other way around, type space and 'Convert Indentation to Spaces'. – Stephen Romero Dec 04 '19 at 20:21
-
That gets rid of the red underline, but when I save the file all the red lines come back again. I have been through the settings 5 times. What is adding back tabs on save?! – Rin and Len Dec 18 '19 at 09:06