How to create your own Eslint rule with tests, boosting the DX, and code-review

As you might have seen in this forum post, I’ve created an Eslint rule that we’re using internally on Galaxy and is open-source.

If you want to learn more about how to create an Eslint rule, you can check my new blog post

Feedbacks are appreciated

6 Likes

Nice job! @vitorsouzaalmeida!

2 Likes

Can you provide examples of common scenarios where custom ESLint rules can be particularly beneficial in improving code quality and developer productivity?

1 Like

One example: we use SimplSchema for schema validation. One thing that has caused us a lot of issues is using blackbox: true which allows an object to be any structure. This caused a lot of bugs in the future when changes happen, especially when a different developer is handling the fix. Most of the time, even the original developer forgets the actual structure of supported data.

A custom Eslint rule helps us prevent the use of blackbox: true in schema objects.

1 Like

Exactly.
Automating as many things as possible during coding and code review is the idea.

For each thing that you need to constantly remember when you code something, you can delegate it to Eslint.

It’s not only about Eslint, it’s about automation. For example, if you use schemas for your collections, you’ll need to create a folder and file structure each time you make some collections. This process will not change for every collection. You can automate it using hygen

With it, you remove a lot of noise during the coding process, which allows the developer to code what matters.

1 Like