From ebb0cfa01a2ac38e4ed2a72279ec88d010b19472 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolski Date: Wed, 20 Jul 2022 16:27:07 +0200 Subject: [PATCH] Add husky/lint-staged --- .husky/pre-commit | 4 ++++ package.json | 8 +++++++- pnpm-lock.yaml | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..5ba764e --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +pnpx lint-staged diff --git a/package.json b/package.json index 0967f7b..3e1e885 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "build": "tsup-node src/* --format esm,cjs --dts && clear-package-json package.json -o dist/package.json --fields publishConfig", "test": "uvu -r tsm spec", "test-watch": "watchlist src spec -- pnpm test", + "prepare": "husky install", "lint": "prettier --loglevel warn --write . && eslint --fix ." }, "keywords": [], @@ -35,6 +36,7 @@ "eslint-plugin-react": "^7.30.1", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-simple-import-sort": "^7.0.0", + "husky": "^8.0.1", "prettier": "2.6.2", "tsm": "^2.2.1", "tsup": "^6.1.3", @@ -42,6 +44,10 @@ "uvu": "^0.5.6", "watchlist": "^0.3.1" }, + "lint-staged": { + "*.{js,ts,tsx}": "eslint --cache --fix", + "*.{js,ts,tsx,css,md,json}": "prettier --write" + }, "exports": { "./package.json": "./package.json", "./const": { @@ -76,4 +82,4 @@ "url": "https://github.com/saleor/saleor-app-sdk/issues" }, "homepage": "https://github.com/saleor/saleor-app-sdk#readme" -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0d7892..9441144 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,6 +16,7 @@ specifiers: eslint-plugin-simple-import-sort: ^7.0.0 fast-glob: ^3.2.11 graphql: ^16.5.0 + husky: ^8.0.1 jose: ^4.8.3 prettier: 2.6.2 retes: ^0.29.4 @@ -45,6 +46,7 @@ devDependencies: eslint-plugin-react: 7.30.1_eslint@8.15.0 eslint-plugin-react-hooks: 4.6.0_eslint@8.15.0 eslint-plugin-simple-import-sort: 7.0.0_eslint@8.15.0 + husky: 8.0.1 prettier: 2.6.2 tsm: 2.2.1 tsup: 6.1.3_typescript@4.7.4 @@ -1425,6 +1427,12 @@ packages: engines: {node: '>=10.17.0'} dev: true + /husky/8.0.1: + resolution: {integrity: sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==} + engines: {node: '>=14'} + hasBin: true + dev: true + /ignore/5.2.0: resolution: {integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==} engines: {node: '>= 4'}