0

Both eslint-config-prettier and eslint-plugin-prettier are popular packages for integrating ESLint with Prettier.

However, after reading Docs of both of them I understood that both would do the job. But, if we use eslint-plugin-prettier, there will be a few issues that would not happen if we would use eslint-config-prettier. Also, when using eslint-plugin-prettier recommended config, it would use eslint-config-prettier behind the scene.

It seams to me that eslint-config-prettier has obvious advantages over eslint-plugin-prettier, but eslint-plugin-prettier is still very popular and it has really a lot of weekly downloads on npm. Did I miss something? What would be advantage of using eslint-plugin-prettier?

NeNaD
  • 18,172
  • 8
  • 47
  • 89

1 Answers1

6

This packages have different purposes:

  • eslint-plugin-prettier - runs Prettier as an ESLint rule and reports differences as individual ESLint issues.

  • eslint-config-prettier - turns off all rules that are unnecessary or might conflict with Prettier. It's mean that if you use some eslint-config(your own or third party) and this config have conflicts with prettier rules - it should resolve this conflicts by turn off this rules.

Alex Gor
  • 533
  • 4
  • 18
  • What does it mean `Runs Prettier as ESLint rule`? What is the difference between running it as a rule and running it normally? – NeNaD Dec 02 '21 at 17:45
  • It's mean that you can run prettier as eslint rule if you use eslint. Prettier is independent tool. But there are have integrations with different linters - eslint, tslint, stylelint etc.. If you use some of them - you can add plugin for your linter and avoid install prettier additionally. – Alex Gor Dec 02 '21 at 17:50
  • I see. So I don't have to install Prettier editor extension locally in order for Prettier to work. ESLint will format my code as Prettier would with it's rule? – NeNaD Dec 02 '21 at 21:43
  • 1
    Yes. But how it's describe in documentation - it's not recommended. You can read about it here - https://prettier.io/docs/en/integrating-with-linters.html#notes – Alex Gor Dec 02 '21 at 21:55