3
votes

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"?

2

2 Answers

2
votes

sorry for the delay! 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
-1
votes

Since more than a month passed and still no one answered, and there are 130+ views, I ll share my experience: NO, I didn't ever need to use Prettier on top of TSLint. TSLint has rules for almost any case, more than I even need.