Don’t hesitate to contact us if you have any feedback.

Streamline your dev workflow with Husky

As developers, we’re always on the lookout for tools and tricks that can shave off precious minutes from our workflow, ensuring that we maintain our focus on writing clean, efficient code rather than getting bogged down by repetitive tasks. One such tool that has become an indispensable part of the modern developer’s toolkit is Husky, a tool that allows you to easily manage Git hooks. Today, we’re excited to share with you our own custom Husky template configuration that you can find on our GitHub repository.

What is Husky?

For the uninitiated, Husky is a simple, yet powerful, tool that can prevent bad git commit, git push, and more by using hooks. Hooks are scripts that run at specific points in the Git lifecycle, and Husky makes it incredibly easy to manage these hooks with a straightforward configuration.

Why use our Husky template configuration?

Our Husky template is designed to streamline your coding and version control processes, ensuring that you can focus on writing code and not on the minutiae of pre-commit or pre-push actions. Here’s what our template brings to your workflow:

Pre-configured Hooks

We’ve set up the most commonly used Git hooks, so you don’t have to start from scratch. Our template includes pre-commit and pre-push hooks that can be easily customized to suit your project’s needs.

Code quality assurance

By using our Husky template, you can integrate tools like ESLint, Prettier, or any other static code analysis tools. This means every commit is checked for potential issues, ensuring that you maintain a high standard of code quality.

Time-saving automation

Automate tasks such as running tests before every push. Our configuration is set up to run your test suite, ensuring that all tests pass before code is even pushed to the repository. This saves you from potential integration headaches later on.

Easy to integrate

Whether you’re working on a solo project or with a team, our Husky template is straightforward to integrate into your workflow. The template is housed on GitHub, making it easy for everyone to access and contribute to.

How to use our Husky template

Getting started with our Husky template is as simple as cloning the repository and following the straightforward setup instructions. Here’s a step-by-step guide:

Clone the Repository

First, clone the repository to your local machine or directly into your project directory:

    git clone https://github.com/LaTableRouge/husky-template.git

    Install Dependencies

    Navigate to the directory where you cloned the repository and run:

      npm install

      This will install Husky and any other necessary dependencies.

      Configure the package.json

      Edit the package.json file to customize the configuration according to your project’s needs. Here are some specific areas you might want to tailor:

      • lint-staged: Modify the asset patterns that need to be verified before committing.
      • validate-branch-name: Update the branch name pattern to fit your team’s naming conventions.
      • commitlint: Adjust the commit message rules to align with your project’s standards.
      • git-precommit-checks: Customize the messages or scripts that run before commits.
      • prettierIgnore: Specify files or directories you want Prettier to ignore.
      • browserslist: Update the target browsers for your project if needed.
      • stylelint: Adjust the Stylelint rules for styles validation.
        • ignoreFiles: Define files to be excluded from stylelint checks.
        • rules: Modify style rules to ensure your styles adhere to the project’s standards.
      • stylelintIgnore: List files or directories to be ignored by stylelint.
      • eslintConfig: Adjust the ESLint rules for script validation.
      • eslintIgnore: Specify files or directories to be excluded from ESLint checks.

      Test It out

      Make a commit or a push to test out your new hooks. You should see the hooks in action, running any specified commands.

      Skipping Verifications

      Sometimes, you may need to bypass these verifications temporarily. Here’s how you can skip these checks:

      • Skip Commit Hooks: You can bypass commit hooks by using the --no-verify flag: bash
      git commit -m "Your commit message" --no-verify
      • Skip Push Hooks: Similar to commit hooks, you can skip push hooks with the --no-verify flag:
      git push origin your-branch --no-verify

      Note: Use these options cautiously, as skipping verifications can lead to unreviewed code or other issues being committed

        Conclusion

        With our Husky template, you’re setting yourself up for success by ensuring that your project adheres to code quality standards and reducing the likelihood of preventable mistakes. We encourage you to try it out and tweak it to fit your workflow. As always, we’re keen to hear about your experiences and improvements, so feel free to submit issues or pull requests to our repository.

        If you want to learn more and do more advanced stuff with Husky check out the official documentation.


        Comments

        Leave a Reply

        Your email address will not be published. Required fields are marked *