

Install ESLint using npm: npm install eslint -save-dev With this tool, husky only checks for the changes that developers made, so it does not contain all the files, only those that the developer made during the commit. Husky can improve our commits by using it to lint our commit messages and run ESLint and Prettier on pre-commit. You will save time by not having to discuss style during code review. A lot of problems found by ESLint can be corrected, more than that, we can customize the rules based on your needs of your companyįormat the HTML, CSS, and TS file with the prettier rule.

Halodoc uses Typescript (Angular), so ESLint can find problems in our javascript and typescript files.

Here's how we do it 💫īefore then, we used several tools to add rules, create formats, and the tools to make them run when we committed the code. Our primary goal is to automatically format the CSS, HTML, and Typescript files. Therefore, developers will have more time to maintain their code. As a result, we created the formatter and cleaner in our code base to make the rules and run them automatically upon commit. However, not every developer knows about the long-term code they build, especially when a deadline approaches and another task awaits. In the future, we can avoid the mess by cleaning up the code we want to commit to the repository. If that happens, it will cause problems such as readability issues, developers taking more time to understand the code, bugs appearing, and when the codebase becomes more significant, it will be difficult to maintain. Let's say we don't have the same code style. Why is it necessary to format and clean the code? To ensure everyone is on the same page about coding style and patterns, guidelines or rules are essential. The same goes for developers.Įvery developer has their own coding style because they come from different backgrounds and institutions. Do you prefer a tidy or a messy room? It would be easier to find your stuff in a clean room, and you would be more comfortable working there.
