Skip to content

Commit 0c67201

Browse files
ss-oCopilot
andcommitted
chore: add .editorconfig and fix lint-on-edit hook
- Add .editorconfig with indent_style=space for .sh files so shfmt and git-diff-check no longer conflict on tab indentation - Replace tab indentation with 2-space indentation in lint-on-edit.sh - Scope PostToolUse hook to check only the edited file (tool_input.path) instead of all git-modified files, reducing unnecessary trunk runs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cf45504 commit 0c67201

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

.editorconfig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# EditorConfig: https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.{md,mdx}]
13+
trim_trailing_whitespace = false
14+
15+
[*.sh]
16+
indent_size = 2
17+
indent_style = space
18+
19+
[*.{json,jsonc}]
20+
indent_size = 2
21+
22+
[*.{yml,yaml}]
23+
indent_size = 2
24+
25+
[Makefile]
26+
indent_style = tab

.github/hooks/lint-on-edit.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ tool_name=$(echo "$input" | jq -r '.tool_name // empty')
1313

1414
case "$tool_name" in
1515
apply_patch | create_file | edit | editFiles | insert_edit_into_file | multi_replace_string_in_file | replace_string_in_file)
16-
pnpm lint 2>&1 | tail -40
16+
file_path=$(echo "$input" | jq -r '.tool_input.path // empty')
17+
if [[ -n $file_path && -f $file_path ]]; then
18+
trunk check "$file_path" 2>&1 | tail -40
19+
else
20+
pnpm lint 2>&1 | tail -40
21+
fi
1722
;;
1823
esac

0 commit comments

Comments
 (0)