add ESLint pre-commit hook to enforce code quality #6480
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces a pre-commit hook that uses Husky to automatically run ESLint on staged files before each commit. The goal is to enforce consistent code quality and catch potential issues early in the development process.
Changes
Added a pre-commit hook using Husky in the .husky/ directory.
Updated package.json to include the necessary scripts for running ESLint.
Fixed existing ESLint issues to ensure compliance with the project’s style guide.
Motivation
By integrating this pre-commit hook, we aim to:
Enforce consistent code quality by automatically linting code before every commit.
Reduce the risk of committing code that doesn't adhere to the coding standards.
Ensure uniform code formatting across the team by catching issues before they are committed.
How to Test
Make a code change in any JavaScript file.
Stage the changes using git add .
Commit the changes using git commit.
The pre-commit hook will automatically run ESLint on the staged files.
If any linting issues are found, the commit will fail, and you’ll need to fix the issues before proceeding.
Additional Information
The pre-commit hook only checks the staged files and runs ESLint on them.
If no issues are found, the commit will proceed normally.