DEV Community

Xing Wang for moesif

Posted on

Which do you prefer? ESLint or Prettier or both?

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

Top comments (9)

Collapse
 
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.

Collapse
 
nickytonline profile image
Nick Taylor • Edited

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

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…
Collapse
 
creeland profile image
Cree

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.

Collapse
 
gabrielecimato 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.

Collapse
 
petecapecod profile image
Peter Cruckshank • Edited

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 😎🔥🔥

Collapse
 
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.

Collapse
 
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

Collapse
 
uddeshjain profile image
Uddesh

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.

Collapse
 
binarypatrick profile image
BinaryPatrick

Both!