Tslint.config formatting/beautification in VS code
Asked Answered
K

2

6

How to get tslint.config based formatting in VSCode. I tried some extensions and it warns me about code quality, but not format/beautify my code on save

Kirst answered 18/4, 2018 at 8:49 Comment(1)
To format/beautify your code, you might want to use prettier: marketplace.visualstudio.com/…Aretta
E
5

There is a config option for vscode-tslint tslint.autoFixOnSave, which will run the fixes for any rules that have fixes.

As suggested above prettier would be a better solution for formatting your code. You'll want to use tslint-config-prettier, to avoid conflicts between them. Allowing prettier to do formatting, and tslint to do any other fixes.

Eugenieeugenio answered 18/4, 2018 at 9:1 Comment(3)
I'm not convinced prettier is better but this is the right answer regardlessCrime
I don't think this is the right answer. Prettier is not doing anything useful unless unless you want to commit to the style prettier prefers.Strident
Is there any CLI command for same as prettier has one for formatting if I've missed auto save on my hundred of files till nowChloride
C
0

I managed to get it working with tslint for TS and beautify for HTML.

-settings.json file: add: "editor.formatOnSave": true,
do not have "editor.defaultFormatter" set. In fact just comment it out.

Then open User Settings -> search for "html format enable". You must uncheck the checkbox.

After that both worked for me on save

Compute answered 16/9, 2021 at 7:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.