From 8a0f3cfe5fb538c6d1fb5b896cc08a596dd9c5b4 Mon Sep 17 00:00:00 2001 From: Tom Southall Date: Tue, 15 Mar 2022 13:54:49 +0000 Subject: [PATCH] Add pre-commit hooks for test and lint --- .husky/pre-commit | 5 +++++ package-lock.json | 26 ++++++++++++++++++++++++-- package.json | 5 ++++- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..39fc256 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,5 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npm test +npm run lint diff --git a/package-lock.json b/package-lock.json index a03251c..bc50b69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "turnstone", - "version": "1.0.2", + "version": "1.1.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "turnstone", - "version": "1.0.2", + "version": "1.1.2", "dependencies": { "escape-string-regexp": "^5.0.0", "first-of-type": "^1.0.0", @@ -27,6 +27,7 @@ "eslint": "^8.9.0", "eslint-plugin-react": "^7.28.0", "eslint-plugin-react-hooks": "^4.3.0", + "husky": "^7.0.4", "jsdom": "^19.0.0", "msw": "^0.36.8", "node-fetch": "^2.6.7", @@ -2916,6 +2917,21 @@ "node": ">= 6" } }, + "node_modules/husky": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", + "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", + "dev": true, + "bin": { + "husky": "lib/bin.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/hyphenate-style-name": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz", @@ -7490,6 +7506,12 @@ "debug": "4" } }, + "husky": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", + "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", + "dev": true + }, "hyphenate-style-name": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz", diff --git a/package.json b/package.json index 075228c..0005e29 100644 --- a/package.json +++ b/package.json @@ -36,9 +36,11 @@ "scripts": { "dev": "vite", "build": "vite build", + "lint": "npx eslint ./src/lib/ --ext .js,.jsx", "test": "vitest run", "watch": "vitest", - "coverage": "vitest run --coverage" + "coverage": "vitest run --coverage", + "prepare": "husky install" }, "dependencies": { "escape-string-regexp": "^5.0.0", @@ -60,6 +62,7 @@ "eslint": "^8.9.0", "eslint-plugin-react": "^7.28.0", "eslint-plugin-react-hooks": "^4.3.0", + "husky": "^7.0.4", "jsdom": "^19.0.0", "msw": "^0.36.8", "node-fetch": "^2.6.7",