From 4ca546b5e6277790955df610e910d17ce727d18c Mon Sep 17 00:00:00 2001 From: Mashrukh Islam Date: Wed, 10 Apr 2024 14:49:21 +0530 Subject: [PATCH] [Task] Adding pre commit hook to check for lint errors and fixing them (#26) Co-authored-by: Mashrukh Islam --- .husky/pre-commit | 4 ++++ package-lock.json | 16 ++++++++++++++++ package.json | 8 +++++--- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..75fac8e1 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run lint diff --git a/package-lock.json b/package-lock.json index 4ae6f1f5..b4532b26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "eslint-plugin-import": "^2.27.5", "eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-react": "^7.32.2", + "husky": "^8.0.0", "react": "^18.2.0", "react-dom": "^18.2.0", "selenium-webdriver": "^4.18.1", @@ -3356,6 +3357,21 @@ "node": ">= 14" } }, + "node_modules/husky": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", + "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", + "dev": true, + "bin": { + "husky": "lib/bin.js" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", diff --git a/package.json b/package.json index d9b26fbd..eb31dc08 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,13 @@ } }, "scripts": { - "lint": "eslint . --ext .tsx", + "lint": "eslint --fix . --ext .tsx", "test": "node ./test/RunTests.js", "build": "tsc && vite build && cp ./dist/index.d.ts ./dist/index.d.cts", "prepublishOnly": "tsc && vite build && cp ./dist/index.d.ts ./dist/index.d.cts", "prepack": "tsc && vite build && cp ./dist/index.d.ts ./dist/index.d.cts", - "start": "vite serve" + "start": "vite serve", + "prepare": "husky install" }, "author": "tjtanjin", "license": "MIT", @@ -57,7 +58,8 @@ "typescript": "^5.1.6", "vite": "^4.5.2", "vite-plugin-dts": "^3.4.0", - "vite-plugin-svgr": "^3.2.0" + "vite-plugin-svgr": "^3.2.0", + "husky": "^8.0.0" }, "browserslist": { "production": [