DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 967,611 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Thanh Van
Thanh Van

Posted on

OSD600 - Lab 7

This week, I have to work on managing project complexity through the use of Static Analysis tooling. Static Analysis tools operate on our source code (static) vs. running (dynamic). They help us maintain the quality of source code by fixing formatting issues, spotting suspicious coding constructs, or alerting us to common errors.

Prettier

I pick Prettier for my project. It will help me fix any format issue and make my code look "prettier" as its name. In order to install it, I type:

npm install --save-dev --save-exact prettier
Enter fullscreen mode Exit fullscreen mode

After that, I have to add an empty config file to let others know Prettier is being used in my program:

echo {}> .prettierrc.json
Enter fullscreen mode Exit fullscreen mode

However, I have encountered a problem when I try to use the above command, it keeps returning errors when I use it. The reason is because .prettierrc.json is encoded in UTF-16LE, not the UTF-8. So I figure the solution out by using Command Prompt in Window to run this command, and it works properly. As I initially use Prettier for my program, so after running this, it looks like nothing is changed for my format.

Linter

For my linter, I use the most popular one with Javascript developers is ESLint. It will help developers catch some unexpected errors such as spelling mistakes, using variables, etc. In order to install ESLint, I run the following command:

npm install eslint --save-dev
Enter fullscreen mode Exit fullscreen mode

After installing and running ESLint, I get a bunch of errors such as declaring a variable but never use it, even some spelling mistakes, and unnecessary \ symbol inside my regular expression. I think ESLint is so powerful for developers since it will catch the errors that we do not realize.

IDE Integration

In order to integrate the tools into the IDE, I create /.vscode folder containing workspace settings. In this folder I have two files settings.json and extensions.json, which contains all necessary configuration for my program and it will help others to know what my program needs to get the right format and the right coding style.

My commit: dd325fd

Top comments (0)

Must read:

"I made 10x faster JSON.stringify() functions, even type safe"