-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: initial setup for pre-commit, commitlinting (#67)
* chore(lint): install githook, commit linting related packages * chore(husky): add commit related githook for linting * chore(lint): overide rules based on commit convention of side * chore(lint): add custom english rule * chore(husky): convert error message from korean into english
- Loading branch information
1 parent
3d622d5
commit dd315c0
Showing
6 changed files
with
1,497 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pnpm 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 @@ | ||
pnpm 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,7 @@ | ||
# git commit -m 명령어를 사용할 때는 스킵 | ||
if [ -z "${2}" ]; then | ||
exec < /dev/tty && pnpm cz --hook || { | ||
echo "\nCommit has been cancelled." | ||
exit 1 | ||
} | ||
fi |
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,39 @@ | ||
const englishOnly = /^[A-Za-z0-9\s!@#$%^&*(),.?":{}|<>_-]+$/; | ||
|
||
// https://commitlint.js.org/reference/configuration.html#typescript-configuration | ||
import { RuleConfigSeverity, type UserConfig } from '@commitlint/types'; | ||
const Configuration: UserConfig = { | ||
extends: ['@commitlint/config-conventional'], | ||
// parserPreset: '', | ||
// formatter: '', | ||
// https://commitlint.js.org/reference/plugins.html#working-with-plugins | ||
plugins: [ | ||
{ | ||
rules: { | ||
'subject-english-only': ({ subject }) => { | ||
if (!subject) return [true, '']; | ||
const valid = englishOnly.test(subject); | ||
return [valid, 'Commit subject must contain only English characters']; | ||
}, | ||
}, | ||
}, | ||
], | ||
rules: { | ||
// https://commitlint.js.org/reference/rules.html | ||
'type-empty': [RuleConfigSeverity.Error, 'never'], | ||
'subject-empty': [RuleConfigSeverity.Error, 'never'], | ||
'subject-max-length': [RuleConfigSeverity.Error, 'always', 50], | ||
'scope-max-length': [RuleConfigSeverity.Error, 'always', 20], | ||
|
||
// custom rules | ||
'subject-english-only': [RuleConfigSeverity.Error, 'always'], | ||
}, | ||
|
||
prompt: { | ||
settings: {}, | ||
messages: {}, | ||
questions: {}, | ||
}, | ||
}; | ||
|
||
export default Configuration; |
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 |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"prepare": "husky", | ||
"cz": "cz", | ||
"build:storybook": "storybook build", | ||
"dev:storybook": "storybook dev -p 6006", | ||
"create:component": "tsx scripts/createComponent.ts create", | ||
|
@@ -11,6 +13,10 @@ | |
"devDependencies": { | ||
"@biomejs/biome": "^1.9.4", | ||
"@changesets/cli": "^2.27.9", | ||
"@commitlint/cli": "^19.6.1", | ||
"@commitlint/config-conventional": "^19.6.0", | ||
"@commitlint/cz-commitlint": "^19.6.1", | ||
"@commitlint/types": "^19.5.0", | ||
"@clack/prompts": "^0.9.0", | ||
"@storybook/addon-essentials": "catalog:", | ||
"@storybook/addon-interactions": "catalog:", | ||
|
@@ -24,15 +30,29 @@ | |
"@typescript-eslint/parser": "^8.19.0", | ||
"@vitest/coverage-v8": "catalog:", | ||
"chromatic": "^11.19.0", | ||
"commitizen": "^4.3.1", | ||
"clipanion": "4.0.0-rc.4", | ||
"eslint": "^9.17.0", | ||
"husky": "^9.1.7", | ||
"knip": "catalog:", | ||
"lint-staged": "^15.3.0", | ||
"sanitize.css": "^13.0.0", | ||
"storybook": "catalog:", | ||
"tsx": "^4.19.2", | ||
"tsup": "catalog:", | ||
"typescript": "catalog:", | ||
"vitest": "catalog:" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"lint-staged": { | ||
"packages/*/src/**/*.{ts,tsx}": [ | ||
"biome lint --apply", | ||
"eslint --fix --flag unstable_ts_config" | ||
] | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "@commitlint/cz-commitlint" | ||
} | ||
} | ||
} |
Oops, something went wrong.