Sharing TSLint Configurations

Detroit Labs is historically a mobile development company, but we have ventured into web development both in our client services and OnSite teams in the last year. In this time, I have worked on a client project learning TypeScript and React. Our team is growing, and the number of TypeScript codebases is increasing. :chart_with_upwards_trend:

One challenge we ran into this week while integrating TSLint into our new codebases was sharing TSLint configurations. Instead of copying and pasting config files and maintaining various copies across repos, we searched for a simpler, less painful solution to the problem. TSLint supports shareable configurations, and it’s very easy to set up!

At first, we imported a React project’s configuration and published it to NPM. However, we have two types of TypeScript codebases - a frontend React project, and a consumable Node.js API. Using TSLint’s extends for configuration inheritance allowed us to share base lint rules between codebases but override rules in our react and node configurations. Check out the commit for how this works.

I highly recommend this approach if your company has multiple TypeScript codebases and wants a consistent code style between them. Feel free to use @detroit-labs/tslint-config as a starting point or open source your company’s code style! :heart: