Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Comparison between tools that allow you to use ESLint and Prettier together.
prettier-eslint eslint-plugin-prettier eslint-config-prettier
What it is A JavaScript module exporting a single function. An ESLint plugin. An ESLint configuration.
What it does Runs the code (string) through prettier then eslint --fix. The output is also a string. Plugins usually contain implementations for additional rules that ESLint will check for. This plugin uses Prettier under the hood and will raise ESLint errors when your code differs from Prettier's expected output. This config turns off formatting-related rules that might conflict with Prettier, allowing you to use Prettier with other ESLint configs like eslint-config-airbnb.
How to use it Either calling the function in your code or via prettier-eslint-cli if you prefer the command line. Add it to your .eslintrc. Add it to your .eslintrc.
Is the final output Prettier compliant? Depends on your ESLint config Yes Yes
Do you need to run prettier command separately? No No Yes
Do you need to use anything else? No You may want to turn off conflicting rules using eslint-config-prettier. No
@yyynnn

This comment has been minimized.

Copy link

yyynnn commented Sep 12, 2017

Nice piece of info. Simple question: could there be a way to fix lint errors/prettify code automagiclly on save without editor's extension?
Using eslint-plugin-prettier.

@lili21

This comment has been minimized.

Copy link

lili21 commented Dec 26, 2017

so prettier-eslint is basically prettier + eslint --fix ?

@yanyu0517

This comment has been minimized.

Copy link

yanyu0517 commented Mar 23, 2018

I have try and don not think eslint-plugin-prettier will run prettier automatic

@crazy4groovy

This comment has been minimized.

Copy link

crazy4groovy commented Aug 15, 2018

xo is also a very interesting choice.

@ScottG489

This comment has been minimized.

Copy link

ScottG489 commented May 23, 2020

NOTE: It is no longer recommended to use prettier-eslint. Here is a quote from the original author of this table from this stackoverflow answer:

It's the recommended practice to let Prettier handle formatting and ESLint for non-formatting issues, prettier-eslint is not in the same direction as that practice, hence prettier-eslint is not recommended anymore. You can use eslint-plugin-prettier and eslint-config-prettier together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.