From edb69265c2a69fdb65beb0772516f5e0f7d41363 Mon Sep 17 00:00:00 2001 From: MD SADAB SAQIB Date: Thu, 25 Apr 2024 22:26:03 +1000 Subject: [PATCH] added husky pre commit to check run lint rules --- .husky/pre-commit | 1 + README.md | 6 +++++- package-lock.json | 22 ++++++++++++++++++++++ package.json | 4 +++- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..a845b85 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npm run lint \ No newline at end of file diff --git a/README.md b/README.md index 9655f0e..2a99faa 100644 --- a/README.md +++ b/README.md @@ -84,12 +84,15 @@ npm run cleanup - Docker for testing against/using containerization - Github actions CI/CD integration - Report portal integration -- dotenv to store secrets locally +- dotenv to store secrets locally +- eslint linting tools integrated +- husky git hooks for pre-commit checks (eslint) ### Folder Structure ```ini ├───.github +├───.husky ├───.vscode ├───.images ├───tests @@ -102,6 +105,7 @@ npm run cleanup | └───types ├───.env ├───.env.example +├───.eslintrc.js ├───.gitignore ├───docker-compose.yml ├───package-lock.json diff --git a/package-lock.json b/package-lock.json index 00ce96f..095a4d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "dotenv": "^16.4.5", "eslint": "^8.57.0", "eslint-plugin-wdio": "^8.24.12", + "husky": "^9.0.11", "ts-node": "^10.9.2", "typescript": "^5.4.5", "wdio-docker-service": "^3.2.1" @@ -5161,6 +5162,21 @@ "ms": "^2.0.0" } }, + "node_modules/husky": { + "version": "9.0.11", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz", + "integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==", + "dev": true, + "bin": { + "husky": "bin.mjs" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -14205,6 +14221,12 @@ "ms": "^2.0.0" } }, + "husky": { + "version": "9.0.11", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz", + "integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==", + "dev": true + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", diff --git a/package.json b/package.json index bdb8f30..8915b07 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "docker:stop": "docker compose -f tests/docker/docker-compose.yml down", "docker:stop:arm": "docker compose -f tests/docker/docker-compose-arm.yml down", "lint": "eslint .", - "lint:fix": "eslint . --fix" + "lint:fix": "eslint . --fix", + "prepare": "husky" }, "author": "MD SADAB SAQIB", "license": "ISC", @@ -35,6 +36,7 @@ "dotenv": "^16.4.5", "eslint": "^8.57.0", "eslint-plugin-wdio": "^8.24.12", + "husky": "^9.0.11", "ts-node": "^10.9.2", "typescript": "^5.4.5", "wdio-docker-service": "^3.2.1"