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

Setup Husky for auto formatting on pre commit #856

Closed
wants to merge 3 commits into from
Closed
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
22 changes: 19 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
6. Create a `.env` file in root of directory.
7. Setup firebase and get your own set of keys. ( follow steps in [Firebase Setup](#firebase-setup) section to setup firebase )
8. Copy all the key fields from `.env.sample` and place your own set of values there.
9. Run `npm run dev`.
10. Visit [http://127.0.0.1:5173/](http://127.0.0.1:5173/) in your preferred browser.
9. Setup husky ( follow steps in [Husky Setup](#husky-setup) section to setup firebase )
10. Run `npm run dev`.
11. Visit [http://127.0.0.1:5173/](http://127.0.0.1:5173/) in your preferred browser.

>📝**NOTE** : Above steps are enough for you to get started with the Codelabz app. If you want to access the database you need to start the emulators.
>📝**NOTE** : Above steps are enough for you to get started with the Codelabz app. If you want to access the database you need to start the emulators.For setup husky follow [Husky Setup](#husky-setup)

### Using Docker-Compose
You can also use docker-compose to setup your project. Simply create your `.env` file and run
Expand All @@ -49,6 +50,21 @@ This will setup your project along with firebase emulator in a docker environmen



## Husky Setup

1.install Husky and lint-staged by running the following command
MuntazirHaider marked this conversation as resolved.
Show resolved Hide resolved
```
npm install husky lint-staged --save-dev
```
2. create lint-staged.config.js file in root directory and add following code
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes here. Since you've pushed lint-staged.config.js file with your pr, it should be available in the root directory after merging your pr right.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I should write husky post installation setup. I will keep in mind thank you. 😊

```
module.exports = {
'**/*': ['npm run lint', 'npm run format', 'git add'],
};

```


## Firebase Setup

1. Sign in to https://console.firebase.google.com/.
Expand Down
3 changes: 3 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'**/*': ['npm run lint', 'npm run format', 'git add'],
};
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"lint": "eslint .",
"format": "prettier --write .",
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
Expand All @@ -12,7 +14,10 @@
"prettier:write": "npx prettier --write .",
"cy:run": "cypress run --headless --browser chrome",
"cy:open": "cypress open --browser chrome",
"test": "start-server-and-test dev http://localhost:5173 cy:run"
"test": "start-server-and-test dev http://localhost:5173 cy:run",
"emulator-import": "firebase emulators:start --import=testdata",
"emulator": "firebase emulators:start",
"emulator-export": "firebase emulators:export"
},
"dependencies": {
"@ant-design/icons": "^4.2.2",
Expand Down Expand Up @@ -86,8 +91,16 @@
"@vitejs/plugin-react-swc": "^3.0.0",
"common-tags": "^1.8.2",
"cypress": "^12.3.0",
"husky": "^8.0.3",
"less": "^4.1.3",
"lint-staged": "^14.0.0",
"vite": "^4.0.0",
"webpack": "^4.46.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}

}
Loading