My step-by step guide to set up Prettier in any project, and integrate it with ESLint and Git Hooks
I’ve been using Prettier for mor...
For further actions, you may consider blocking this person and/or reporting abuse
Would you like to hear a one line command that literally does half the things in your article :) ?
npx mrm lint-staged
Run this, it ll install husky, modify package.json to add husky folder, create the pre-commit file with lint-staged, install lint-staged, create package.json lint-staged...with all their related dependencies and more
yes sir you read that right
In addition, you can also enable format on save in vscode, which will run prettier to format your code.
I prefer this before developer commit their code.
If you're developing an open-source product for example, you cannot force every contributor to use vscode and configure it exactly like you expect !
lint-staged with husky gives ultimate power to manage your code
You can also use
yarn dlx
instead ofnpx
.what's the npx commad?
npx is a tool which comes with Node.js & npm
By default, when you run
npx <command>
, npx will check whether<command>
exists in$PATH
, or in the local project binaries, and execute that. If<command>
is not found, it will be installed prior to execution.Thank you for sharing! Will try and use this for my next project!
Awesome! I wrote an article on this subject too recently.
How to use ESLint and Prettier for code analysis and formatting
Andrew Baisden ・ Jun 16 ・ 6 min read
Can you add commands for pnpm also?
Sorry, I've never used it, but if you manage to find working commands, please post them in a comment and I'll add them to the guide!