diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d61909c4..7a855be5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 @@ -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 +``` +npm install husky lint-staged --save-dev +``` +2. create lint-staged.config.js file in root directory and add following code +``` +module.exports = { + '**/*': ['npm run lint', 'npm run format', 'git add'], +}; + +``` + + ## Firebase Setup 1. Sign in to https://console.firebase.google.com/. diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 00000000..7fdb8588 --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,3 @@ +module.exports = { + '**/*': ['npm run lint', 'npm run format', 'git add'], + }; \ No newline at end of file diff --git a/package.json b/package.json index 4ec2f6d5..450a65e7 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "version": "0.0.0", "type": "module", "scripts": { + "lint": "eslint .", + "format": "prettier --write .", "dev": "vite", "build": "vite build", "preview": "vite preview", @@ -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", @@ -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" + } } + }