Three years ago I’ve introduced lint-staged to the world. As of today, after 81 releases it’s in the dependency graph of more than 55.000 GitHub repositories and has surpassed 500.000 weekly downloads on NPM!
I would never expect lint-staged to become such a popular tool when I was releasing it back in 2015.
Shortly after lint-staged was introduced to react-boilerplate — a popular open source project by Max Stoiber, I’ve got an issue report entitled “Add better support for partially staged files”
This issue is number #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
I tried fixing the issue several times without luck. Last closest attempt was about a year ago on the train to AgentConf 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:
Today, after more than two years and 138 commits I’m very excited to finally release version 8 of lint-staged that supports partially staged files!
It uses the following algorithm:
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
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.
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.
The final solution is based on comments and ideas shared in the comments to the original issue 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 and Lufty Wiranda.
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.