Why use prettier if ESLint can format?
Proper way of Installing ESlint with Prettier in a React Project
How to Configure ESLint, Prettier, and Flow in VS Code for React Development (x-post /r/reactnative)
This may be a little off topic, but I use Prettier with Sublime Text via the JsPrettier plugin.
Does anyone else have issues with the plugin "losing" the path to the Prettier package? Or the console not providing adequate errors when a bug is found (and Prettier hadn't run)? Often times this happens after a reboot of my computer or just ST.
I really enjoy the tool, but it's becoming more of a headache to figure out what's going wrong when I haven't changed anything relating to ST or the package itself.
More on reddit.comReformatting your code base using prettier or eslint without destroying git history
Sounds like you’re changing the git history on master and force pushing it. Isn’t that kind of risky? Also, what happens to the existing branches that were around before you force push?
More on reddit.comVideos
» npm install eslint-plugin-prettier
» npm install eslint-config-prettier
» npm install prettier-eslint
I've heard ESLint can format but I haven't found a clear answer why it seems prettier is used instead of the ESLint formatter. Whenever I try to look it up most comments neglect to mention that ESLint can also format so it's not obvious why prettier would be needed at all.
There are a number of ways to set up prettier to work with eslint and it can be confusing.
To run prettier as an eslint rule, you would want to add a rule that allows eslint to run prettier. You do that with the eslint-plugin-prettier plugin.
"plugins": ["prettier"], // Defines a rule that allows eslint to run prettier.
"rules": {
"prettier/prettier": "error" // Turns on that rule.
}
You would also want to turn off eslint rules that may conflct with prettier. You do this with the eslint-config-prettier extension. Note this should come after any other extensions in order to override the rules as appropriate.
"extends": [
/*other extensions*/,
"prettier" // Turns off conflicting eslint rules.
]
As per their documentation, it sounds the recommended extension that comes with the prettier plugin actually takes care of everything for you, so you should be able to get away with just:
extends: [
// .. other extensions
'plugin:prettier/recommended',
]
https://github.com/prettier/eslint-plugin-prettier
Also, in case third-party plugins come with their own rules that may conflict with prettier, you used to have to add "prettier/that-plugin" - "prettier/react" in your case for instance - to the list of plugins in order to tell eslint to defer to prettier for these non-standard rules as relevant as well. But this no longer seems required.
I used this guide for setting up eslint with airbnb's style guide on a Yarn monorepo/workspace.