Ensure running 'prettier'
See original GitHub issueBecause I just run prettier on master and there are some changes, I think we need to discuss on that, there are several solutions.
Ideas :
- Separate style fixes in a a specific rule (
npm run lint:fix
) - Run prettier on a precommit hook (staged files only, using husky and lint-staged #314)
@GingerPlusPlus : Can you confirm me your prettier does nothing on master ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
CLI - Prettier
Use the prettier command to run Prettier from the command line. prettier [options] [file/dir/glob ...] To run your locally installed version of Prettier,...
Read more >How to configure Prettier and VSCode - Gleb Bahmutov
Launch VS Code Quick Open (Ctrl+P); Run the following command. 1, ext install esbenp.prettier-vscode ...
Read more >Using Prettier and ESLint to automate formatting and fixing ...
Run Prettier followed by ESLint programmatically; Run Prettier as an ESLint rule. First, let's get a clear understanding of what ESLint and ...
Read more >How to use Prettier in VS Code - Robin Wieruch
How to install Prettier for VS Code (Visual Studio Code). ... Prettier is an opinionated code formatter which ensures one unified code ...
Read more >How to Add Prettier to a Project - Bits and Pieces
Prettier is a code formatter that automatically adjusts your code to adhere to well-defined conventions. Using tools like this is a great way...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
By far the easiest solution is to have prettier run on save for your editor. I use VSCode and the integration is seamless - I get all the ESLint errors displayed inline and every time I save Prettier formats the code. This is particularly great because I no longer need to think about formatting my code at all. I can type whatever I need straight in, using snippets as needed, and just save to get everything formatted which is a huge timesaver (and ensures I save regularly).
However this doesn’t solve consistency issues with PRs etc. For my own projects I have Husky set up to run effectively
lint & eslint
before every commit and runlint & eslint & test & build
before every push.Imho asking people to remember to do something - especially someone who might be committing to the project for the first time - is always going to cause issues. Linting / formatting of both code and commit messages should be automatic. This is the only way we can ensure consistency.
Yes. I find a separate hook for committing and pushing is good - keep the commit hook lightweight (and fast) - just
lint and format
then addtest
andbuild
for push.