Skip to content

Commit 8b8f9e2

Browse files
## Justification for Executing Lint Pre-Push Hook
Executing a lint pre-push hook is important for several reasons: 1. **Code Quality**: Ensures that all code being pushed meets the defined coding standards, improving overall code quality and consistency. 2. **Error Prevention**: Catches syntax errors and potential bugs early, reducing the likelihood of introducing issues into the shared codebase. 3. **Consistency**: Maintains a consistent code style across the team, making the codebase easier to read and maintain. 4. **Efficiency**: Automates the linting process, saving time for developers by catching issues before they reach code review or deployment stages. 5. **Continuous Integration**: Integrates seamlessly with continuous integration practices, ensuring that only clean, lint-free code enters the repository. By enforcing linting at the pre-push stage, teams can maintain high standards of code quality and reduce the frequency of code issues, leading to more robust and maintainable software.
1 parent 57b0233 commit 8b8f9e2

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,16 @@ Habitica's code is licensed as described at https://github.com/HabitRPG/habitica
1212
**Found a bug?** Please report it to [admin email](mailto:[email protected]) rather than creating an issue (an admin will advise you if a new issue is necessary; usually it is not).
1313

1414
**Have any questions about Habitica or its community?** See the links in the [habitica.com](https://habitica.com) website's Help menu or drop in to [Guilds > Tavern Chat](https://habitica.com/groups/tavern) to ask questions or chat socially!
15+
16+
17+
### Setup git hooks
18+
To improve code quality and rise feedback loop more efficient you can setup pre-push hooks.
19+
Hook will execute eslint verification without fixing.
20+
Eslint errors are restricted on pipeline level, so to reduce time for a feedback you can incorporate it in development stage.
21+
#### Setup hook
22+
From terminal/power shel execute script from
23+
```
24+
.\scripts\setup-pre-commit-scipts.sh
25+
```
26+
If you would like to skip pre-push hook you can push with additional parameter
27+
`git push --no-verify`

scripts/setup-pre-commit-scipts.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# Define the file path
4+
HOOK_FILE="../.git/hooks/pre-push"
5+
6+
# Define the content of the hook
7+
HOOK_CONTENT='#!/bin/sh
8+
9+
# Run ESLint
10+
echo "Running ESLint..."
11+
npm run lint
12+
13+
if [ $? -ne 0 ]; then
14+
echo "ESLint failed, aborting push."
15+
exit 1
16+
fi
17+
18+
echo "ESLint passed, pushing changes."
19+
exit 0'
20+
21+
# Create the hooks directory if it doesn't exist
22+
mkdir -p "$(dirname "$HOOK_FILE")"
23+
24+
# Write the content to the file
25+
echo "$HOOK_CONTENT" > "$HOOK_FILE"
26+
27+
# Make the file executable
28+
chmod +x "$HOOK_FILE"
29+
30+
echo "pre-push hook created successfully."

0 commit comments

Comments
 (0)