Skip to content

Commit

Permalink
Add Readonly<> to props
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Sep 15, 2023
1 parent 318fd52 commit fafed2e
Show file tree
Hide file tree
Showing 25 changed files with 46 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function isUpvoteAction(voteAction: VoteAction): voteAction is UpvoteAction {
return voteAction.actionOption === 'upvote';
}

type Props = { activity: WebChatActivity };
type Props = Readonly<{ activity: WebChatActivity }>;

const OthersActivityStatus = memo(({ activity }: Props) => {
const [{ sendStatus }] = useStyleSet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Slotted from './Slotted';
import Timestamp from './Timestamp';
import useStyleSet from '../hooks/useStyleSet';

type Props = { activity: WebChatActivity };
type Props = Readonly<{ activity: WebChatActivity }>;

const SelftActivityStatus = memo(({ activity }: Props) => {
const [{ sendStatus }] = useStyleSet();
Expand Down
6 changes: 1 addition & 5 deletions packages/component/src/ActivityStatus/Slotted.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React, { Children, Fragment, memo, type PropsWithChildren } from 'react';
import classNames from 'classnames';

type Props = PropsWithChildren<{
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
className?: string;
}>;
type Props = Readonly<PropsWithChildren<{ className?: string }>>;

const Slotted = memo(({ children, className }: Props) => (
<span className={classNames('webchat__activity-status--slotted', className)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import FeedbackVoteButton from './private/VoteButton';

const { usePonyfill, usePostActivity } = hooks;

type Props = PropsWithChildren<{
voteActions: ReadonlySet<VoteAction>;
}>;
type Props = Readonly<
PropsWithChildren<{
voteActions: ReadonlySet<VoteAction>;
}>
>;

const DEBOUNCE_TIMEOUT = 500;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ import ThumbDislike16Regular from './icons/ThumbDislike16Regular';
import ThumbLike16Filled from './icons/ThumbLike16Filled';
import ThumbLike16Regular from './icons/ThumbLike16Regular';

type Props = {
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
type Props = Readonly<{
className?: string;
direction: 'down' | 'up';
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
filled?: boolean;
};
}>;

const ThumbButtonImage = memo(({ className, direction, filled = false }: Props) =>
direction === 'down' ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ import useStyleSet from '../../../../hooks/useStyleSet';

const { useLocalizer } = hooks;

type Props = {
type Props = Readonly<{
direction: 'down' | 'up';
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
onClick?: () => void;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
pressed?: boolean;
};
}>;

const ThumbButton = memo(({ direction, onClick, pressed }: Props) => {
const [{ thumbButton }] = useStyleSet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import { useRefFrom } from 'use-ref-from';
import { type VoteAction } from '../../../../types/external/OrgSchema/VoteAction';
import ThumbsButton from './ThumbButton';

type Props = {
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
type Props = Readonly<{
onClick?: (voteAction: VoteAction) => void;
pressed: boolean;
voteAction: VoteAction;
};
}>;

const FeedbackVoteButton = memo(({ onClick, pressed, voteAction }: Props) => {
const onClickRef = useRefFrom(onClick);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { memo } from 'react';

// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
type Props = { className?: string };
type Props = Readonly<{ className?: string }>;

const ThumbDislike16Filled = memo(({ className }: Props) => (
<svg className={className} fill="none" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { memo } from 'react';

// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
type Props = { className?: string };
type Props = Readonly<{ className?: string }>;

const ThumbDislike16Regular = memo(({ className }: Props) => (
<svg className={className} fill="none" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { memo } from 'react';

// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
type Props = { className?: string };
type Props = Readonly<{ className?: string }>;

const ThumbLike16Filled = memo(({ className }: Props) => (
<svg className={className} fill="none" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { memo } from 'react';

// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
type Props = { className?: string };
type Props = Readonly<{ className?: string }>;

const ThumbLike16Regular = memo(({ className }: Props) => (
<svg className={className} fill="none" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { memo } from 'react';

import { type ReplyAction } from '../../types/external/OrgSchema/ReplyAction';

type Props = { replyAction: ReplyAction };
type Props = Readonly<{ replyAction: ReplyAction }>;

const Originator = memo(({ replyAction }: Props) => {
const { description, provider } = replyAction;
Expand Down
4 changes: 2 additions & 2 deletions packages/component/src/Attachment/Text/TextAttachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import React, { type FC, memo } from 'react';
import { type WebChatAttachment } from '../private/types/WebChatAttachment';
import TextContent from './TextContent';

type Props = {
type Props = Readonly<{
activity: WebChatActivity;
attachment: WebChatAttachment & {
contentType: `text/${string}`;
};
};
}>;

const TextAttachment: FC<Props> = memo(({ activity, attachment: { content, contentType } }: Props) => (
<TextContent contentType={contentType} entities={activity.entities} text={content} />
Expand Down
6 changes: 2 additions & 4 deletions packages/component/src/Attachment/Text/TextContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import useRenderMarkdownAsHTML from '../../hooks/useRenderMarkdownAsHTML';

import { type WebChatActivity } from 'botframework-webchat-core';

type Props = {
type Props = Readonly<{
contentType?: string;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
entities?: WebChatActivity['entities'];
text: string;
};
}>;

const TextContent: FC<Props> = memo(({ contentType = 'text/plain', entities, text }: Props) => {
const supportMarkdown = !!useRenderMarkdownAsHTML();
Expand Down
4 changes: 1 addition & 3 deletions packages/component/src/Attachment/Text/private/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { memo } from 'react';

type Props = {
value: string;
};
type Props = Readonly<{ value: string }>;

const Badge = memo(({ value }: Props) => <div className="webchat__link-definitions__badge">{value}</div>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ import React, { memo, type MouseEventHandler, useCallback } from 'react';

import ItemBody from './ItemBody';

type Props = {
type Props = Readonly<{
identifier: string;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
onClick?: (url: string) => void;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
title?: string;
url: string;
};
}>;

const CitationItem = memo(({ identifier, onClick, title, url }: Props) => {
const onClickRef = useRefFrom(onClick);
Expand Down
6 changes: 2 additions & 4 deletions packages/component/src/Attachment/Text/private/ItemBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import React, { memo } from 'react';
import Badge from './Badge';
import OpenInNewWindowIcon from './OpenInNewWindowIcon';

type Props = {
type Props = Readonly<{
identifier: string;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
isExternal?: boolean;
title: string;
};
}>;

const ItemBody = memo(({ identifier, isExternal, title }: Props) => (
<div className="webchat__link-definitions__list-item-body">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import useStyleSet from '../../../hooks/useStyleSet';

const { useLocalizer } = hooks;

type Props = {
type Props = Readonly<{
markdown: string;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
onCitationClick?: (url: string) => void;
};
}>;

const REFERENCE_LIST_HEADER_IDS = {
one: 'REFERENCE_LIST_HEADER_ONE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import useStyleSet from '../../../hooks/useStyleSet';

const { useLocalizer } = hooks;

type Props = {
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
type Props = Readonly<{
entities?: WebChatActivity['entities'];
markdown: string;
};
}>;

const MarkdownTextContent = memo(({ entities, markdown }: Props) => {
const [{ renderMarkdown: renderMarkdownStyleSet, textContent: textContentStyleSet }] = useStyleSet();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import classNames from 'classnames';
import React from 'react';

// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
type Props = { className?: string };
type Props = Readonly<{ className?: string }>;

const OpenInNewWindowIcon = ({ className }: Props) => (
<svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import React, { type FC, Fragment, memo } from 'react';

import useStyleSet from '../../../hooks/useStyleSet';

type Props = {
text: string;
};
type Props = Readonly<{ text: string }>;

const PlainTextContent: FC<Props> = memo(({ text }: Props) => {
const [{ textContent: textContentStyleSet }] = useStyleSet();
Expand Down
6 changes: 2 additions & 4 deletions packages/component/src/Attachment/Text/private/URLItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import React, { memo } from 'react';

import ItemBody from './ItemBody';

type Props = {
type Props = Readonly<{
identifier: string;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
title?: string;
url: string;
};
}>;

const URLItem = memo(({ identifier, title, url }: Props) => (
<a
Expand Down
5 changes: 1 addition & 4 deletions packages/component/src/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ function styleSetToEmotionObjects(styleToEmotionObject, styleSet) {
return mapMap(styleSet, (style, key) => (key === 'options' ? style : styleToEmotionObject(style)));
}

type ComposerCoreUIProps = Readonly<{
// eslint-disable-next-line react/require-default-props
children?: ReactNode;
}>;
type ComposerCoreUIProps = Readonly<{ children?: ReactNode }>;

const ComposerCoreUI = memo(({ children }: ComposerCoreUIProps) => {
const [{ cssCustomProperties }] = useStyleSet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ type DialogInit = Exclude<Parameters<ContextType['showModal']>[1], undefined>;

type RenderFunctionAndDialogInit = Readonly<[RenderFunction, DialogInit | undefined]>;

// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
type Props = { children?: ReactNode };
type Props = Readonly<{ children?: ReactNode }>;

const ModalDialogComposer = memo(({ children }: Props) => {
const [renderFunctionAndDialogInit, setRenderFunctionAndDialogInit] = useState<
Expand Down
22 changes: 8 additions & 14 deletions packages/component/src/providers/ModalDialog/private/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ import useStyleSet from '../../../hooks/useStyleSet';

const { useLocalizer } = hooks;

type Props = PropsWithChildren<{
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
'aria-label'?: string;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
'aria-labelledby'?: string;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
className?: string;
// "defaultProps" is being deprecated.
// eslint-disable-next-line react/require-default-props
onDismiss?: () => void;
}>;
type Props = Readonly<
PropsWithChildren<{
'aria-label'?: string;
'aria-labelledby'?: string;
className?: string;
onDismiss?: () => void;
}>
>;

const ModalDialog = memo(
({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, children, className, onDismiss }: Props) => {
Expand Down

0 comments on commit fafed2e

Please sign in to comment.