Prettier with linters

Jonathan Harrison
1 min readAug 29, 2017

--

Recently I started using prettier in my side projects and for those who don’t know what prettier is; it is an opinionated code formatter. I highly encourage you to check it out.

prettier’s documentation is a great place to get started, but when trying to set it up for a “real project” I couldn’t find any complete examples with linters. If not correctly configured, your linter of choice and prettier will be at war about formatting your code.

In my case I was using:

After some digging and playing around, I got the previously mentioned linters playing nice with prettier.

To save the next person who tries to do this a few hours, I thought I would share my minimal setup on GitHub. Simply:

  • Clone the project.
  • Open up one of the folders e.g. tslint.
  • Install the dependencies with npm or yarn.
  • Run the linter command with “npm run lint-ts” or “yarn run lint-ts” (Replace lint-ts with lint-css for stylelint).

If everything worked as expected, you should have some linting errors.

There you go. Happy coding :)

--

--

Jonathan Harrison
Jonathan Harrison

Written by Jonathan Harrison

Principal Software Engineer @ Tripadvisor. Formerly at Spotify, Altitude Angel and Microsoft. All opinions are my own.

No responses yet