OSS Contributions: 16th-23rd August 2021

ยท

2 min read

After a long time, I started contributing to open-source software. For a long time, I had my eye on Deno. This week, I merged my first PR in Deno Lint. Following is the detailed post about the issue.

Issue 425

deno.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, 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 is responsible for running test cases.

Solution

In this commit, 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 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! 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 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 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 and 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.

Did you find this article valuable?

Support Subhasish Kundu by becoming a sponsor. Any amount is appreciated!

ย