-
Notifications
You must be signed in to change notification settings - Fork 5
Setup Prettier Pre commit #13
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
base: develop
Are you sure you want to change the base?
Conversation
JUNNY12
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lambeboluwatife
I just checked out what you have done. I'm not quite clear on how to manually test it out. After switching to your branch and installing the necessary dependencies, I'm unsure about what to do next. Could you please provide further guidance.
SageKyle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lambeboluwatife your PR message doesn't seem to follow the template. I'm not sure how to test it.
What you wrote under How should this be manually tested? should be under Description of Task to be completed?.
Since you did the installation/configuration, I shouldn't need to install any of these packages individually to test your PR; I can simply run npm install to install all the packages at once, and make sure I'm using exactly the same version with you.
Then after installing the packages, what next? How do I know that it's working?
Just in case you're not aware, you can click the three dots to edit the PR message:

Well done 👏
theaderonkeadebisi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check other PR messages, take note of the format and the tenses then make corrections to yours.
SageKyle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lambeboluwatife, the commit message looks great so far.
Here's my challenge: after following the instructions in your commit message, I didn't notice any error message to prove that your PR is working.
The error messages I got: Unexpected console statement. is based on the ESLint config - or is this what I'm expected to see?
My suggestion:
provide an example of a change I should make, a commit message, along with the error I am supposed to see to prove that the PR is working.
I'm not sure about this, but I couldn't find prettier in the devDependencies.
This is from the Prettier docs on creating a pre-commit hook:
Make sure Prettier is installed and is in your devDependencies before you proceed.
please ignore this if you've already done that
I'll also recommend you check out this resource on configuring Prettier with ESLint.
Thanks for your suggestion, I have fixed it. Hopefully, you understand, and prettier is installed as a dev dependency, I don't know why it isn't in the package.json file |
What does this PR do?
This PR adds a pre-commit hook that runs prettier against code to be committed. This would ensure the enforcement of our code convention.
This can re-format your files that are marked as “staged” via git add before you commit.
Description of Task to be Completed
npx husky-init. This command will install Husky as a development dependency and create a simple pre-commit hook in .husky/pre-commit that you can edit..husky/pre-commitreplacenpm testwithnpx lint-staged."prepare": "husky install"inside the script object inpackage.json.lintstagedrc.jsonwith the following contents:package.jsonwith the following content:How should this be manually tested?
pre-commitbranchnpm installin the command line, all project dependencies should be installed in the local dev environmentgit add .andgit commit, pre-commit should run and report any formatting errors or warnings.Any background context you want to provide?
Pre-commit hooks can be used to ensure that code adheres to specific formatting and style guidelines. This can include enforcing indentation, spacing, line breaks, and naming conventions. By using pre-commit hooks for code formatting and standards, developers can ensure that code is consistent and easy to read.
What are the relevant GitHub Issues?
#6
Screenshots (if appropriate)
Error Testing
According the rule set in the eslint file, semi colon should not be allowed. Then try git commit with semi-colon in a file then pre-commit throws a warning.

Example: