-
Notifications
You must be signed in to change notification settings - Fork 0
Chore/CodeStyle-CommitConvention #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/sh | ||
|
|
||
| pnpm commitlint --edit "$1" || { | ||
| echo | ||
| echo "โ ์ปค๋ฐ ๋ฉ์์ง ๊ท์น ์๋ฐ!" | ||
| echo " ํ์: CDP-์ซ์ type์ด๋ชจ์ง(scope): subject" | ||
| echo " ์์: CDP-31 fix๐(ci): CI error resolution" | ||
| echo " ํ์ฉ: featโจ, fix๐, refactor๐จ, style๐จ, choreโ๏ธ, docs๐, test๐งช" | ||
| exit 1 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/usr/bin/env sh | ||
| . "$(dirname -- "$0")/_/husky.sh" | ||
|
|
||
| echo "๐ pre-commit: lint-staged ์คํ ๋ฐ ์ต์ข ์ ๊ฒ ์์" | ||
|
|
||
| # 0) ์ปค๋ฐ์ ํฌํจ๋ ํ์ผ ๋ชฉ๋ก (์ถ๊ฐ/๋ณต์ฌ/์์ ) | ||
| STAGED_FILES="$(git diff --name-only --cached --diff-filter=ACMR)" | ||
| if [ -z "$STAGED_FILES" ]; then | ||
| echo "โน๏ธ ์คํ ์ด์ง๋ ํ์ผ์ด ์์ต๋๋ค. ๊ฑด๋๋๋๋ค." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # 1) ๋ณ๊ฒฝ ํ์ผ๋ง ์๋ ์์ (eslint --fix, prettier --write) | ||
| if ! pnpm lint-staged; then | ||
| echo | ||
|
Comment on lines
+13
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Call lint-staged via pnpm exec to avoid hook failures The new pre-commit hook runs Useful? React with ๐ย / ๐. |
||
| echo "โ lint-staged ๋จ๊ณ์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค." | ||
| echo " - ์๋์์ ๋ถ๊ฐํ ๋ฆฐํธ ์๋ฌ๊ฐ ์์ ์ ์์ด์." | ||
| echo " - ๋ก์ปฌ์์ 'pnpm lint'๋ก ์๋ฌ๋ฅผ ํ์ธํ๊ณ ์์ ํ ๋ค ๋ค์ ์ปค๋ฐํ์ธ์." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 2) ์ต์ข ์ ๊ฒ: ์คํ ์ด์ง๋ ํ์ผ๋ง ๋์์ผ๋ก ๊ฒ์ฌ(์์ ์์ด ์คํจ๋ง ๊ฐ์ง) | ||
| PRETTIER_FAIL=0 | ||
| ESLINT_FAIL=0 | ||
|
|
||
| # ๊ฐํ๋ง ๊ตฌ๋ถ์๋ก ์ฌ์ฉ (๊ณต๋ฐฑ ํฌํจ ํ์ผ๋ช ์์ ) | ||
| IFS="$(printf '\n')" | ||
| for f in $STAGED_FILES; do | ||
| case "$f" in | ||
| *.js|*.jsx|*.ts|*.tsx|*.json|*.css|*.md) | ||
| # Prettier ํฌ๋งท ์ค์ ํ์ธ (์์ ์์ด ๊ฒ์ฌ) | ||
| pnpm -s prettier --check "$f" || PRETTIER_FAIL=1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| for f in $STAGED_FILES; do | ||
| case "$f" in | ||
| *.js|*.jsx|*.ts|*.tsx) | ||
| # ESLint ์ต์ข ํ์ธ (์์ ์์ด ๊ฒ์ฌ) | ||
| pnpm -s eslint --max-warnings=0 "$f" || ESLINT_FAIL=1 | ||
| ;; | ||
| esac | ||
| done | ||
| unset IFS | ||
|
|
||
| if [ "$PRETTIER_FAIL" -ne 0 ]; then | ||
| echo | ||
| echo "โ Prettier ํฌ๋งท ์๋ฐ์ด ๋จ์ ์์ต๋๋ค." | ||
| echo " - 'pnpm format' ํ ๋ค์ ์ปค๋ฐํ์ธ์." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$ESLINT_FAIL" -ne 0 ]; then | ||
| echo | ||
| echo "โ ESLint ์๋ฐ์ด ๋จ์ ์์ต๋๋ค." | ||
| echo " - 'pnpm lint:fix' ๋๋ ์๋ ์์ ํ ๋ค์ ์ปค๋ฐํ์ธ์." | ||
| exit 1 | ||
| fi | ||
|
|
||
| COUNT="$(printf '%s\n' "$STAGED_FILES" | wc -l | tr -d ' ')" | ||
| echo "โ pre-commit ํต๊ณผ: ${COUNT}๊ฐ ํ์ผ ์ ๊ฒ ์๋ฃ" | ||
| exit 0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| node_modules | ||
| .next | ||
| out | ||
| dist | ||
| coverage | ||
| .turbo | ||
| public/generated |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "printWidth": 100, | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "semi": true, | ||
| "singleQuote": false, | ||
| "trailingComma": "all", | ||
| "bracketSpacing": true, | ||
| "arrowParens": "always", | ||
| "endOfLine": "lf", | ||
| "proseWrap": "preserve" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /** commitlint.config.cjs */ | ||
| module.exports = { | ||
| extends: ["@commitlint/config-conventional"], | ||
| parserPreset: { | ||
| parserOpts: { | ||
| // CDP-123 choreโ๏ธ(scope): subject | ||
| headerPattern: | ||
| /^(CDP-\d+)\s(featโจ|fix๐|refactor๐จ|style๐จ|choreโ๏ธ|docs๐|test๐งช)\(([^)]+)\):\s(.+)$/, | ||
| headerCorrespondence: ["ticket", "type", "scope", "subject"], | ||
| }, | ||
| }, | ||
| rules: { | ||
| "type-enum": [ | ||
| 2, | ||
| "always", | ||
| ["featโจ", "fix๐", "refactor๐จ", "style๐จ", "choreโ๏ธ", "docs๐", "test๐งช"], | ||
| ], | ||
| "scope-empty": [2, "never"], | ||
| "subject-empty": [2, "never"], | ||
| "header-max-length": [2, "always", 120], | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,21 @@ | ||
| // eslint.config.mjs | ||
| import { FlatCompat } from "@eslint/eslintrc"; | ||
| import { dirname } from "path"; | ||
| import { fileURLToPath } from "url"; | ||
| import { FlatCompat } from "@eslint/eslintrc"; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = dirname(__filename); | ||
|
|
||
| const compat = new FlatCompat({ | ||
| baseDirectory: __dirname, | ||
| }); | ||
| const compat = new FlatCompat({ baseDirectory: __dirname }); | ||
|
|
||
| const config = [ | ||
| // Next ๊ถ์ฅ + TS + Prettier ์ถ์ฒ(FlatCompat๋ก ๋ ๊ฑฐ์ ํ์ฅ ๋ณํ) | ||
| ...compat.extends("next/core-web-vitals", "next/typescript", "plugin:prettier/recommended"), | ||
|
|
||
| const eslintConfig = [ | ||
| ...compat.extends("next/core-web-vitals", "next/typescript"), | ||
| // ๋ฌด์ ๋ชฉ๋ก | ||
| { | ||
| ignores: [ | ||
| "node_modules/**", | ||
| ".next/**", | ||
| "out/**", | ||
| "build/**", | ||
| "next-env.d.ts", | ||
| ], | ||
| ignores: ["node_modules/**", ".next/**", "out/**", "build/**", "next-env.d.ts"], | ||
| }, | ||
| ]; | ||
|
|
||
| export default eslintConfig; | ||
| export default config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Use pnpm exec for commitlint in commit-msg hook
The commit message hook invokes
pnpm commitlint, but pnpm cannot find that command because the repo defines nocommitlintscript. This means every commit will abort with โCommand "commitlint" not foundโ and the message is never checked. Runpnpm exec commitlint --edit "$1"(or add acommitlintscript) to make the hook work.Useful? React with ๐ย / ๐.