DEV Community

Discussion on: Diving into Husky and Lint-staged

Collapse
 
andrewriveradev profile image
Andrew • Edited

Use npx lint-staged instead of npm run lint-staged. npm run can only execute the scripts specified in the scripts section of your package.json

or

In .husky/pre-commit change npm run lint-staged to npm run pre-commit

Add "pre-commit": "lint-staged" to package.json in "scripts"
Add lint-staged config like you've always done:

"scripts: {
    "pre-commit": "lint-staged"
},
"lint-staged": {
    "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --write"
    ]
  },
Enter fullscreen mode Exit fullscreen mode

Github Issue #949 How to use husky v6 with lint-staged?