OSS Contributions: 16th-23rd August 2021
Tags: showdev, programming, deno
Published: 2021-08-22 17:20:46

After a long time, I started contributing to open-source software. For a long time, I had my eye on  [Deno](https://deno.land/). This week, I merged my first PR in [Deno Lint](https://github.com/denoland/deno_lint). Following is the detailed post about the issue.

## Issue [425](https://github.com/denoland/deno_lint/issues/425)

![deno.jpeg](https://cdn.hashnode.com/res/hashnode/image/upload/v1629650692526/tEeRz2p1U.jpeg)

**Category:** Refactoring

### Description of the Issue
If we go through the issue, we could see that in the tests of each rule, there is a repeat of messages and hints. For example, from *\ban_ts_comments.rs from a [previous commit](https://github.com/denoland/deno_lint/blob/a15d25bb84d0067971eaf3c530548b50556e35ad/src/rules/ban_ts_comment.rs#[L252,L260]), we can see that messages and hints are being repeated

```
    r#"// @ts-nocheck"#: [
            {
              col: 0,
              message: DirectiveKind::Nocheck.as_message(),
              hint: DirectiveKind::Nocheck.as_hint(),
            }
          ],
    r#"/// @ts-nocheck"#: [
            {
              col: 0,
              message: DirectiveKind::Nocheck.as_message(),
              hint: DirectiveKind::Nocheck.as_hint(),
            }
          ],
    r#"//@ts-nocheck"#: [
            {
              col: 0,
              message: DirectiveKind::Nocheck.as_message(),
              hint: DirectiveKind::Nocheck.as_hint(),
            }
          ],
    r#"// @ts-nocheck    "#: [
      {
        col: 0,
        message: DirectiveKind::Nocheck.as_message(),
        hint: DirectiveKind::Nocheck.as_hint(),
      }
```

The test cases for each rule in Deno Lint could be grouped together based on common messages and hints. This issue talks about that. Macro [assert_lint_err](https://github.com/denoland/deno_lint/blob/a15d25bb84d0067971eaf3c530548b50556e35ad/src/test_util.rs#L37) is responsible for running test cases. 

### Solution
In this [commit](https://github.com/denoland/deno_lint/commit/576f5a1fc725a49aa86ea5be0ae061ffaaed6bcf), I have extended this macro with new rules, where we could use it to run multiple test cases with the same messages and hints. Following is the modified [assert_lint_err](https://github.com/denoland/deno_lint/blob/main/src/test_util.rs#[L65,L97]) macro. I have added two new rules, where we could group tests based on messages and hints.

### Challenges
1. I did not know about Rust. I had to learn about [macro_rules!](https://doc.rust-lang.org/rust-by-example/macros.html) to solve this issue. I have gotten interested in it. Let me see, how much I make progress.
2. As this is the first time, I was contributing to Deno, I was not aware of all the formalities. [Yusuke Tanaka](https://github.com/magurotuna) from the Deno team helped me a lot. They have been very receptive and active. Their help has encouraged me to take up my [new issue](https://github.com/denoland/deno_lint/issues/779) as well.
3. This is not a challenge, but learning. I could not totally comprehend Rust-style styling. The reviewer pointed those out to me. From next time onwards, I have to be better with that.

### Follow up
In this commit, I have covered  [ban_ts_comment.rs](https://github.com/denoland/deno_lint/blob/main/src/rules/ban_ts_comment.rs)  and 
  [no_await_in_loop.rs](https://github.com/denoland/deno_lint/blob/main/src/rules/no_await_in_loop.rs). I need to cover other files as well. If someone reads this post and feels good to contribute, I would encourage them to do that 😀😀. Connect with me or anyone in Deno team for help/any questions. We will be happy to help.

I will write a detailed post on various aspects of Deno and Deno development and contributions in subsequent blog posts.