Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.opt-in-hooks
7 changes: 7 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if [ -f ".opt-in-hooks" ]; then
echo "✅ Git hooks are enabled locally. Running pre-commit checks..."
pnpm exec lint-staged
else
echo "ℹ️ Skipping pre-commit hooks. To enable, create an '.opt-in-hooks' file."
exit 0
fi
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ build
coverage
.docusaurus
.github
.gitignore
.husky
.prettierignore
pnpm-lock.yaml
.svg
*.svg
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,32 @@ All changes will be reviewed by a member of the current GPUL board before being

For more detailed information, please read our [Contributing Guide](CONTRIBUTING.md).

### Code Quality and Pre-Commit Hooks

To help maintain code quality and consistent formatting, this project includes pre-commit hooks that run [ESLint](https://eslint.org/) and [Prettier](https://prettier.io/) on staged files before a commit is made. The same linting and formatting is being run on CI.

These hooks are **completely optional** (opt-in) to give developers flexibility in their workflow, however, we encourage its use, to avoid having to re-do commits to pass CI.

### How It Works

- **ESLint**: Checks for potential bugs and enforces code style rules. If any errors are found, **the commit will be aborted**, and you will need to fix the errors manually before trying to commit again.
- **Prettier**: Automatically formats your code to ensure a consistent style across the entire codebase.

### How to Enable the Hooks

If you wish to enable the pre-commit hooks on your local machine, follow this simple step.

1. Navigate to the root directory of the project in your terminal.
2. Create the opt-in file by running the following command:

```bash
touch .opt-in-hooks
```

That's it! The hooks will now run automatically every time you make a commit. The `.opt-in-hooks` file is listed in our `.gitignore`, so it won't be added to the repository.

If you decide you no longer want the hooks to run, simply delete the `.opt-in-hooks` file.

## 📄 License

This project is licensed under the GPL v3 License - see the [LICENSE](LICENSE) file for details.
Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc"
"typecheck": "tsc",
"prepare": "husky"
},
"dependencies": {
"@docusaurus/core": "3.7.0",
Expand All @@ -38,6 +39,8 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.3.0",
"husky": "^9.1.7",
"lint-staged": "^16.1.2",
"prettier": "^3.5.3",
"typescript": "~5.6.2",
"typescript-eslint": "^8.36.0"
Expand All @@ -56,5 +59,11 @@
},
"engines": {
"node": ">=18.0"
},
"lint-staged": {
"*": [
"eslint",
"prettier --write"
]
}
}
Loading