0

New to husky and having problems running pre-commit hook.

pre-commit file (I have husky install script):

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged

.eslintrc:

{
    "root": true,
    "parser": "@typescript-eslint/parser",
    "plugins": ["@typescript-eslint", "prettier"],
    "extends": [
      "eslint:recommended",
      "plugin:@typescript-eslint/eslint-recommended",
      "plugin:@typescript-eslint/recommended",
      "prettier"
    ]
}

.prettierrc:

{
  "bracketSpacing": true,
  "jsxBracketSameLine": true,
  "singleQuote": true,
  "trailingComma": "all",
  "arrowParens": "always"
}

package-json property lint-staged:

"lint-staged": {
    "./src/*.{js,jsx,ts,tsx}": "npm run lint"
}

lint script:

"lint": "eslint --ext .js,.jsx,.ts,.tsx"

Have placed this chunk of code listed below somewhere inside the app, but pre-commit is not triggering (it should because in .eslintrc you can see it extends the eslint:recommended ruleset, which contains e.g. "no-compare-neg-zero": "error").

Code:

let x;
if (x === -0) {
  // doSomething()...
}

I reckon the problem is with lint-staged property, because I just c/p that piece of code. What is some sort of average/conventional value for lint-staged property?

Followup question is: If husky is working as it should, will I see any husky log after git commit even though there is no errors detected?

Thank You!

moze
  • 322
  • 1
  • 5
  • 14

0 Answers0