Skip to content

Commit 8422457

Browse files
committed
chore: add format-and-lint hook for code formatting and linting
1 parent 5af6115 commit 8422457

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

.claude/hooks/format-and-lint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
INPUT=$(cat)
3+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
4+
5+
if [[ -z "$FILE_PATH" ]]; then
6+
exit 0
7+
fi
8+
9+
# Only run on ts/tsx/js/jsx files
10+
if [[ "$FILE_PATH" != *.ts && "$FILE_PATH" != *.tsx && "$FILE_PATH" != *.js && "$FILE_PATH" != *.jsx ]]; then
11+
exit 0
12+
fi
13+
14+
npx oxfmt "$FILE_PATH" >&2
15+
npx oxlint --type-aware --type-check "$FILE_PATH" >&2

.claude/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hooks": {
3+
"PostToolUse": [
4+
{
5+
"matcher": "Edit|Write",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "bash .claude/hooks/format-and-lint.sh"
10+
}
11+
]
12+
}
13+
]
14+
}
15+
}

CLAUDE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ Run `pnpm lint` when checking for linting OR typescript errors with oxlint.
44
Single test file: `pnpm vitest run path/to/test.ts`
55
For styling, use Tailwind CSS, class property, `cn` utility. Do not use classlist. Only colors available are those defined in Tailwind config.
66
In legacy code, use `i` tags with FontAwesome classes. In new code, use `Fa` component.
7-
At the end of plan mode, give me a list of unresolved questions to answer, if any. Make them concise.
8-
Run `pnpm lint` after making every change.
7+
At the end of plan mode, give me a list of unresolved questions to answer, if any. Make them concise.

0 commit comments

Comments
 (0)