From 5cea0ac16c274934db0828b7206bded73128ca59 Mon Sep 17 00:00:00 2001 From: Chris Vogt Date: Sun, 1 Dec 2024 23:11:28 -0800 Subject: [PATCH] SQUASHME: update CircleCI script and add Husky hooks --- .circleci/config.yml | 10 +++++++++- .husky/pre-commit | 6 ++---- .husky/pre-push | 3 +++ package.json | 8 +++++--- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 .husky/pre-push diff --git a/.circleci/config.yml b/.circleci/config.yml index 7d54d5c6..1e6bd790 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 jobs: build: docker: - - image: cimg/node:20.9.0 # Updated to Node 20.9.0 + - image: cimg/node:20.9.0 # Updated to Node 20.9.0 working_directory: ~/gatsby-theme-chrisvogt @@ -26,6 +26,14 @@ jobs: paths: - ~/.cache/yarn + - run: + name: Run Prettier Check + command: yarn prettier --check . + + - run: + name: Run ESLint Check + command: yarn lint + - run: name: Unit Tests w/Coverage command: yarn workspace gatsby-theme-chrisvogt test:coverage --maxWorkers=2 diff --git a/.husky/pre-commit b/.husky/pre-commit index 58042295..d8806341 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1,3 @@ -# Format staged files with Prettier +# Run Prettier and ESLint on staged files npx pretty-quick --staged - -# Lint staged files with ESLint -npx eslint --fix $(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|json)$') || exit 1 +npx eslint --fix $(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx)$') || exit 1 diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100644 index 00000000..1bc7ac67 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,3 @@ +# Run tests and lint the full codebase +yarn test --passWithNoTests || exit 1 +npx eslint . || exit 1 diff --git a/package.json b/package.json index 10a8833b..e7460c0a 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,12 @@ "develop": "yarn workspace www.chrisvogt.me develop:https", "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,md}\"", "lint": "eslint", - "test": "yarn workspace gatsby-theme-chrisvogt test", - "test:watch": "yarn workspace gatsby-theme-chrisvogt test:watch", "postinstall": "node index.js", - "prepare": "husky install" + "prepare": "husky install", + "prettier": "prettier", + "test:coverage": "yarn workspace gatsby-theme-chrisvogt test --coverage", + "test:watch": "yarn workspace gatsby-theme-chrisvogt test:watch", + "test": "yarn workspace gatsby-theme-chrisvogt test" }, "devDependencies": { "@eslint/compat": "^1.2.3",