notrab / react-use-cart

React hook library for managing cart state

Home Page:http://npm.im/react-use-cart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Husky Pre-commits is not working, also need to run test script and linting auto-fix before commit.

Skidragon opened this issue · comments

This issue should resolve:

  • husky runs the test, linting, and linting auto-fix scripts
  • add a test watch command for our test runner

Not sure if there is a better way but here is what I got so far.

I propose the following updates:

  • According to the husky docs, a .husky folder must be created then the pre-commit hook file can be added:

  • https://github.com/typicode/husky

  • Then these scripts can run as a pre-commit:

  • npm run test

  • npm run lint:fix

  • npm run lint

These scripts will make sure the test code passes then fix any linting errors then give the user an error so they can commit the linting code fixes that are auto-generated.

Proposed package.json updates:

  • "test:watch": "npm run test -- --watch", //Makes it easier to update code while running the test runner
  • "lint:fix": "npm run lint -- --fix", //This will fix our linting errors
  • "prepare:husky": "husky install", //Create the husky.sh file
//Remove
 "husky": {
    "hooks": {
      "pre-commit": "tsdx lint"
    }
  },

Just have to figure out how to run prepare:husky when npm install. I guess the husky.sh file shouldn't be commited since a .gitignore has been generated to not include it but I will look into it more.

image

I'm not sure how I missed this, sorry!

I think husky needs a bit of an update in this repo, which should solve the issue here.

Edit: I forgot we use tsdx 🤦🏻