Skip to content

Add Pre-commit Hooks for Code Quality Enforcement #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
shashi-sah2003 opened this issue Apr 25, 2025 · 4 comments · May be fixed by #150
Open

Add Pre-commit Hooks for Code Quality Enforcement #144

shashi-sah2003 opened this issue Apr 25, 2025 · 4 comments · May be fixed by #150

Comments

@shashi-sah2003
Copy link

shashi-sah2003 commented Apr 25, 2025

Is your feature request related to a problem? Please describe.

Currently, the project doesn't have pre-commit hooks configured, which means linting and formatting checks aren't automatically run before commits. This allows inconsistent code style and potential issues to be committed to the repository. Developers might forget to run linting or formatting scripts manually before committing, which can lead to:

  • Inconsistent code formatting across the codebase
  • Linting errors making it into the codebase
  • Extra review cycles needed to fix styling issues

Describe the solution you'd like
I propose adding pre-commit hooks using Husky and lint-staged to automatically run the existing linting and formatting tools before each commit.

Specifically:

  1. Install Husky and lint-staged as dev dependencies
  2. Configure Husky to run lint-staged on pre-commit
  3. Configure lint-staged to run:
    • ESLint on JavaScript/TypeScript files (using the existing lint:ts script)
    • Prettier on all supported files (using the existing format script)
    • markdownlint on Markdown files (using the existing lint:md script)

Describe alternatives you've considered

  1. CI-only checks: We could rely solely on CI checks to catch these issues, but this increases the feedback loop time and can lead to more back-and-forth during PR reviews.
  2. Documentation only: We could simply document that developers should run linting/formatting manually, but this relies on developers remembering to do so and is error-prone.

Hey @pikurasa if you are okay with above feature request then I would like to work on it?
thanks

@pikurasa
Copy link
Contributor

This is something for @sa-fw-an to weigh in on.

Also. we encourage you to join the discussion on https://matrix.to/#/#sugarlabs-web:matrix.org

@sa-fw-an
Copy link
Member

@pikurasa, I’m still not sure about adding this functionality. I need some time to think it over.

@sa-fw-an
Copy link
Member

@shashi-sah2003 Go ahead and raise a PR

@shashi-sah2003 shashi-sah2003 linked a pull request Apr 28, 2025 that will close this issue
@shashi-sah2003
Copy link
Author

hey @sa-fw-an I have raised pr #150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants