Closed AntonioVentilii closed 1 week ago
This PR replaced PR #12 , because I changed my account.
An useful rule is to enforce the usage of utils isNullish and nonNullish from repo @dfinity/utils for a simple nullish comparison.
isNullish
nonNullish
param === undefined param === null param === undefined || param === null
isNullish(param);
param !== undefined param !== null param !== null && param !== undefined
nonNullish(param);
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 || ...
Create specific tests for the new rule.
@peterpeterparker as discussed offline, done with:
Note
This PR replaced PR #12 , because I changed my account.
Motivation
An useful rule is to enforce the usage of utils
isNullish
andnonNullish
from repo @dfinity/utils for a simple nullish comparison.isNullish
Incorrect
Correct
nonNullish
Incorrect
Correct
Future Improvements
The rule will be improved to recognize nullish check even with the following cases (and their negation counterparty):
Tests
Create specific tests for the new rule.