Skip to content

Commit

Permalink
Merge pull request #27 from frankiefab100/githooks
Browse files Browse the repository at this point in the history
feat: add husky and precommit hooks
  • Loading branch information
pablo-clueless authored Sep 18, 2023
2 parents 502162b + 9ab4f5d commit 71c2e33
Show file tree
Hide file tree
Showing 5 changed files with 5,074 additions and 31 deletions.
53 changes: 23 additions & 30 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react",
"prettier",
"eslint"
],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto",
"quotes": "single",
"semi": "false"
}
]
}
"env": {
"browser": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:react/recommended"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["react", "prettier", "eslint"],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto",
"quotes": "single",
"semi": "false"
}
]
}
}
3 changes: 3 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

11 changes: 11 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"


branch="$(git rev-parse --abbrev-ref HEAD)"

if [ "$branch" = "main" ]; then
echo "You can't commit directly to \"$branch\" branch"
exit 1
fi

16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@
],
"main": "index.js",
"scripts": {
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix",
"pre-commit": "lint-staged",
"test": "jest --coverage",
"copy-assets": "copyfiles --all --up 1 --exclude \"./**/*.{ts,tsx}\" \"./src/**/*\" ./dist/src/",
"compile": "rimraf dist && npx tsc",
"predev": "npm run build",
"dev": "concurrently \"npx tsc --watch\" \"nodemon -q dist/src/index.js\"",
"build": "npm run compile && npm run copy-assets",
"start": "node dist/src/index.js"
"start": "node dist/src/index.js",
"prepare": "husky install"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint:fix && yarn prettier:fix"
}
},
"repository": {
"type": "git",
Expand All @@ -32,6 +41,7 @@
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"eslint-plugin-react": "^7.33.2",
"express": "^4.18.2",
"mongoose": "^7.5.1"
},
Expand All @@ -47,7 +57,11 @@
"concurrently": "^8.2.1",
"copyfiles": "^2.4.1",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"husky": "^8.0.0",
"jest": "^29.7.0",
"lint-staged": "^14.0.1",
"morgan": "^1.10.0",
"nodemon": "^3.0.1",
"prettier": "^3.0.3",
Expand Down
Loading

0 comments on commit 71c2e33

Please sign in to comment.