x-stend / x

`x$` is a highly flexible and extendable utility library for JavaScript and TypeScript, designed to streamline the integration and extension of various utility libraries like lodash, moment, and ramda. With `x$`, developers can easily create custom higher-order functions, ensuring adaptability and maintainability in their codebase.
MIT License
0 stars 0 forks source link

[DEVOPS]: Run lint check using git hooks on commit #32

Open cstroliadavis opened 3 months ago

cstroliadavis commented 3 months ago

Description

~While it is possible to run a lint fix on github, it is impractical and costly. It would be much better to have lint auto fixing happen directly in the local build environment whenever an attempt is made to commit code. If the code cannot be fixed, then~ any broken code in the commit should ~be prevented~ prevent the commit.

Proposed Solution

Utilize git hooks to automatically run a lint ~/fix~ on the project prior to commit.

Benefits

~This will improve code quality and reduce developer load automatically.~ it will ~also~ help developers quickly realize if they have broken something prior to pushing to the remote repo.

Additional Context

n/a

cstroliadavis commented 3 months ago

In the process of implementing this fix, I discovered that not only is it really challenging with lots of potential pitfalls to actually try to "fix" the linting errors automatically in the commit hook, it is highly discouraged as the "fixes" may not be the appropriate ones. Nearly all sources agree it is best to simply prevent the code from being committed until the fix is in place, but let the developer decide how to do that. If they want to "auto fix" on save, or handle linting and prettifying in their own way, that's fine, we simply want to make sure it doesn't get into the commit until it is fixed.

Also, not mentioned in the reqs (yet), it would be ideal if this lint only checks files that are actually in the commit, not simply the entire project, or even those that have changed but not been staged. This will reduce the need for the developer to need to "fix" things that aren't even in the commit.

cstroliadavis commented 3 months ago

Moving to on-hold because there are a lot more challenges here than expected and this functionality can wait for a bit.