From 08e289c975d370d007a6140eeea12a2a6ed6905a Mon Sep 17 00:00:00 2001 From: Jeremy Asuncion Date: Fri, 9 Apr 2021 01:47:23 -0700 Subject: [PATCH] Added lint-staged and husky for linting on commit --- .husky/.gitignore | 1 + .husky/pre-commit | 5 +++++ client/.lintstagedrc.yml | 6 ++++++ client/package.json | 1 + 4 files changed, 13 insertions(+) create mode 100644 .husky/.gitignore create mode 100755 .husky/pre-commit create mode 100644 client/.lintstagedrc.yml diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 000000000..31354ec13 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..ae51f1e8b --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,5 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +cd client +node_modules/.bin/lint-staged diff --git a/client/.lintstagedrc.yml b/client/.lintstagedrc.yml new file mode 100644 index 000000000..2be78d519 --- /dev/null +++ b/client/.lintstagedrc.yml @@ -0,0 +1,6 @@ +'*.{js,ts,tsx,scss,md,yml,yaml,json}': + - prettier --write +'*.{js,ts,tsx}': + - eslint --fix +'*.scss': + - stylelint --fix diff --git a/client/package.json b/client/package.json index 0e4340eff..17221ee0e 100644 --- a/client/package.json +++ b/client/package.json @@ -10,6 +10,7 @@ "e2e": "jest -c jest/e2e.config.js", "e2e:watch": "pnpm e2e -- --watch", "e2e:update": "pnpm e2e -- --updateSnapshot", + "postinstall": "cd .. && husky install", "start": "next start -p 8080", "test": "jest -c jest/test.config.js", "test:watch": "pnpm jest -- --watch",