-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrating and Enforcing Prettier & ESLint #320
Comments
Hey Matija, This is a fantastic blog, and the conclusion of "just use 1 tool via eslint-plugin-prettier" was very helpful to me when I started setting up my linting framework back in 2019. However, a friend pointed out to me recently that using The other major point that my friend brought up has to do with projects that have other files than JavaScript/TypeScript. In the same way that you want your TypeScript files failing in CI when they are not formatted correctly, you would also want JSON/YAML/HTML files failing too. And ESLint can't lint those files - only Prettier can. So as long as a project has JSON/YAML/HTML/whatever files, even though we are trying to avoid installing/using two different tools, we end up using Prettier anyway. I have to admit that this is a pretty serious drawback, since lots of projects are going to have those kinds of files. What do you think about this? And has your standard linting setup changed at all in the two years since you have written this blog? |
Hi Zamiell, This is really interesting feedback, thank you! To answer your last question, I'm still using this setup, which is pretty unexpected even to me in the world where we change frameworks every couple of months 😄 I didn't know that Prettier discourages using
I can imagine that there is some impact on speed, though, I haven't measured it either. I would like to compare it, though. Now let's talk about other file types that Prettier can format. First of all, you said something about avoiding/installing two different tools, but with the setup I recommend in my post (or any other for that matter) you'd be doing both, you're always both installing and using Prettier, it just varies how you're using it. For other file types you can have a separate setup, for example in I understand why this makes your friend ask why did would we join ESLint and Prettier at all if we're running Prettier separately for other file types, but the answer is hopefully simple — most benefits I mentioned previously still stand regardless of this, you also likely have less code written in other languages, so some of the problems that joining ESLint and Prettier alleviates might not be significant problems for them. Also, maybe you don't want Prettier to run on every file, only on some, perhaps in some cases you want to control the formatting. In summary you should be able to combine both approaches just fine. What do you think about that? |
Integrating and Enforcing Prettier & ESLint
How to resolve the conflict between Prettier and ESLint and use ESLint to enforce Prettier in your codebase.
https://silvenon.com/blog/integrating-and-enforcing-prettier-and-eslint/
The text was updated successfully, but these errors were encountered: