Skip to content

Commit

Permalink
ci(config): 🔨 add branch config
Browse files Browse the repository at this point in the history
add branch config for main and development

Ref: #4
  • Loading branch information
anantakumarghosh committed Jan 15, 2024
1 parent 172c706 commit 12d01fa
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

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

valid_branch_names_regex="^WRPD-(feature|bugfix|release|ci|enhancement|hotfix|refactor|deps|docs|experimental|security)?-[0-9]+$|^main$|^development$"
branch="$(git rev-parse --abbrev-ref HEAD)"

if [ "$branch" = "main" ] || [ "$branch" = "development" ]; then
echo "Committing on the $branch branch is not allowed."
exit 1
fi

if ! [[ $branch =~ $valid_branch_n$branames_regex ]]; then
echo "Invalid branch name: $branch; commit rejected"
echo "Please rename your branch to conform to $valid_branch_names_regex pattern."
exit 1
fi
# anable after linting config is created.
# npx lint-staged
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"files.eol": "\n",
"[javascript]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
Expand Down
42 changes: 42 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* List of commit types allowed in commit messages.
*
* @author Ananta Kumar Ghosh <[email protected]>
*/
const types = [
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test"
];

/**
* List of commit scopes allowed in commit messages.
*/
const scopes = ["config", "core", "global", "utils"];

// eslint-disable-next-line no-undef
module.exports = {
extends: ["@commitlint/config-conventional"],

parserPreset: { parserOpts: { issuePrefixes: ["#"] } },

rules: {
"body-leading-blank" : [2, "always"],
"body-max-line-length": [2, "always", 250],
"footer-empty" : [2, "never"],
"footer-leading-blank": [2, "always"],
"references-empty" : [2, "never"],
"scope-case" : [2, "always", "camel-case"],
"scope-empty" : [0, "always"],
"scope-enum" : [2, "always", scopes],
"type-enum" : [2, "always", types],
},
};
1 change: 1 addition & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { "**/*.{js,jsx,ts,tsx}": ["npx eslint --ignore-path .gitignore ./app"] };
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "This is a template repository for a wrappid module.",
"main": "index.js",
"scripts": {
"prepare": "husky install",
"code:lint:app": "eslint --ignore-path .gitignore ./app",
"code:format:app": "npm run code:lint:app -- --fix ./app",
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down Expand Up @@ -31,7 +32,8 @@
"eslint-plugin-require-extensions": "^0.1.3",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-unused-imports": "^2.0.0",
"react-redux": "^8.0.5"
"react-redux": "^8.0.5",
"husky": "^8.0.3"
},
"dependencies": {
"@faker-js/faker": "^8.1.0",
Expand All @@ -54,4 +56,4 @@
}
}
}
}
}

0 comments on commit 12d01fa

Please sign in to comment.