Skip to content

Conversation

@Neon-White
Copy link
Contributor

Describe the Problem

Currently, there's no automated way to ensure code quality through ESLint checks before commits. This can lead to inconsistent code style and potential issues being committed to the repository.

Explain the Changes

  1. Added a pre-commit hook in .githooks/pre-commit that runs ESLint on staged JavaScript/TypeScript files
  2. Added a preinstall script in package.json that automatically configures git to use the hooks from .githooks directory
  3. The hook will:
    • Check only staged JavaScript/TypeScript files (.js, .jsx, .ts, .tsx)
    • Run ESLint on these files
    • Block the commit if any ESLint errors are found
    • Show the specific ESLint errors that need to be fixed

Testing Instructions:

Fresh repo clone:

  1. Clone the repository
  2. Run npm install - this will automatically set up the git hooks.
  3. Make a change to any JavaScript/TypeScript file that violates ESLint rules (e.g., add an unused variable)
  4. Try to commit the change - the commit should be blocked with ESLint error messages
  5. Fix the ESLint errors and try to commit again - the commit should succeed

Existing repo clone:

  1. cd into the repo directory
  2. Run git config core.hooksPath .githooks
  3. Follow step 4 onwards above

Signed-off-by: Ben <belimele@redhat.com>
@Neon-White Neon-White merged commit 35bfb70 into noobaa:master Jun 6, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants