DEV Community

Devansh Shah
Devansh Shah

Posted on

Adding a Static Analysis Tool as a Open Source Contribution

Intro

This week, I took the knowledge from adding prettier in Fire Linker and found an issue to add prettier to a larger repo. The repo I found was an addon for ember.js .The addon makes it easier to add Content Security Policy (CSP) to a ember project. In this blog I will talk about my experience working with a bigger repo and the process.

Process over Implementation

So, last week I showed my intention to work on this issue. Though this is smaller addition to big project but the change affects almost all the files in the repository. So, there can be many merge conflicts if I made the change and the contributors for the project where working on a bigger pr. That is what exactly happened for this issue, one of the contributors let me know he was working on a rather big change and asked if I was okay with waiting till he merges his current pr. I told him I would wait before I add prettier to the repo. A couple days pass by and the contributor mentions me and say the pr is taking much longer than expected and that I should move ahead and implement the new addition. The biggest thing I learned from this experience is how important the process and communication is when contributing to the open source. What if I had just sent a pr right as I saw the issue or had done it before I was assigned to the issue. This small addition may have caused larger problems for the project.

Implementation

Implementing prettier at first I thought was simple, got slightly more complicated when I found out prettier does not support handlebars. Though the project is mostly javascript there are some test implementation that have a handlebars application. Though I wasn't sure, if I needed to implement prettier for handlebars. When, I saw the error I got a bit worried and then did research to find that handlebars is not supported by prettier and to use prettier on handlebars I need to use a different parser known as glimmer. As, I was unsure to implement and use a different parser for prettier. I created a simple prettier script for non handlebars files and mentioned in my pr that if they wanted me to implement and thing or change it. I would do so.

Implementation Reflection

Lastly, I just want to say that this small addition changed 500+ lines of code. I found it really interesting how something so small has such a big change in a project. This also reaffirmed my understanding that we should chose a code formatter at the beginning of the project to avoid a lot of conflicts in the future.

Top comments (0)