Use Static analysis tools in Lab7

 This week we learn to manage our projects using Static analysis tools. Static analysis tools help us maintain the quality of our source code by fixing formatting issues, spotting suspicious coding constructs, or alerting us to common errors. Now I use my testLink project to practice these tools.

Create a CONTRIBUTING.md File

First, I create a CONTRIBUTING.md file to separate the setup and development content from README.md file.

Add a Source Code Formatter

I pick Prettier formatter for my JavaScript project. Following the instruction, I use the command "npm install --save-dev --save-exact prettier" to install the tool. After installing, I use the command "npx prettier --write ." to formate all my files and "npx prettier --check ." to check the files if there are some wrong formation. I also set the ".prettierrc.json" and ".prettierrcignore" file.

Then, I create a simple "one-step" solution for running my formatter in package.json file.


Add a Linter

I choose to install ESLint linter for my project.  Following the instruction, I use the command "npm install eslint --save-dev" to install the tool. Then I use "npx eslint --init" command to set up a configuration file and set some rules for my project in the ".eslintrc.json" file.


When I use "npx eslint ." to check my project, I find there are some errors and I use "npx eslint . --fix" command to fix some errors automatically and fix the other errors manually by myself. Then,  I create a simple "one-step" solution for running my linter in package.json file.


Editor/IDE Integration

For this part, I install the extensions in my vscode and set my settings in the "settings.json" and "extensions.json" files.




In the above steps, I commit the changes for every step. After making code changes, I rebase and squash all the commits to a single commit. Then I merge it with my master branch and push them to my GitHub repo.







Comments

Popular posts from this blog

Choose a project in Release 0.4

Open source development course

Publish project in Lab 9