From 29725445cc32db14fa42cef01eb5415262ecc96e Mon Sep 17 00:00:00 2001 From: Daniel Steigman <35793213+NightTrek@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:48:43 -0800 Subject: [PATCH] Create pre-commit hooks with husky to enforce linting and formating for all commits (#1374) * updated the hooks to ensure code cleanliness * updated package-lock for the CI/CD --- .gitignore | 2 ++ .husky/pre-commit | 17 +++++++++++++++++ .prettierignore | 4 ++-- package-lock.json | 22 +++++++++++++++++++--- package.json | 4 +++- 5 files changed, 43 insertions(+), 6 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.gitignore b/.gitignore index 89382bd73..a38039207 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ node_modules *.vsix .DS_Store + +pnpm-lock.yaml \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..f7f6972ae --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,17 @@ +echo "Running pre-commit checks..." + +# Run ESLint +echo "Running ESLint..." +npm run lint || { + echo "❌ ESLint check failed. Please fix the errors and try committing again." + exit 1 +} + +# Run Prettier +echo "Running Prettier..." +npm run format || { + echo "❌ Prettier check failed. Run 'npm run format:fix' to automatically fix formatting issues." + exit 1 +} + +echo "✅ All checks passed!" diff --git a/.prettierignore b/.prettierignore index 71a9e1219..30f96297f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,5 @@ dist/ node_modules webview-ui/build/ -CHANGELOG.md -package-lock.json \ No newline at end of file +*.md +package-lock.json diff --git a/package-lock.json b/package-lock.json index c4f4ef03a..96a127d49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,12 @@ { "name": "claude-dev", - "version": "3.2.0", + "version": "3.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "claude-dev", - "version": "3.1.11", - "version": "3.2.0", + "version": "3.2.4", "license": "Apache-2.0", "dependencies": { "@anthropic-ai/bedrock-sdk": "^0.10.2", @@ -61,6 +60,7 @@ "@vscode/test-electron": "^2.4.0", "esbuild": "^0.21.5", "eslint": "^8.57.0", + "husky": "^9.1.7", "npm-run-all": "^4.1.5", "prettier": "^3.3.3", "should": "^13.2.3", @@ -7694,6 +7694,22 @@ "ms": "^2.0.0" } }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true, + "license": "MIT", + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", diff --git a/package.json b/package.json index 915ffd67f..af63be138 100644 --- a/package.json +++ b/package.json @@ -164,7 +164,8 @@ "start:webview": "cd webview-ui && npm run start", "build:webview": "cd webview-ui && npm run build", "test:webview": "cd webview-ui && npm run test", - "publish:marketplace": "vsce publish && ovsx publish" + "publish:marketplace": "vsce publish && ovsx publish", + "prepare": "husky" }, "devDependencies": { "@types/diff": "^5.2.1", @@ -178,6 +179,7 @@ "@vscode/test-electron": "^2.4.0", "esbuild": "^0.21.5", "eslint": "^8.57.0", + "husky": "^9.1.7", "npm-run-all": "^4.1.5", "prettier": "^3.3.3", "should": "^13.2.3",