Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Husky [Fixes #495] #520

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn format:fix
yarn lint:fix
yarn typecheck
20 changes: 19 additions & 1 deletion INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This document provides instructions on how to set up and start a running instanc
- [Sign in to talawa-admin](#sign-in-to-talawa-admin)
- [Running tests](#running-tests)
- [Linting code files](#linting-code-files)
- [Husky for Git Hooks](#husky-for-git-hooks)
- [Setting up Talawa-Admin and API for Talawa App](#setting-up-talawa-admin-and-api-for-talawa-app)
- [On Your Local Machine](#on-your-local-machine)

Expand Down Expand Up @@ -147,7 +148,24 @@ You can run the tests for `talawa-admin` using this command:-

You can lint your code files using this command:-

yarn lint
yarn lint:fix

## Husky for Git Hooks

We are using the package `Husky` to automatically run the following scripts on your changes whenever you make a commit:

```
yarn format:fix
yarn lint:fix
yarn typecheck
```

This is done to improve developer experience and to make sure that your commits do not fail on the automated workflow runs. Still you can manually opt-out of the same using the `--no-verify` flag as follows:

```
git commit -m "Commit message" --no-verify
```


## Setting up Talawa-Admin and API for Talawa App

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"lint:fix": "eslint \"**/*.{ts,tsx}\" --fix",
"format:fix": "prettier --write \"**/*.{ts,tsx,json,scss,css}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,json,scss,css}\"",
"typecheck": "tsc --project tsconfig.json --noEmit"
"typecheck": "tsc --project tsconfig.json --noEmit",
"prepare": "husky install"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -103,6 +104,7 @@
"@typescript-eslint/eslint-plugin": "^5.9.0",
"@typescript-eslint/parser": "^5.9.0",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^8.0.3",
"jest-localstorage-mock": "^2.4.19",
"jest-location-mock": "^1.0.9",
"jquery": "^3.2.1"
Expand Down
Loading