Skip to content

Commit

Permalink
Fix no-eq-null issues (#9205)
Browse files Browse the repository at this point in the history
See [`no-eq-null`](https://eslint.org/docs/rules/no-eq-null) for more information.

This change enables `no-eq-null` and fixes the issues raised by the rule.
  • Loading branch information
whymarrh authored Aug 12, 2020
1 parent f8ebfc2 commit 548b0bb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module.exports = {
'guard-for-in': 'error',
'no-case-declarations': 'error',
'no-empty': 'error',
'no-eq-null': 'error',
'no-loop-func': 'error',
'no-useless-catch': 'error',
'no-useless-concat': 'error',
Expand Down
2 changes: 1 addition & 1 deletion ui/app/components/app/asset-list-item/asset-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const AssetListItem = ({
: null

const sendTokenButton = useMemo(() => {
if (tokenAddress == null) {
if (tokenAddress === null || tokenAddress === undefined) {
return null
}
return (
Expand Down
2 changes: 1 addition & 1 deletion ui/app/helpers/utils/conversion-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const converter = ({
}

if (fromCurrency !== toCurrency) {
if (conversionRate == null) {
if (conversionRate === null || conversionRate === undefined) {
throw new Error(`Converting from ${fromCurrency} to ${toCurrency} requires a conversionRate, but one was not provided`)
}
let rate = toBigNumber.dec(conversionRate)
Expand Down
5 changes: 4 additions & 1 deletion ui/app/helpers/utils/i18n-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export const getMessage = (localeCode, localeMessages, key, substitutions) => {
return part
}
const substituteIndex = Number(subMatch[1]) - 1
if (substitutions[substituteIndex] == null && !missingSubstitutionErrors[localeCode]?.[key]) {
if (
(substitutions[substituteIndex] === null || substitutions[substituteIndex] === undefined) &&
!missingSubstitutionErrors[localeCode]?.[key]
) {
if (!missingSubstitutionErrors[localeCode]) {
missingSubstitutionErrors[localeCode] = {}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/app/hooks/useTransactionDisplayData.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function useTransactionDisplayData (transactionGroup) {
// 3. Deposit
// 4. Site interaction
// 5. Approval
if (transactionCategory == null) {
if (transactionCategory === null || transactionCategory === undefined) {
category = TRANSACTION_CATEGORY_SIGNATURE_REQUEST
title = t('signatureRequest')
subtitle = origin
Expand Down

0 comments on commit 548b0bb

Please sign in to comment.