tsc:allowUnreachableCode, eslint:no-unreachable, assert->assertDev

This commit is contained in:
Jamie Kyle 2022-09-15 12:17:15 -07:00 committed by GitHub
parent f627a05cf8
commit eb10aafd7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 213 additions and 176 deletions

View file

@ -20,7 +20,7 @@ import { ContactSpoofingReviewDialogPerson } from './ContactSpoofingReviewDialog
import { Button, ButtonVariant } from '../Button';
import { Intl } from '../Intl';
import { Emojify } from './Emojify';
import { assert } from '../../util/assert';
import { assertDev } from '../../util/assert';
import { missingCaseError } from '../../util/missingCaseError';
import { isInSystemContacts } from '../../util/isInSystemContacts';
@ -133,7 +133,7 @@ export const ContactSpoofingReviewDialog: FunctionComponent<
});
break;
case MessageRequestState.unblocking:
assert(
assertDev(
false,
'Got unexpected MessageRequestState.unblocking state. Clearing confiration state'
);
@ -175,11 +175,11 @@ export const ContactSpoofingReviewDialog: FunctionComponent<
switch (props.type) {
case ContactSpoofingType.DirectConversationWithSameTitle: {
const { possiblyUnsafeConversation, safeConversation } = props;
assert(
assertDev(
possiblyUnsafeConversation.type === 'direct',
'<ContactSpoofingReviewDialog> expected a direct conversation for the "possibly unsafe" conversation'
);
assert(
assertDev(
safeConversation.type === 'direct',
'<ContactSpoofingReviewDialog> expected a direct conversation for the "safe" conversation'
);

View file

@ -7,7 +7,7 @@ import React from 'react';
import type { ConversationType } from '../../state/ducks/conversations';
import type { LocalizerType, ThemeType } from '../../types/Util';
import type { PreferredBadgeSelectorType } from '../../state/selectors/badges';
import { assert } from '../../util/assert';
import { assertDev } from '../../util/assert';
import { Avatar, AvatarSize } from '../Avatar';
import { ContactName } from './ContactName';
@ -25,7 +25,7 @@ type PropsType = {
export const ContactSpoofingReviewDialogPerson: FunctionComponent<
PropsType
> = ({ children, conversation, getPreferredBadge, i18n, onClick, theme }) => {
assert(
assertDev(
conversation.type === 'direct',
'<ContactSpoofingReviewDialogPerson> expected a direct conversation'
);

View file

@ -11,7 +11,7 @@ import React, {
import classNames from 'classnames';
import { noop } from 'lodash';
import { assert } from '../../util/assert';
import { assertDev } from '../../util/assert';
import type { LocalizerType } from '../../types/Util';
import type { AttachmentType } from '../../types/Attachment';
import { isDownloaded } from '../../types/Attachment';
@ -226,7 +226,7 @@ export const MessageAudio: React.FC<Props> = (props: Props) => {
setActiveAudioID,
} = props;
assert(audio != null, 'GlobalAudioContext always provides audio');
assertDev(audio != null, 'GlobalAudioContext always provides audio');
const isActive =
activeAudioID === id && activeAudioContext === renderingContext;
@ -365,7 +365,7 @@ export const MessageAudio: React.FC<Props> = (props: Props) => {
};
const onLoadedMetadata = () => {
assert(
assertDev(
!Number.isNaN(audio.duration),
'Audio should have definite duration on `loadedmetadata` event'
);

View file

@ -13,7 +13,7 @@ import { ScrollDownButton } from './ScrollDownButton';
import type { AssertProps, LocalizerType, ThemeType } from '../../types/Util';
import type { ConversationType } from '../../state/ducks/conversations';
import type { PreferredBadgeSelectorType } from '../../state/selectors/badges';
import { assert, strictAssert } from '../../util/assert';
import { assertDev, strictAssert } from '../../util/assert';
import { missingCaseError } from '../../util/missingCaseError';
import { clearTimeoutIfNecessary } from '../../util/clearTimeoutIfNecessary';
import { WidthBreakpoint } from '../_util';
@ -522,7 +522,7 @@ export class Timeline extends React.Component<
this.intersectionObserver = new IntersectionObserver(
(entries, observer) => {
assert(
assertDev(
this.intersectionObserver === observer,
'observer.disconnect() should prevent callbacks from firing'
);
@ -630,7 +630,7 @@ export class Timeline extends React.Component<
return { scrollBottom: 0 };
case ScrollAnchor.ScrollToIndex:
if (scrollToIndex === undefined) {
assert(
assertDev(
false,
'<Timeline> got "scroll to index" scroll anchor, but no index'
);
@ -674,7 +674,7 @@ export class Timeline extends React.Component<
lastSeenIndicatorEl.scrollIntoView();
} else {
scrollToBottom(containerEl);
assert(
assertDev(
false,
'<Timeline> expected a last seen indicator but it was not found'
);
@ -942,7 +942,7 @@ export class Timeline extends React.Component<
const messageId = items[itemIndex];
if (!messageId) {
assert(
assertDev(
false,
'<Timeline> iterated through items and got an empty message ID'
);
@ -1058,7 +1058,7 @@ export class Timeline extends React.Component<
bounds
onResize={({ bounds }) => {
if (!bounds) {
assert(false, 'We should be measuring the bounds');
assertDev(false, 'We should be measuring the bounds');
return;
}
this.setState({ lastMeasuredWarningHeight: bounds.height });

View file

@ -5,7 +5,7 @@ import type { FunctionComponent, ReactNode } from 'react';
import React from 'react';
import type { LocalizerType } from '../../../../types/Util';
import { assert } from '../../../../util/assert';
import { assertDev } from '../../../../util/assert';
import { ModalHost } from '../../../ModalHost';
import { Button, ButtonVariant } from '../../../Button';
import { Spinner } from '../../../Spinner';
@ -35,7 +35,7 @@ export const ConfirmAdditionsModal: FunctionComponent<PropsType> = ({
selectedContacts,
}) => {
const firstContact = selectedContacts[0];
assert(
assertDev(
firstContact,
'Expected at least one conversation to be selected but none were picked'
);

View file

@ -10,7 +10,7 @@ import type { ConversationType } from '../../../state/ducks/conversations';
import type { PreferredBadgeSelectorType } from '../../../state/selectors/badges';
import type { SmartChooseGroupMembersModalPropsType } from '../../../state/smart/ChooseGroupMembersModal';
import type { SmartConfirmAdditionsModalPropsType } from '../../../state/smart/ConfirmAdditionsModal';
import { assert } from '../../../util/assert';
import { assertDev } from '../../../util/assert';
import { getMutedUntilText } from '../../../util/getMutedUntilText';
import type { LocalizerType, ThemeType } from '../../../types/Util';
@ -237,7 +237,7 @@ export const ConversationDetails: React.ComponentType<Props> = ({
renderConfirmAdditionsModal={renderConfirmAdditionsModal}
clearRequestError={() => {
setAddGroupMembersRequestState(oldRequestState => {
assert(
assertDev(
oldRequestState !== RequestState.Active,
'Should not be clearing an active request state'
);