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
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
- 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.
- 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.
- 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.
Top comments (0)