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
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
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.
Thanks for reading
Comments
Post a Comment