Three years ago Iāve [introduced lint-staged](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8) to the world. As of today, after 81 releases itās in the dependency graph of [more than 55.000 GitHub repositories](https://github.com/okonet/lint-staged/network/dependents) and has surpassed [500.000 weekly downloads on NPM](https://www.npmjs.com/package/lint-staged)! I would never expect lint-staged to become such a popular tool when I was releasing it back in 2015. #### One issue that took me two years toĀ fix Shortly after lint-staged was introduced to [react-boilerplate](https://github.com/react-boilerplate/react-boilerplate)āāāa popular open source project by [Max Stoiber](https://medium.com/@mxstbr), Iāve got an issue report entitled [āAdd better support for partially staged filesā](https://github.com/okonet/lint-staged/issues/62) This [issue is number #62](https://github.com/okonet/lint-staged/issues/62) (yes, I can remember its number without looking it up). This issue has _lots_ of comments and _lots_ of different opinions varying from āhuh, itās as simple as doingĀ ā¦ā to āthatās impossible to achieveā. Itās so long that it would not fit into one single PNG file because it would exceed 30.000pxāāāmaximum allowed image height (sic!).  Screenshot of the issue #62 from GitHub. [https://github.com/okonet/lint-staged/issues/62](https://github.com/okonet/lint-staged/issues/62) I tried fixing the issue several times without luck. Last closest attempt was about a year ago on the train to [AgentConf](https://www.agent.sh) 2018 where I held a presentation about lint-staged.  Unfortunately, even though I spent almost a few days hacking on it I could not solve it. This work still had some positive outcomes: 1. I meet a few people during the conference who encouraged and helped me to keep trying (thanks to [Juho VepsƤlƤinen](https://medium.com/@bebraw), [Michel Weststrate](https://medium.com/@mweststrate), and Nejc Zdovc). 2. I wrote lots of tests so it became easier to do TDD and try different implementation ideas (which I did a lot). #### š Introducing lint-staged v8 Today, after more than two years and [138 commits](https://github.com/okonet/lint-staged/pull/75/commits) Iām very excited to finally release version 8 of lint-staged that supports partially staged files! It uses the following algorithm: 1. Before running linters, check if there are partially stated files (i.e. both with changes in commit index and the working copy) 2. Stash and remove from the working copy all files that arenāt in the commit index 3. Execute commands (linters and formatters) on these files 4. Add formatters changes to index (separate task in the config) 5. Restore the stashed working copy state if all linters exit with zero code (i.e. success). If there are errors running linters, restore stashed working copy. 6. Compare new commit index and working copy and _apply as many formatting changes to working copy as possible_. If there are conflicting hunks, drop formatterās changes. User modifications that were stashed should always take precedence over formatters. And this is how it looks in action: [**š«š© lint-staged with support for partially staged files** _This is the demo of how partially staged files support works in š«š© lint-staged. For more information seeā¦_asciinema.org](https://asciinema.org/a/199934 "https://asciinema.org/a/199934")[](https://asciinema.org/a/199934) Most importantly, y_ou donāt have to change your config to get support for partially staged files to work!_ The only ābreaking changeā in this version is the requirement of Node 8.6. npm install --save-dev lint-staged@latest Iāve been using it for more than a month on all my projects and consider it stable. If you happen to encounter issues with it, please report them on GitHub and help me fix them. ### Takeaways #### Donāt give up on yourĀ ideas! People kept saying that the problem Iām trying to tackle is impossible to solve. Some part of me kept denying it⦠One thing Iāve learned is that itās worth trying something if you believe into it. #### Open Source isĀ ā¤ļø The final solution is based on comments and ideas shared in the [comments to the original issue](https://github.com/okonet/lint-staged/issues/62) and wouldnāt be possible without huge support and encouragement coming from people around the globe. Iād also like to thank contributors who help me maintain the project: [Suhas Karanth](https://github.com/sudo-suhas) and [Lufty Wiranda](https://github.com/luftywiranda13). #### Open Source isĀ š© The fact it took me more than 2 years to find the solution is just ridiculous but it goes back to justifying this kind of work. I spent countless amount of hours looking for the final solution. It took me a few more days to finalize and clean up the code, merge changes from upstream, and write this blog post. Just in last 2 months I spent more than 50 hours on it. Dedicating this amount of time becomes harder and harder for me to justify, keeping in mind Iām a father of two. **If you think lint-staged is useful please consider** [**funding the project at Open Collective**](https://opencollective.com/lint-staged)**.**