Tslint/eslint vs prettier [closed]
Asked Answered
S

1

7

Tslint (probably as well as eslint) has a --fix param, that fixes style errors. Is there any reason I should also consider using prettier, other than "prettier has more style rules"?

Soemba answered 16/8, 2018 at 10:38 Comment(0)
R
7

There are a few good reasons why you'd use Prettier over TSLint:

  • Prettier is much faster than TSLint at formatting because it doesn't need to run as many rules or use type information.
  • Prettier is much more opinionated in its output. That means you get a much more strictly enforced style guide for you. TSLint's whitespace rule and related are intentionally not feature-complete with Prettier (reference).
  • Prettier reformats code more strictly than TSLint. You have to do a lot less of your own formatting work (and if others are working on your project, everybody's code will look much more similar).

Here's a common approach if you're still interested:

  • In your tslint.json, use tslint-config-prettier to disable any formatting rules that conflict with Prettier
  • Per Prettier's docs, use husky and pretty-quick to auto-run Prettier on all Git commits
Romanticize answered 10/11, 2018 at 21:23 Comment(1)
Even if I am still not convinced to use prettier, this is a good answer! Thanks!Soemba

© 2022 - 2024 — McMap. All rights reserved.