-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add pre-commit hook for conventional commits and linting (#127)
- Integrated Commitizen for enforcing conventional commit messages. - Added pre-commit hook to run lint-staged for code linting before commit. - Configured commit-msg hook to validate commit messages using commitlint.
- Loading branch information
1 parent
5503143
commit 1387a35
Showing
9 changed files
with
2,715 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
npx commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
# Check if commit message is provided with -m flag | ||
COMMIT_MSG_FILE=$1 | ||
COMMIT_SOURCE=$2 | ||
|
||
# Check if commit is being created from the message source (e.g., with `git commit -m`) | ||
if echo "$HUSKY_GIT_PARAMS" | grep -qE '^-m\s'; then | ||
if [ "$COMMIT_SOURCE" = "message" ]; then | ||
exit 0 | ||
fi | ||
fi | ||
|
||
exec < /dev/tty && npx git-cz --hook || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const path = require("path"); | ||
const buildEslintCommand = (filenames) => | ||
`next lint --fix --file ${filenames | ||
.map((f) => path.relative(process.cwd(), f)) | ||
.join(" --file ")}`; | ||
module.exports = { | ||
"*.{js,jsx,ts,tsx}": [buildEslintCommand], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import type { UserConfig } from '@commitlint/types'; | ||
|
||
const Configuration: UserConfig = { | ||
extends: ['@commitlint/config-conventional'], | ||
parserPreset: 'conventional-changelog-atom', | ||
formatter: '@commitlint/format', | ||
rules: { | ||
'type-enum': [ | ||
2, | ||
'always', | ||
[ | ||
'feat', // New feature | ||
'fix', // Bug fix | ||
'docs', // Documentation changes | ||
'style', // Changes that do not affect the meaning of the code (white-space, formatting, etc.) | ||
'refactor', // Code changes that neither fix a bug nor add a feature | ||
'perf', // Performance improvement | ||
'test', // Adding missing tests or correcting existing tests | ||
'build', // Changes that affect the build system or external dependencies (example scopes: npm) | ||
'ci', // Changes to CI configuration files and scripts | ||
'chore', // Other changes that don't modify src or test files | ||
'revert', // Reverts a previous commit | ||
], | ||
], | ||
'scope-enum': [ | ||
2, | ||
'always', | ||
[ | ||
'setup', // Project setup | ||
'config', // Configuration files | ||
'deps', // Dependency updates | ||
'feature', // Feature-specific changes | ||
'bug', // Bug fixes | ||
'docs', // Documentation | ||
'style', // Code style/formatting | ||
'refactor', // Code refactoring | ||
'test', // Tests | ||
'build', // Build scripts or configuration | ||
'ci', // Continuous integration | ||
'release', // Release related changes | ||
'other', // Other changes | ||
], | ||
], | ||
}, | ||
}; | ||
|
||
export default Configuration; |
Oops, something went wrong.