Static Analysis Tooling

With a small scale project that only involves a few coders, styling differences are a minor nuisance. But with a larger scale project involving more coders with different habits and stylings, the tab users and space users might start the next civil war of our time. Therefore we use static analysis tooling to moderate and standardize the styling used in a specific repo. This week our professor has tasked us with implementing static analysis tools in our link checking project.


Before this lab, I've had prettier and eslint installed on my vscode as extensions but never fully understood and used them to their potential. But this lab cleared a lot up regarding these topics. So I installed prettier as a dependency and generated a config file with a few rules to test out


Then I added a few files/directories to an ignore file to skip formatting some files. After that I tested out the formatting by running
npx prettier --write .

In addition to prettier, I also installed ESLint for further formatting by pointing out lints in my code. So I installed ESLint as another dependency and setup a config file. Now by running 
npx eslint .

This will scan the project for lints in code and then you can make adjustments from there. When I got both tools working, I made npm scripts for anyone to run the commands easier.


I've also added a vscode folder recommending ESLint and Prettier as extensions to make it easier than the commands above. A format on save code was also written to automatically format code with prettier when you save them.


Finally I added one last npm package in my repo, which is husky. Husky will add a pre commit hook to format changed files with prettier automatically before they are commited.




With these tools, my code will be a lot more organized and consistent with styling in the future.


Thanks for reading

Comments

Popular posts from this blog

Release 0.3 : Telescope and The Quest for Infinity.... Scroll

Introduction

HacktoberFest Entry No.2