dfinity / eslint-config-oisy-wallet

Shared ESLint configurations from the Oisy Wallet team
Apache License 2.0
2 stars 0 forks source link

feat: enforce usage of nullish check utils #12

Closed AntonioVentilii-DFINITY closed 1 week ago

AntonioVentilii-DFINITY commented 1 month ago

Motivation

An useful rule is to enforce the usage of utils isNullish and nonNullish from repo @dfinity/utils for a simple nullish comparison.

isNullish

Incorrect

param === undefined

param === null

param === undefined || param === null

Correct

isNullish(param);

nonNullish

Incorrect

param !== undefined

param !== null

param !== null && param !== undefined

Correct

nonNullish(param);

Future Improvements

The rule will be improved to recognize nullish check even with the following cases (and their negation counterparty):

const param: NonBooleanType | undefined | null;

if (param) {...}

param ? ... : ...

param && ...

param || ...

Tests

Create specific tests for the new rule.

github-actions[bot] commented 1 week ago

Thank you for contributing! Unfortunately this repository does not accept external contributions yet.

We are working on enabling this by aligning our internal processes and our CI setup to handle external contributions. However this will take some time to set up so in the meantime we unfortunately have to close this Pull Request.

We hope you understand and will come back once we accept external PRs.

— The DFINITY Foundation"""

AntonioVentilii commented 1 week ago

Closed in favour of:

because I changed my account