Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Space Indentation Expected in ng lint

Tags:

tslint

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 ?

like image 544
user3086452 Avatar asked Oct 06 '17 12:10

user3086452


People also ask

How do I fix expected space indentation?

You can do this by editing your tslint. json file (for TypeScript) or eslint. json file (for JavaScript) and adding / modifying the indent rule, or simply turning the indent validation off.

How do you fix ng lint issues?

Using the command ng lint --fix is correct and should fix the indentation.


2 Answers

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.

like image 153
user3255061 Avatar answered Oct 17 '22 22:10

user3255061


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.

like image 12
zappa Avatar answered Oct 17 '22 23:10

zappa