question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ensure running 'prettier'

See original GitHub issue

Because 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:closed
  • Created 6 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Undistractioncommented, Feb 19, 2018

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 run lint & 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.

1reaction
Undistractioncommented, Feb 19, 2018

For the hook, Instead running all the lint command, we can use lint-staged for fast commiting.

Yes. I find a separate hook for committing and pushing is good - keep the commit hook lightweight (and fast) - just lint and format then add test and build for push.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found