Mes Post-Its
Raphael Piccolo

husky and lint-staged to run estlint and prettier on pre-commit

Retour
# install lint-staged
npm install -D lint-staged

# create this file with following content
.lintstagedrc
{
    "*.js": [
        "eslint --fix",
        "prettier --write"
    ]
}

# you can now try to lint staged files with
npx lint-staged

# install husky
npm install -D husky
npm set-script prepare "husky install"
npm run prepare

# create hook
npx husky add .husky/pre-commit "npx lint-staged"
git add .husky/pre-commit


# on another machine you can git clone, and this command is automatically executed on "npm install", otherwise run it :
npm run prepare

cv.raphaelpiccolo.com |Connexion