From a90dfdc5a62072482b6187c6875b65aa967da851 Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Sun, 19 Nov 2023 15:25:51 +0100 Subject: [PATCH] Enable Prettier as a pre-commit hook --- .husky/.gitignore | 1 + .husky/pre-commit | 4 ++++ package.json | 6 ++++++ 3 files changed, 11 insertions(+) create mode 100644 .husky/.gitignore create mode 100755 .husky/pre-commit diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 0000000..31354ec --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..d24fdfc --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged diff --git a/package.json b/package.json index b2e54cb..788a52a 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ ], "main": "MMM-OnThisDay.js", "scripts": { + "prepare": "husky install", "prettier:fix": "prettier --write .", "test": "nyc mocha test/unit --recursive && prettier --check .", "test-functional": "mocha test/functional --recursive" @@ -24,12 +25,17 @@ "jsdom": "^22.1.0" }, "devDependencies": { + "husky": "^8.0.3", + "lint-staged": "^15.1.0", "mocha": "^10.2.0", "nyc": "^15.1.0", "prettier": "^3.1.0", "proxyquire": "^2.1.3", "sinon": "^17.0.1" }, + "lint-staged": { + "**/*": "prettier --write --ignore-unknown" + }, "nyc": { "reporter": [ "text",