chore: add commitlint git hook

This commit is contained in:
Abdullah Atta
2022-08-29 13:17:45 +05:00
parent 1f2410bdd2
commit 5020f189b3
5 changed files with 1060 additions and 3 deletions

4
.husky/commit-msg Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx commitlint --edit "\${1}"

3
AUTHORS Normal file
View File

@@ -0,0 +1,3 @@
Notesnook is written & maintained by:
- Abdullah Atta <abdullahatta@streetwriters.co>
- Ammar Ahmed <ammarahmed6506@gmail.com>

17
commitlint.config.js Normal file
View File

@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { execSync } = require("child_process");
const { readFileSync } = require("fs");
const authorEmail = execSync(`git show -s --format='%ae' HEAD`)
.toString("utf-8")
.trim();
const authors = readFileSync("AUTHORS", "utf-8");
const isAuthor = authors.includes(`<${authorEmail}>`);
module.exports = {
rules: {
"signed-off-by": [isAuthor ? 0 : 2, "always", `Signed-off-by:`]
}
};

1035
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,6 +2,7 @@
"name": "notesnook", "name": "notesnook",
"private": true, "private": true,
"scripts": { "scripts": {
"prepare": "husky install",
"bootstrap": "lerna bootstrap -- --legacy-peer-deps", "bootstrap": "lerna bootstrap -- --legacy-peer-deps",
"build": "nx run-many --target=build --all --exclude=@notesnook/mobile,@notesnook/web", "build": "nx run-many --target=build --all --exclude=@notesnook/mobile,@notesnook/web",
"build:web": "nx build @notesnook/web", "build:web": "nx build @notesnook/web",
@@ -11,6 +12,8 @@
"linc": "npx eslint ./apps/ ./packages/ --cache" "linc": "npx eslint ./apps/ ./packages/ --cache"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^17.1.1",
"@types/node": "^18.7.13",
"@typescript-eslint/eslint-plugin": "^5.35.1", "@typescript-eslint/eslint-plugin": "^5.35.1",
"@typescript-eslint/parser": "^5.35.1", "@typescript-eslint/parser": "^5.35.1",
"eslint": "^8.22.0", "eslint": "^8.22.0",
@@ -21,6 +24,7 @@
"eslint-plugin-react": "^7.31.0", "eslint-plugin-react": "^7.31.0",
"eslint-plugin-react-native": "^4.0.0", "eslint-plugin-react-native": "^4.0.0",
"eslint-plugin-unused-imports": "^2.0.0", "eslint-plugin-unused-imports": "^2.0.0",
"husky": "^8.0.1",
"lerna": "^5.4.0", "lerna": "^5.4.0",
"nx": "^14.5.4", "nx": "^14.5.4",
"prettier": "^2.7.1" "prettier": "^2.7.1"