Husky lets us run commands or script before committing or pushing our code to git. It works as a pre runner before commiting anything.
yarn add -D husky prettier eslint list-staged
npm init @eslint/config
// select below options for process
✔ How would you like to use ESLint? · problems
✔ What type of modules does your project use? · esm
✔ Which framework does your project use? · react
✔ Does your project use TypeScript? · Yes
✔ Where does your code run? · browser
✔ What format do you want your config file to be in? · JavaScript
The config that you've selected requires the following dependencies:
@typescript-eslint/eslint-plugin@latest eslint-plugin-react@latest @typescript-eslint/parser@latest
✔ Would you like to install them now? · Yes
✔ Which package manager do you want to use? · yarn
{
...
"lint-staged": {
"src/**/*.{js,ts,tsx}": [
"prettier --write",
"eslint"
]
}
...
}
npx husky init
npx husky add .husky/pre-commit "npx lint-staged"
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged
Warning: React version not specified in eslint-plugin-react settings. See https://github.com/jsx-eslint/eslint-plugin-react#configuration .
- Update .eslintrc.js file
...
"settings": {
"react": {
"version": "detect"
}
}
...
- Update any component file add junky code
- hit
git add <file>
&&git commit -m "test husky"
Auf "yes, it is" meanst du das @Thebks ist ristige, oder ?