Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to install Husky in your project.
Git
npm install [1] --save-dev Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Installing the wrong package like eslint or webpack.
Forgetting to add --save-dev to save as a development dependency.
✗ Incorrect
Husky is installed as a development dependency using npm install husky --save-dev.
2fill in blank
mediumComplete the command to initialize Husky in your project.
Git
npx husky [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'init' or 'start' instead of 'install'.
Not running this command after installing Husky.
✗ Incorrect
Use npx husky install to set up Husky hooks in your project.
3fill in blank
hardFix the error in the command to add a pre-commit hook that runs tests.
Git
npx husky add .husky/pre-commit "[1]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'npm start' which runs the app instead of tests.
Trying to run 'git commit' inside the hook.
✗ Incorrect
The pre-commit hook should run tests, so the command is npm test.
4fill in blank
hardFill both blanks to add a pre-push hook that runs lint and format checks.
Git
npx husky add .husky/pre-push "[1] && [2]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'npm run test' instead of lint or format.
Using 'npm start' which runs the app.
✗ Incorrect
The pre-push hook runs lint and format checks using npm run lint and npm run format.
5fill in blank
hardFill all three blanks to add a prepare script in package.json that installs Husky and sets up Git hooks.
Git
"prepare": "npm [1] husky && npx husky [2] && npx husky [3]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'init' instead of 'install' for setting up Husky.
Forgetting to add the pre-commit hook command.
✗ Incorrect
The prepare script installs Husky, runs husky install, and adds a pre-commit hook to run tests.