I'm diving into my first TypeScript project and looking for ways to have my code automatically formatted when I save. Any suggestions for setting up my VS Code environment? I'm not using any frameworks, just straight TypeScript.
4 Answers
Both ESLint and Prettier are great for formatting and linting your code! Ideally, you want to use them together: Prettier for the formatting and ESLint for the linting. Just a heads up, though—don't rely on ESLint for formatting since it can be a bit clunky!
Have you considered trying WebStorm instead of VS Code? A lot of people find it has better integrations for projects. It's been a couple of years since I've used it though, so I'm curious about how the code generation compares now.
Honestly, I haven't used WebStorm in a while either. Does anyone know if its code generation has improved?
I'd just stick with the Prettier extension. It's straightforward and works well for auto-formatting when you save your files. Super useful!
If you're using VS Code, I recommend setting up ESLint for your project. It can help manage your code style, but I've personally been formatting my files manually by right-clicking and selecting 'Format Document.' There might be settings or extensions out there for auto-formatting on save, so it's worth searching for those!
Exactly! Prettier does the formatting job way better than ESLint.