Add type-alias-readonlydeep rule and make ducks mostly immutable

This commit is contained in:
Jamie Kyle 2023-01-13 12:07:26 -08:00 committed by GitHub
parent 11ce3c3d59
commit c58a723f45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 1164 additions and 871 deletions

View file

@ -9,6 +9,7 @@ import { createPortal } from 'react-dom';
import { noop } from 'lodash';
import { useSpring, animated, to } from '@react-spring/web';
import type { ReadonlyDeep } from 'type-fest';
import type {
ConversationType,
SaveAttachmentActionCreatorType,
@ -29,7 +30,7 @@ export type PropsType = {
getConversation?: (id: string) => ConversationType;
i18n: LocalizerType;
isViewOnce?: boolean;
media: ReadonlyArray<MediaItemType>;
media: ReadonlyArray<ReadonlyDeep<MediaItemType>>;
saveAttachment: SaveAttachmentActionCreatorType;
selectedIndex?: number;
toggleForwardMessageModal: (messageId: string) => unknown;
@ -682,7 +683,7 @@ function LightboxHeader({
}: {
getConversation: (id: string) => ConversationType;
i18n: LocalizerType;
message: MediaItemMessageType;
message: ReadonlyDeep<MediaItemMessageType>;
}): JSX.Element {
const conversation = getConversation(message.conversationId);

View file

@ -7,6 +7,7 @@ import type { ReactChild, ReactNode, RefObject } from 'react';
import React from 'react';
import Measure from 'react-measure';
import type { ReadonlyDeep } from 'type-fest';
import { ScrollDownButton } from './ScrollDownButton';
import type { LocalizerType, ThemeType } from '../../types/Util';
@ -49,7 +50,7 @@ const MIN_ROW_HEIGHT = 18;
const SCROLL_DOWN_BUTTON_THRESHOLD = 8;
const LOAD_NEWER_THRESHOLD = 5;
export type WarningType =
export type WarningType = ReadonlyDeep<
| {
type: ContactSpoofingType.DirectConversationWithSameTitle;
safeConversation: ConversationType;
@ -58,7 +59,8 @@ export type WarningType =
type: ContactSpoofingType.MultipleGroupMembersWithSameTitle;
acknowledgedGroupNameCollisions: GroupNameCollisionsWithIdsByTitle;
groupNameCollisions: GroupNameCollisionsWithIdsByTitle;
};
}
>;
export type ContactSpoofingReviewPropType =
| {
@ -139,7 +141,7 @@ export type PropsActionsType = {
// From Backbone
acknowledgeGroupMemberNameCollisions: (
conversationId: string,
groupNameCollisions: Readonly<GroupNameCollisionsWithIdsByTitle>
groupNameCollisions: ReadonlyDeep<GroupNameCollisionsWithIdsByTitle>
) => void;
clearInvitedUuidsForNewlyCreatedGroup: () => void;
clearSelectedMessage: () => unknown;

View file

@ -3,6 +3,7 @@
import React from 'react';
import type { ReadonlyDeep } from 'type-fest';
import type { LocalizerType } from '../../../types/Util';
import type { MediaItemType } from '../../../types/MediaItem';
@ -19,7 +20,7 @@ export type Props = {
showAllMedia: () => void;
showLightboxWithMedia: (
selectedAttachmentPath: string | undefined,
media: ReadonlyArray<MediaItemType>
media: ReadonlyArray<ReadonlyDeep<MediaItemType>>
) => void;
};

View file

@ -4,6 +4,7 @@
import React from 'react';
import classNames from 'classnames';
import type { ReadonlyDeep } from 'type-fest';
import {
isImageTypeSupported,
isVideoTypeSupported,
@ -13,7 +14,7 @@ import type { MediaItemType } from '../../../types/MediaItem';
import * as log from '../../../logging/log';
export type Props = {
mediaItem: MediaItemType;
mediaItem: ReadonlyDeep<MediaItemType>;
onClick?: () => void;
i18n: LocalizerType;
};