-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35440 from dimagi/em/prettier-hook-script
Add Prettier script and pre-commit check for HTML and stylesheets
- Loading branch information
Showing
5 changed files
with
56 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,14 @@ | ||
{ | ||
"plugins": ["prettier-plugin-jinja-template"], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"*.html" | ||
], | ||
"options": { | ||
"parser": "jinja-template" | ||
} | ||
} | ||
], | ||
"tabWidth": 2 | ||
} |
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
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
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,18 @@ | ||
#!/bin/bash | ||
|
||
get_changed() { | ||
# Get a list of changed and committed files with appropriate extensions | ||
git diff master...HEAD --name-only --diff-filter=d | grep -E "\.(html|css|scss|less)$" | ||
} | ||
|
||
prettify() { | ||
FILES=$1 | ||
echo "Formatting files changed on this branch:" | ||
./node_modules/.bin/prettier --write "$FILES" | ||
echo | ||
} | ||
|
||
CHANGED_FILES=$(get_changed) || { echo "No changed files found to format." && exit 1; } | ||
prettify "$CHANGED_FILES" || { echo "Oops! Did you remember to run yarn install?" && exit 1; } | ||
|
||
echo "Remember to commit these changes." |
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