From 1f8787ae6684ad7c0d9f2c5918a96dd5cec518a4 Mon Sep 17 00:00:00 2001 From: Andrey Morozov Date: Mon, 29 Aug 2022 19:02:02 +0300 Subject: [PATCH] feat: add pre-commit lint --- .husky/pre-commit | 4 ++++ package-lock.json | 9 +++++++++ package.json | 12 ++++++++++++ 3 files changed, 25 insertions(+) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..263cce3 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx nano-staged diff --git a/package-lock.json b/package-lock.json index d8e7094..96db44f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12301,6 +12301,15 @@ "dev": true, "optional": true }, + "nano-staged": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/nano-staged/-/nano-staged-0.6.0.tgz", + "integrity": "sha512-TqbdujUpBMwaBu582a5/BHlxTrs3Mu1DMk8KF2q38M0CTGiY34WRpwaQXTy5jRc5BXGjBCy4XByS69TSaS8WPw==", + "dev": true, + "requires": { + "picocolors": "^1.0.0" + } + }, "nanoid": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", diff --git a/package.json b/package.json index f97d44c..dbca2d2 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "eslint": "^8.0.0", "jest": "^28.0.0", "husky": "^8.0.0", + "nano-staged": "^0.6.0", "npm-run-all": "^4.0.0", "prettier": "^2.0.0", "react": "^17.0.0", @@ -56,5 +57,16 @@ "peerDependencies": { "react": "^17.0.0", "react-dom": "^17.0.0" + }, + "nano-staged": { + "*.{scss}": [ + "stylelint --fix --quiet" + ], + "*.{js,jsx,ts,tsx}": [ + "eslint --fix --quiet" + ], + "*.md": [ + "prettier --write" + ] } }