Skip to content
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

Prettier precommit hook #126

Merged
merged 5 commits into from
Mar 21, 2018
Merged

Prettier precommit hook #126

merged 5 commits into from
Mar 21, 2018

Conversation

josh-lester
Copy link
Contributor

Purpose

  • ...

Adds initial setup for running prettier during commit so that code styles are always followed

#35

Does this introduce a breaking change?

[ ] Yes
[ x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[ ] Feature
[ x] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

adding prettier styling to the repo.

Also adds a nice prettier configuration badge to the readme file to show that prettier is used

@josh-lester
Copy link
Contributor Author

@johnpapa I figured if i went ahead and opened a PR then you can pull it down and play around if you wanted until we find what works best

Copy link
Owner

@johnpapa johnpapa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

.prettierrc Outdated
@@ -0,0 +1,5 @@
{
"printWidth": 100,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to 80 please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, if you want me to switch the staged files over to the add script you pointed out, i can change that too while im at it

.prettierignore Outdated
@@ -0,0 +1,4 @@
# ignore all files
*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we need this file. there are some files outside of src which are fine to pretty. let's make this file blank

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@johnpapa
Copy link
Owner

update to 80 chars and i think we're good.

@wardbell should try this out before we merge

@@ -64,6 +65,7 @@
"@types/node": "~6.0.60",
"codelyzer": "^4.1.0",
"concurrently": "^3.5.0",
"husky": "^0.14.3",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we also need this?

  "precommit": ["precommit"],

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like pretty-quick is using husky according to the documentation. looking to see if i can find any more information about that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Husky can prevent bad git commit, git push and more

this is from the husky repo...
i could be wrong but it sounds like husky purpose is to prevent you from committing if your precommit fails.

Honestly i was just following the docs on prettier site and installed the things they said to install.

I can remove if wanted

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we are good. i tested this elsewhere and here is hwat I have:

npm i husky prettier pretty-quick -D

Then i added this to the package.json, inside of scripts

    "pretty-quick": "pretty-quick",
    "precommit": "pretty-quick --staged"

The first one is for formatting the entire project, the latter for the hook that husky calls

@johnpapa
Copy link
Owner

@wardbell - please take a look. if you like this, let's merge

@johnpapa
Copy link
Owner

thanks for the PR!

@johnpapa johnpapa merged commit 09efe18 into johnpapa:master Mar 21, 2018
@josh-lester josh-lester deleted the prettier-precommit-hook branch August 29, 2020 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants