npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@coara/pre-commit

v1.0.2

Published

pre-commit scripts for coara projects

Downloads

586

Readme

pre-commit

This package has some predefined hooks to do some pre-commit scripts that help in some of the typical developer flow.

Install

You should install like a develop npm dependency and you should install too a husky package

npm i @coara/pre-commit husky -D

Before continue

  1. We need to create a .husky folder on our project root
  2. Add prepare script to our package.json file ("prepare": "husky install",)
  3. Run npm run prepare

Inside our .husky folder we should add as many hooks as we want, every hook is an executable file and its name is the triggering hook, here an example with a pre-commit message to link your Jira issues with your branches.

└── .husky
   └── commit-msg

And here is the commit-msg file content:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run coara-pre-commit link-jira-issue $1

How this works

Link jira issues

This command will add your Jira issue to the message commit trying to find on the branch name the key of your project followed by the number of the issue, your branch should look like feature/MYPROJECTKEY-12123-some-amazing-stuff. To trigger this script the command should be like the next:

npm run coara-pre-commit link-jira-issue $1

This command always should be triggered by the commit-msg hook from husky. Your configuration should like:

└── .husky
   └── commit-msg

And here is the commit-msg file content:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run coara-pre-commit link-jira-issue $1

Prettier on pre-commit

To auto fix the staged files with prettier you can add the command coara-pre-commit lint-staged-prettier. This command applies your prettier config and auto fix the files that match with your pattern. If you don't add any pattern they apply a default one. To can execute correctly this command you should have a prettier config file and the lint-staged. Our recommendation for the prettier config file is to use the @coara/prettier-config, but you can use the configuration whatever that you want

Install

npm i lint-staged @coara/prettier-config -D

add on your root directory a prettier config file .prettierrc and extend there the @coara/prettier-config or include your custom rules

@coara/prettier-config

Finaly you should add this command on you husky configuration like:

└── .husky
   └── pre-commit

And here is the pre-commit file content:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run coara-pre-commit lint-staged-prettier

stylelint on pre-commit

To auto fix the staged files with styelint you can add the command coara-pre-commit lint-staged-stylelint. This command applies your stylelint configuration to auto-fix the files that match with your pattern. If you don't add any pattern they apply a default one. To execute correctly this command you should have a stylelint config file and the lint-staged. Our recommendation for the prettier config file is to use the @coara/stylelint-config, but you can use the configuration whatever that you want

Install

npm i lint-staged @coara/stylelint-config -D

add on your root directory a stylelint config file .stylelintrc.json and extend there the @coara/stylelint-config or include your custom rules

{
  "extends": "@coara/stylelint-config"
}

Finaly you should add this command on you husky configuration like:

└── .husky
   └── pre-commit

And here is the pre-commit file content:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run coara-pre-commit lint-staged-stylelint

Package powered by coara TM