From 0086216c9d61874e798680c19d0178d66352cf66 Mon Sep 17 00:00:00 2001 From: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> Date: Wed, 14 Sep 2022 14:40:44 -0700 Subject: [PATCH] Add eqeqeq rule but require == for null --- .eslintrc.js | 4 +++ ts/SignalProtocolStore.ts | 26 +++++++++---------- ts/background.ts | 2 +- ts/components/CompositionInput.tsx | 6 ++--- ts/components/conversation/MessageAudio.tsx | 2 +- ts/jobs/helpers/syncHelpers.ts | 2 +- ts/models/messages.ts | 6 ++--- ts/quill/emoji/completion.tsx | 6 ++--- ts/quill/mentions/completion.tsx | 2 +- ts/quill/signal-clipboard/index.ts | 12 ++++----- ts/scripts/symbolicate-crash-reports.ts | 2 +- ts/services/storage.ts | 5 +--- ts/services/storageRecordOps.ts | 1 + ts/sql/cleanDataForIpc.ts | 3 ++- .../util/getStreamWithTimeout_test.ts | 2 +- .../linkPreviews/linkPreviewFetch_test.ts | 2 +- ts/textsecure/EventTarget.ts | 6 ++--- ts/textsecure/Helpers.ts | 2 +- ts/textsecure/MessageReceiver.ts | 2 +- ts/textsecure/SendMessage.ts | 8 +++--- ts/textsecure/processDataMessage.ts | 5 +--- ts/types/Address.ts | 2 +- ts/types/QualifiedAddress.ts | 2 +- ts/types/Stickers.ts | 2 +- ts/util/dropNull.ts | 3 ++- ts/util/isNotNil.ts | 2 +- ts/util/isRecord.ts | 2 +- ts/util/iterables.ts | 2 +- ts/util/memoizeByRoot.ts | 2 +- ts/util/sessionTranslation.ts | 4 +-- 30 files changed, 64 insertions(+), 63 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index facd2e1361e..bfb17bd1fca 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,6 +19,10 @@ const rules = { 'brace-style': ['error', '1tbs', { allowSingleLine: false }], curly: ['error', 'all'], + // Always use === and !== except when directly comparing to null + // (which only will equal null or undefined) + eqeqeq: ['error', 'always', { null: 'never' }], + // prevents us from accidentally checking in exclusive tests (`.only`): 'mocha/no-exclusive-tests': 'error', diff --git a/ts/SignalProtocolStore.ts b/ts/SignalProtocolStore.ts index aaef4899b07..7d3f777ef19 100644 --- a/ts/SignalProtocolStore.ts +++ b/ts/SignalProtocolStore.ts @@ -931,7 +931,7 @@ export class SignalProtocolStore extends EventsMixin { throw new Error('loadSession: this.sessions not yet cached!'); } - if (qualifiedAddress === null || qualifiedAddress === undefined) { + if (qualifiedAddress == null) { throw new Error('loadSession: qualifiedAddress was undefined/null'); } @@ -1049,7 +1049,7 @@ export class SignalProtocolStore extends EventsMixin { throw new Error('storeSession: this.sessions not yet cached!'); } - if (qualifiedAddress === null || qualifiedAddress === undefined) { + if (qualifiedAddress == null) { throw new Error('storeSession: qualifiedAddress was undefined/null'); } const { uuid, deviceId } = qualifiedAddress; @@ -1225,7 +1225,7 @@ export class SignalProtocolStore extends EventsMixin { throw new Error('removeAllSessions: this.sessions not yet cached!'); } - if (identifier === null || identifier === undefined) { + if (identifier == null) { throw new Error('removeAllSessions: identifier was undefined/null'); } @@ -1491,7 +1491,7 @@ export class SignalProtocolStore extends EventsMixin { throw new Error('isTrustedIdentity: this.identityKeys not yet cached!'); } - if (encodedAddress === null || encodedAddress === undefined) { + if (encodedAddress == null) { throw new Error('isTrustedIdentity: encodedAddress was undefined/null'); } const ourUuid = window.textsecure.storage.user.getCheckedUuid(); @@ -1553,7 +1553,7 @@ export class SignalProtocolStore extends EventsMixin { } async loadIdentityKey(uuid: UUID): Promise { - if (uuid === null || uuid === undefined) { + if (uuid == null) { throw new Error('loadIdentityKey: uuid was undefined/null'); } const identityRecord = await this.getOrMigrateIdentityRecord(uuid); @@ -1566,7 +1566,7 @@ export class SignalProtocolStore extends EventsMixin { } async getFingerprint(uuid: UUID): Promise { - if (uuid === null || uuid === undefined) { + if (uuid == null) { throw new Error('loadIdentityKey: uuid was undefined/null'); } @@ -1606,7 +1606,7 @@ export class SignalProtocolStore extends EventsMixin { throw new Error('saveIdentity: this.identityKeys not yet cached!'); } - if (encodedAddress === null || encodedAddress === undefined) { + if (encodedAddress == null) { throw new Error('saveIdentity: encodedAddress was undefined/null'); } if (!(publicKey instanceof Uint8Array)) { @@ -1703,7 +1703,7 @@ export class SignalProtocolStore extends EventsMixin { uuid: UUID, attributes: Partial ): Promise { - if (uuid === null || uuid === undefined) { + if (uuid == null) { throw new Error('saveIdentityWithAttributes: uuid was undefined/null'); } @@ -1728,7 +1728,7 @@ export class SignalProtocolStore extends EventsMixin { } async setApproval(uuid: UUID, nonblockingApproval: boolean): Promise { - if (uuid === null || uuid === undefined) { + if (uuid == null) { throw new Error('setApproval: uuid was undefined/null'); } if (typeof nonblockingApproval !== 'boolean') { @@ -1750,7 +1750,7 @@ export class SignalProtocolStore extends EventsMixin { verifiedStatus: number, publicKey?: Uint8Array ): Promise { - if (uuid === null || uuid === undefined) { + if (uuid == null) { throw new Error('setVerified: uuid was undefined/null'); } if (!validateVerifiedStatus(verifiedStatus)) { @@ -1775,7 +1775,7 @@ export class SignalProtocolStore extends EventsMixin { } async getVerified(uuid: UUID): Promise { - if (uuid === null || uuid === undefined) { + if (uuid == null) { throw new Error('getVerified: uuid was undefined/null'); } @@ -1799,7 +1799,7 @@ export class SignalProtocolStore extends EventsMixin { verifiedStatus: number, publicKey?: Uint8Array ): Promise { - if (uuid === null || uuid === undefined) { + if (uuid == null) { throw new Error('processVerifiedMessage: uuid was undefined/null'); } if (!validateVerifiedStatus(verifiedStatus)) { @@ -1849,7 +1849,7 @@ export class SignalProtocolStore extends EventsMixin { } isUntrusted(uuid: UUID, timestampThreshold = TIMESTAMP_THRESHOLD): boolean { - if (uuid === null || uuid === undefined) { + if (uuid == null) { throw new Error('isUntrusted: uuid was undefined/null'); } diff --git a/ts/background.ts b/ts/background.ts index 010dd77351e..0abc9ea3457 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -3561,7 +3561,7 @@ export async function startApp(): Promise { const { storageServiceKey } = ev; - if (storageServiceKey === null) { + if (storageServiceKey == null) { log.info('onKeysSync: deleting window.storageKey'); window.storage.remove('storageKey'); } diff --git a/ts/components/CompositionInput.tsx b/ts/components/CompositionInput.tsx index 7ad5af866ee..dac51338869 100644 --- a/ts/components/CompositionInput.tsx +++ b/ts/components/CompositionInput.tsx @@ -185,7 +185,7 @@ export function CompositionInput(props: Props): React.ReactElement { const range = quill.getSelection(); const insertionRange = range || lastSelectionRange; - if (insertionRange === null) { + if (insertionRange == null) { return; } @@ -599,7 +599,7 @@ export function CompositionInput(props: Props): React.ReactElement { quill.once('editor-change', () => { const scroller = scrollerRef.current; - if (scroller !== null) { + if (scroller != null) { quill.scrollingContainer = scroller; } @@ -613,7 +613,7 @@ export function CompositionInput(props: Props): React.ReactElement { 'selection-change', (newRange: RangeStatic, oldRange: RangeStatic) => { // If we lose focus, store the last edit point for emoji insertion - if (newRange === null) { + if (newRange == null) { setLastSelectionRange(oldRange); } } diff --git a/ts/components/conversation/MessageAudio.tsx b/ts/components/conversation/MessageAudio.tsx index 712430b5d83..39f8fa27745 100644 --- a/ts/components/conversation/MessageAudio.tsx +++ b/ts/components/conversation/MessageAudio.tsx @@ -226,7 +226,7 @@ export const MessageAudio: React.FC = (props: Props) => { setActiveAudioID, } = props; - assert(audio !== null, 'GlobalAudioContext always provides audio'); + assert(audio != null, 'GlobalAudioContext always provides audio'); const isActive = activeAudioID === id && activeAudioContext === renderingContext; diff --git a/ts/jobs/helpers/syncHelpers.ts b/ts/jobs/helpers/syncHelpers.ts index af62c51ee1b..b28b944175d 100644 --- a/ts/jobs/helpers/syncHelpers.ts +++ b/ts/jobs/helpers/syncHelpers.ts @@ -56,7 +56,7 @@ function parseOptionalString(name: string, value: unknown): undefined | string { if (typeof value === 'string') { return value; } - if (value === undefined || value === null) { + if (value == null) { return undefined; } throw new Error(`${name} was not a string`); diff --git a/ts/models/messages.ts b/ts/models/messages.ts index bf4b4a14859..d9e4f6caee6 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -1895,11 +1895,11 @@ export class MessageModel extends window.Backbone.Model { attachments: quote.attachments.slice(), bodyRanges: quote.bodyRanges.map(({ start, length, mentionUuid }) => { strictAssert( - start !== undefined && start !== null, + start != null, 'Received quote with a bodyRange.start == null' ); strictAssert( - length !== undefined && length !== null, + length != null, 'Received quote with a bodyRange.length == null' ); @@ -2564,7 +2564,7 @@ export class MessageModel extends window.Backbone.Model { } let avatar = null; - if (downloadedAvatar && avatarAttachment !== null) { + if (downloadedAvatar && avatarAttachment != null) { const onDiskAttachment = await Attachment.migrateDataToFileSystem(downloadedAvatar, { writeNewAttachmentData: diff --git a/ts/quill/emoji/completion.tsx b/ts/quill/emoji/completion.tsx index eb2d2f00b7d..7ee18ec5f64 100644 --- a/ts/quill/emoji/completion.tsx +++ b/ts/quill/emoji/completion.tsx @@ -202,7 +202,7 @@ export class EmojiCompletion { completeEmoji(): void { const range = this.quill.getSelection(); - if (range === null) { + if (range == null) { return; } @@ -211,7 +211,7 @@ export class EmojiCompletion { const tokenTextMatch = /:([-+0-9a-z_]*)(:?)$/.exec(leafText); - if (tokenTextMatch === null) { + if (tokenTextMatch == null) { return; } @@ -277,7 +277,7 @@ export class EmojiCompletion { getBoundingClientRect() { const selection = window.getSelection(); // there's a selection and at least one range - if (selection !== null && selection.rangeCount !== 0) { + if (selection != null && selection.rangeCount !== 0) { // grab the first range, the one the user is actually on right now // clone it so we don't actually modify the user's selection/caret position const range = selection.getRangeAt(0).cloneRange(); diff --git a/ts/quill/mentions/completion.tsx b/ts/quill/mentions/completion.tsx index d5193945f50..6f1f7e521d5 100644 --- a/ts/quill/mentions/completion.tsx +++ b/ts/quill/mentions/completion.tsx @@ -151,7 +151,7 @@ export class MentionCompletion { const range = this.quill.getSelection(); - if (range === null) { + if (range == null) { return; } diff --git a/ts/quill/signal-clipboard/index.ts b/ts/quill/signal-clipboard/index.ts index 44ba238b601..4180c33a320 100644 --- a/ts/quill/signal-clipboard/index.ts +++ b/ts/quill/signal-clipboard/index.ts @@ -9,7 +9,7 @@ import { getTextFromOps } from '../util'; const getSelectionHTML = () => { const selection = window.getSelection(); - if (selection === null) { + if (selection == null) { return ''; } @@ -49,19 +49,19 @@ export class SignalClipboard { onCaptureCopy(event: ClipboardEvent, isCut = false): void { event.preventDefault(); - if (event.clipboardData === null) { + if (event.clipboardData == null) { return; } const range = this.quill.getSelection(); - if (range === null) { + if (range == null) { return; } const contents = this.quill.getContents(range.index, range.length); - if (contents === null) { + if (contents == null) { return; } @@ -83,7 +83,7 @@ export class SignalClipboard { } onCapturePaste(event: ClipboardEvent): void { - if (event.clipboardData === null) { + if (event.clipboardData == null) { return; } @@ -92,7 +92,7 @@ export class SignalClipboard { const clipboard = this.quill.getModule('clipboard'); const selection = this.quill.getSelection(); - if (selection === null) { + if (selection == null) { return; } diff --git a/ts/scripts/symbolicate-crash-reports.ts b/ts/scripts/symbolicate-crash-reports.ts index 1058358c9fa..82f4a2eb73e 100644 --- a/ts/scripts/symbolicate-crash-reports.ts +++ b/ts/scripts/symbolicate-crash-reports.ts @@ -89,7 +89,7 @@ async function main( await wrapEventEmitterOnce(proxyServer, 'listening'); const addr = proxyServer.address(); strictAssert( - typeof addr === 'object' && addr !== null, + typeof addr === 'object' && addr != null, 'Address has to be an object' ); diff --git a/ts/services/storage.ts b/ts/services/storage.ts index a0a706e69cc..dc687c7a168 100644 --- a/ts/services/storage.ts +++ b/ts/services/storage.ts @@ -1640,10 +1640,7 @@ async function sync( return undefined; } - strictAssert( - manifest.version !== undefined && manifest.version !== null, - 'Manifest without version' - ); + strictAssert(manifest.version != null, 'Manifest without version'); const version = manifest.version?.toNumber() ?? 0; log.info( diff --git a/ts/services/storageRecordOps.ts b/ts/services/storageRecordOps.ts index bfd961e401a..5f51be00570 100644 --- a/ts/services/storageRecordOps.ts +++ b/ts/services/storageRecordOps.ts @@ -540,6 +540,7 @@ function doRecordsConflict( // false, empty string, or 0 for these records we do not count them as // conflicting. if ( + // eslint-disable-next-line eqeqeq remoteValue === null && (localValue === false || localValue === '' || diff --git a/ts/sql/cleanDataForIpc.ts b/ts/sql/cleanDataForIpc.ts index 18a992f9d3c..44174abf878 100644 --- a/ts/sql/cleanDataForIpc.ts +++ b/ts/sql/cleanDataForIpc.ts @@ -65,6 +65,7 @@ function cleanDataInner( // functions but don't mark them as cleaned. return undefined; case 'object': { + // eslint-disable-next-line eqeqeq if (data === null) { return null; } @@ -73,7 +74,7 @@ function cleanDataInner( const result: CleanedArray = []; data.forEach((item, index) => { const indexPath = `${path}.${index}`; - if (item === undefined || item === null) { + if (item == null) { pathsChanged.push(indexPath); } else { result.push(cleanDataInner(item, indexPath, pathsChanged)); diff --git a/ts/test-both/util/getStreamWithTimeout_test.ts b/ts/test-both/util/getStreamWithTimeout_test.ts index 05afc421a2f..3a79c33e2cb 100644 --- a/ts/test-both/util/getStreamWithTimeout_test.ts +++ b/ts/test-both/util/getStreamWithTimeout_test.ts @@ -18,7 +18,7 @@ describe('getStreamWithTimeout', () => { stream: Readable, chunk: string | null ): Promise => { - const promise = once(stream, chunk === null ? 'end' : 'data'); + const promise = once(stream, chunk == null ? 'end' : 'data'); stream.push(chunk); return promise; }; diff --git a/ts/test-electron/linkPreviews/linkPreviewFetch_test.ts b/ts/test-electron/linkPreviews/linkPreviewFetch_test.ts index 8681f94071e..786f0655eea 100644 --- a/ts/test-electron/linkPreviews/linkPreviewFetch_test.ts +++ b/ts/test-electron/linkPreviews/linkPreviewFetch_test.ts @@ -76,7 +76,7 @@ describe('link preview fetching', () => { const headersObj = new Headers(); Object.entries({ 'Content-Type': 'text/html; charset=utf-8', - 'Content-Length': bodyLength === null ? null : String(bodyLength), + 'Content-Length': bodyLength == null ? null : String(bodyLength), ...headers, }).forEach(([headerName, headerValue]) => { if (headerValue) { diff --git a/ts/textsecure/EventTarget.ts b/ts/textsecure/EventTarget.ts index 7a1c1074554..003e98d5bd9 100644 --- a/ts/textsecure/EventTarget.ts +++ b/ts/textsecure/EventTarget.ts @@ -20,7 +20,7 @@ export default class EventTarget { if (!(ev instanceof Event)) { throw new Error('Expects an event'); } - if (this.listeners === null || typeof this.listeners !== 'object') { + if (this.listeners == null || typeof this.listeners !== 'object') { this.listeners = {}; } const listeners = this.listeners[ev.type]; @@ -44,7 +44,7 @@ export default class EventTarget { if (typeof callback !== 'function') { throw new Error('Second argument expects a function'); } - if (this.listeners === null || typeof this.listeners !== 'object') { + if (this.listeners == null || typeof this.listeners !== 'object') { this.listeners = {}; } let listeners = this.listeners[eventName]; @@ -62,7 +62,7 @@ export default class EventTarget { if (typeof callback !== 'function') { throw new Error('Second argument expects a function'); } - if (this.listeners === null || typeof this.listeners !== 'object') { + if (this.listeners == null || typeof this.listeners !== 'object') { this.listeners = {}; } const listeners = this.listeners[eventName]; diff --git a/ts/textsecure/Helpers.ts b/ts/textsecure/Helpers.ts index e7337e9f738..914c4c875b3 100644 --- a/ts/textsecure/Helpers.ts +++ b/ts/textsecure/Helpers.ts @@ -56,7 +56,7 @@ function ensureStringed(thing: any): any { return res; } - if (thing === null) { + if (thing == null) { return null; } throw new Error(`unsure of how to jsonify object of type ${typeof thing}`); diff --git a/ts/textsecure/MessageReceiver.ts b/ts/textsecure/MessageReceiver.ts index 299044f4166..57cae95ac2e 100644 --- a/ts/textsecure/MessageReceiver.ts +++ b/ts/textsecure/MessageReceiver.ts @@ -755,7 +755,7 @@ export default class MessageReceiver id: item.id, receivedAtCounter: item.receivedAtCounter ?? item.timestamp, receivedAtDate: - item.receivedAtCounter === null ? Date.now() : item.timestamp, + item.receivedAtCounter == null ? Date.now() : item.timestamp, messageAgeSec: item.messageAgeSec || 0, // Proto.Envelope fields diff --git a/ts/textsecure/SendMessage.ts b/ts/textsecure/SendMessage.ts index 37e9ea8f0b8..2361aedcb28 100644 --- a/ts/textsecure/SendMessage.ts +++ b/ts/textsecure/SendMessage.ts @@ -293,7 +293,7 @@ class Message { throw new Error('Invalid timestamp'); } - if (this.expireTimer !== undefined && this.expireTimer !== null) { + if (this.expireTimer != null) { if (typeof this.expireTimer !== 'number' || !(this.expireTimer >= 0)) { throw new Error('Invalid expireTimer'); } @@ -311,8 +311,8 @@ class Message { } if (this.isEndSession()) { if ( - this.body !== null || - this.group !== null || + this.body != null || + this.group != null || this.attachments.length !== 0 ) { throw new Error('Invalid end session message'); @@ -674,7 +674,7 @@ export default class MessageSender { > ): Promise { assert( - typeof attachment === 'object' && attachment !== null, + typeof attachment === 'object' && attachment != null, 'Got null attachment in `makeAttachmentPointer`' ); diff --git a/ts/textsecure/processDataMessage.ts b/ts/textsecure/processDataMessage.ts index 226b7b48c4b..c9c206cebbd 100644 --- a/ts/textsecure/processDataMessage.ts +++ b/ts/textsecure/processDataMessage.ts @@ -76,10 +76,7 @@ function processGroupContext( } strictAssert(group.id, 'group context without id'); - strictAssert( - group.type !== undefined && group.type !== null, - 'group context without type' - ); + strictAssert(group.type != null, 'group context without type'); const masterKey = deriveMasterKeyFromGroupV1(group.id); const data = deriveGroupFields(masterKey); diff --git a/ts/types/Address.ts b/ts/types/Address.ts index ed0ffa9fc01..82e4f2cb6dc 100644 --- a/ts/types/Address.ts +++ b/ts/types/Address.ts @@ -19,7 +19,7 @@ export class Address { public static parse(value: string): Address { const match = value.match(ADDRESS_REGEXP); - strictAssert(match !== null, `Invalid Address: ${value}`); + strictAssert(match != null, `Invalid Address: ${value}`); const [whole, uuid, deviceId] = match; strictAssert(whole === value, 'Integrity check'); return Address.create(uuid, parseInt(deviceId, 10)); diff --git a/ts/types/QualifiedAddress.ts b/ts/types/QualifiedAddress.ts index 66159661113..2ef33389e67 100644 --- a/ts/types/QualifiedAddress.ts +++ b/ts/types/QualifiedAddress.ts @@ -39,7 +39,7 @@ export class QualifiedAddress { public static parse(value: string): QualifiedAddress { const match = value.match(QUALIFIED_ADDRESS_REGEXP); - strictAssert(match !== null, `Invalid QualifiedAddress: ${value}`); + strictAssert(match != null, `Invalid QualifiedAddress: ${value}`); const [whole, ourUuid, uuid, deviceId] = match; strictAssert(whole === value, 'Integrity check'); diff --git a/ts/types/Stickers.ts b/ts/types/Stickers.ts index 092d638b151..0f609afb04b 100644 --- a/ts/types/Stickers.ts +++ b/ts/types/Stickers.ts @@ -319,7 +319,7 @@ async function downloadSticker( { ephemeral }: { ephemeral?: boolean } = {} ): Promise> { const { id, emoji } = proto; - strictAssert(id !== undefined && id !== null, "Sticker id can't be null"); + strictAssert(id != null, "Sticker id can't be null"); const { messaging } = window.textsecure; if (!messaging) { diff --git a/ts/util/dropNull.ts b/ts/util/dropNull.ts index 7f9f85f2082..b96b5bb39eb 100644 --- a/ts/util/dropNull.ts +++ b/ts/util/dropNull.ts @@ -8,6 +8,7 @@ export type NullToUndefined = Extract extends never export function dropNull( value: NonNullable | null | undefined ): T | undefined { + // eslint-disable-next-line eqeqeq if (value === null) { return undefined; } @@ -22,7 +23,7 @@ export function shallowDropNull( [Property in keyof O]: NullToUndefined; } | undefined { - if (value === null || value === undefined) { + if (value == null) { return undefined; } diff --git a/ts/util/isNotNil.ts b/ts/util/isNotNil.ts index c60598407bc..0600ef5775b 100644 --- a/ts/util/isNotNil.ts +++ b/ts/util/isNotNil.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-only export function isNotNil(value: T | null | undefined): value is T { - if (value === null || value === undefined) { + if (value == null) { return false; } return true; diff --git a/ts/util/isRecord.ts b/ts/util/isRecord.ts index 7e1e2b71a83..7dd76ded9d1 100644 --- a/ts/util/isRecord.ts +++ b/ts/util/isRecord.ts @@ -2,4 +2,4 @@ // SPDX-License-Identifier: AGPL-3.0-only export const isRecord = (value: unknown): value is Record => - typeof value === 'object' && !Array.isArray(value) && value !== null; + typeof value === 'object' && !Array.isArray(value) && value != null; diff --git a/ts/util/iterables.ts b/ts/util/iterables.ts index e50b53d73af..6179b58b5f8 100644 --- a/ts/util/iterables.ts +++ b/ts/util/iterables.ts @@ -7,7 +7,7 @@ import { getOwn } from './getOwn'; export function isIterable(value: unknown): value is Iterable { return ( - (typeof value === 'object' && value !== null && Symbol.iterator in value) || + (typeof value === 'object' && value != null && Symbol.iterator in value) || typeof value === 'string' ); } diff --git a/ts/util/memoizeByRoot.ts b/ts/util/memoizeByRoot.ts index dc182e50b06..e2d3290d6da 100644 --- a/ts/util/memoizeByRoot.ts +++ b/ts/util/memoizeByRoot.ts @@ -27,7 +27,7 @@ export function memoizeByRoot( const wrap = (root: unknown, ...rest: Array): unknown => { strictAssert( - typeof root === 'object' && root !== null, + typeof root === 'object' && root != null, 'Root is not object' ); diff --git a/ts/util/sessionTranslation.ts b/ts/util/sessionTranslation.ts index ef37acce18f..322631dd10d 100644 --- a/ts/util/sessionTranslation.ts +++ b/ts/util/sessionTranslation.ts @@ -336,7 +336,7 @@ function binaryToUint8Array( length: number ): Uint8Array { const target = get(object, path); - if (target === null || target === undefined) { + if (target == null) { throw new Error(`binaryToUint8Array: Falsey path ${path}`); } @@ -357,7 +357,7 @@ function binaryToUint8Array( // eslint-disable-next-line @typescript-eslint/no-explicit-any function getInteger(object: any, path: string): number { const target = get(object, path); - if (target === null || target === undefined) { + if (target == null) { throw new Error(`getInteger: Falsey path ${path}`); }