oisy-wallet icon indicating copy to clipboard operation
oisy-wallet copied to clipboard

feat(ci): created local rule to use isNullish and nonNullish

Open AntonioVentilii-DFINITY opened this issue 1 year ago • 2 comments

Motivation

We would like to enforce the usage of functions isNullish and nonNullish in the code whenever possible.

Changes

  • Created custom local lint rule for isNullish usage.
  • Created custom local lint rule for nonNullish usage.
  • Fix issues created by new rules.

Tests

It raised issues, correctly, and we fixed it.

AntonioVentilii-DFINITY avatar Jun 19 '24 01:06 AntonioVentilii-DFINITY

@peterpeterparker ah! I didn't think that some of the conditions were in place with a purpose...

so, either I put the @lint-exception in place there, or I can just discard this PR, what do you think? for example, if we want to keep the rule of this PR, but have specifics checks that ignore the rule, we would do:

// eslint-disable-next-line nullish-check -- it is ok to display undefined becasue.....
if (value === null) {

AntonioVentilii-DFINITY avatar Aug 06 '24 12:08 AntonioVentilii-DFINITY

I didn't think that some of the conditions were in place with a purpose...

Yep. Checkout the definition of the store and how we handle errors in the services. On error we set null.

so, either I put the @lint-exception

Lint-exception sounds good to me, I think it's a cool stuffs to have your eslint rule. 👍 We should just pay attention at the changes and not do a bulk change.

peterpeterparker avatar Aug 06 '24 12:08 peterpeterparker

Since the code changed too much since I last reviewed this PR, I will open a new one (https://github.com/dfinity/oisy-wallet/pull/2355) and close this one

AntonioVentilii-DFINITY avatar Sep 13 '24 22:09 AntonioVentilii-DFINITY