Which do you prefer? ESLint or Prettier or both?

xngwng profile image Xing Wang ใƒป1 min read

What is your setup?
Which coding style guide do you use?


Editor guide
darthknoppix profile image
Seth Corker

ESLint is definitely useful (Using Airbnbโ€™s configuration with a few modifications) but Prettier is excellent for code style. I love Prettier and use ESLint for non-style related issues like cyclic complexity, unused imports etc.

nickytonline profile image
Nick Taylor (he/him)

Eslint and Prettier. Eslint for non-formatting rules and Prettier for formatting.

You can check the setup in my blog if you're interested.

GitHub logo nickytonline / iamdeveloper.com

Source code for my web site iamdeveloper.com


Netlify Status

Hey there, I'm Nick and this is my site's source code. This site started off as a clone of the Netlify CMS Gatsby Starter (check it out!). Since then, I've tweaked it a lot and converted the codebase to TypeScript.

Feel free to peruse the code and/or fork it. ๐Ÿ˜‰

Thanks to all the wonderful projects that made it possible to build this blog.

To get up and running:

  • clone the repository by running git clone git@github.com:nickytonline/www.iamdeveloper.com.git or git clone https://github.com/nickytonline/www.iamdeveloper.com.git
  • run npm install
  • run npm run develop to get up and running with the Gatsby development server.
  • Since the project uses Babel and not TypeScript as the compiler, a separate process is required to run type checking. Open another terminal and run npm run type-check:watch
  • If you're curious about why the Netlify CMS adminโ€ฆ
creeland profile image

I'd say that's a bit like comparing ๐ŸŽ to ๐ŸŠ since they both accomplish two different things.

๐Ÿ‘ฉโ€๐ŸŽจ Prettier is an opinionated formatter that parses the AST and reprints the entire thing, enforcing prettier's style rules, but it doesn't actually make changes to the AST. You'd use prettier to enforce code style across the entire project, it isn't going to catch errors.

๐Ÿ‘ฎโ€โ™‚๏ธ ESLint traverses the tree and can make changes to nodes and give you warnings. ESLint does have some format opinions but it doesn't reprint your entire tree as prettier does. You'd use ESLint to enforce code convention across your project.

gabcimato profile image
Gabriele Cimato

Oh well I actually have a combination of both, ESLint is very useful for unused vars, imports and things like that but I am guilty of using it for formatting code a certain way where Prettier fails. For everything else code style related Prettier is the way to go, there are just certain things that rub me the wrong way but at the end of the day it doesn't matter that much.

petecapecod profile image
Peter Cruckshank

It's gotta be both for me.
ESLint is a must have for catching common bugs and typos.
And a11y catches
But Prettier makes my overall coding faster ๐Ÿ˜Ž๐Ÿ”ฅ๐Ÿ”ฅ

baso53 profile image
Sebastijan Grabar

These two aren't really up to comparison and the best answer is to use them together. ESLint is a linter - it will show possible errors in your code, provide with best practices and then show you code style problems, which you then solve with Prettier. The combination of two is life changing.

melodymorgan profile image
Melody Morgan

use both! prettier will take care of formatting while eslint will catch code quality bugs (e.g. unused variables) prettier.io/docs/en/comparison.html

uddeshjain profile image

I use both ESLint and prettier. But I love prettier because I'm very dumb in indentation and styling the code and prettier does it automatically for me.

binarypatrick profile image