-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Added Pre-Commit Hooks for Improved Formatting (#401)
* chore(pre-commit): add pre-commit hooks for dart code formatting and adding missing required trailing commas * docs(CONTRIBUTING): add pre-commit hooks section to CONTRIBUTING.md
- Loading branch information
1 parent
a79181a
commit 5ffb350
Showing
2 changed files
with
40 additions
and
1 deletion.
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,19 @@ | ||
# Get the list of Dart files to check | ||
dart_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(dart)$') | ||
|
||
# Check if there are no Dart files to check | ||
if [[ -z "$dart_files" ]]; then | ||
exit 0 | ||
fi | ||
|
||
# Apply 'dart fix' to each file individually | ||
for file in $dart_files; do | ||
echo "Adding required trailing commas to $file..." | ||
dart fix --apply --code=require_trailing_commas "$file" | ||
done | ||
|
||
echo "Formatting Dart files..." | ||
dart format $dart_files | ||
|
||
echo "Dart files formatted successfully." | ||
exit 0 |
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