Skip to content

Commit 7fc7ace

Browse files
authored
chore: turn on no-unsafe-optional-chaining rule again (#527)
Turned on `no-unsafe-optional-chaining` eslint rule again off-ed by #526
1 parent 26bb405 commit 7fc7ace

File tree

17 files changed

+37
-33
lines changed

17 files changed

+37
-33
lines changed

.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
"no-bitwise": "off",
7272
"no-restricted-syntax": "off",
7373
"no-prototype-builtins": "off",
74-
"no-unsafe-optional-chaining": "off",
7574
"import/no-unresolved": "off",
7675
"import/no-extraneous-dependencies": "off",
7776
"import/no-useless-path-segments": "off",

src/hooks/VoicePlayer/useVoicePlayer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ export const useVoicePlayer = ({
7070
play: playVoicePlayer,
7171
pause: pauseVoicePlayer,
7272
stop: stopVoicePlayer,
73-
playbackTime: currentAudioUnit?.playbackTime * 1000,
74-
duration: currentAudioUnit?.duration * 1000,
73+
playbackTime: currentAudioUnit.playbackTime * 1000,
74+
duration: currentAudioUnit.duration * 1000,
7575
// the unit of playbackTime and duration should be millisecond
76-
playingStatus: currentAudioUnit?.playingStatus,
76+
playingStatus: currentAudioUnit.playingStatus,
7777
});
7878
};

src/modules/Channel/components/Message/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ const Message = ({
5454
}: MessageUIProps): React.ReactElement => {
5555
const { dateLocale } = useLocalization();
5656
const globalStore = useSendbirdStateContext();
57+
5758
const {
5859
userId,
5960
isOnline,
6061
isMentionEnabled,
6162
userMention,
62-
} = globalStore?.config;
63+
} = globalStore.config;
6364
const maxUserMentionCount = userMention?.maxMentionCount || MAX_USER_MENTION_COUNT;
6465
const maxUserSuggestionCount = userMention?.maxSuggestionCount || MAX_USER_SUGGESTION_COUNT;
6566

src/modules/Channel/components/MessageInput/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const MessageInputWrapper = (
5050
isMentionEnabled,
5151
userMention,
5252
isVoiceMessageEnabled,
53-
} = globalStore?.config;
53+
} = globalStore.config;
5454
const maxUserMentionCount = userMention?.maxMentionCount || 10;
5555
const maxUserSuggestionCount = userMention?.maxSuggestionCount || 15;
5656

src/modules/Channel/components/MessageList/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const MessageList: React.FC<MessageListProps> = ({
100100
setAnimatedMessageId?.(null);
101101
setHighLightedMessageId?.(null);
102102
if (scrollRef?.current?.scrollTop > -1) {
103-
scrollRef.current.scrollTop = scrollRef?.current?.scrollHeight - scrollRef?.current?.offsetHeight;
103+
scrollRef.current.scrollTop = (scrollRef?.current?.scrollHeight ?? 0) - (scrollRef?.current?.offsetHeight ?? 0);
104104
}
105105
};
106106

@@ -181,7 +181,7 @@ const MessageList: React.FC<MessageListProps> = ({
181181
time={unreadSince}
182182
onClick={() => {
183183
if (scrollRef?.current?.scrollTop) {
184-
scrollRef.current.scrollTop = scrollRef?.current?.scrollHeight - scrollRef?.current?.offsetHeight;
184+
scrollRef.current.scrollTop = (scrollRef?.current?.scrollHeight ?? 0) - (scrollRef?.current?.offsetHeight ?? 0);
185185
}
186186
if (!disableMarkAsRead) {
187187
markAsReadScheduler?.push(currentGroupChannel);

src/modules/Channel/components/SuggestedMentionList/SuggestedUserMentionItem.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ function SuggestedUserMentionItem(props: SuggestedUserMentionItemProps): JSX.Ele
2828
onMouseMove,
2929
renderUserMentionItem,
3030
} = props;
31-
const scrollRef = useRef(null);
31+
const scrollRef = useRef<HTMLDivElement>(null);
3232
const { stringSet = {} } = useContext(LocalizationContext);
3333
useEffect(() => {
34-
if (isFocused
35-
&& (parentScrollRef?.current?.scrollTop >= scrollRef?.current?.offsetTop
36-
|| parentScrollRef?.current?.scrollTop + parentScrollRef?.current?.clientHeight <= scrollRef?.current?.offsetTop
34+
if (isFocused && parentScrollRef?.current != null && scrollRef?.current != null
35+
&& (parentScrollRef.current.scrollTop >= scrollRef.current.offsetTop
36+
|| parentScrollRef.current.scrollTop + parentScrollRef.current.clientHeight <= scrollRef.current.offsetTop
3737
)) {
38-
scrollRef?.current?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
38+
scrollRef.current.scrollIntoView({ block: 'nearest', inline: 'nearest' });
3939
}
4040
}, [isFocused]);
4141
const customMentionItem = useMemo(() => {

src/modules/Channel/context/ChannelProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type {
1717
} from '@sendbird/chat/message';
1818
import type { SendbirdError, User } from '@sendbird/chat';
1919

20-
import { ReplyType, RenderUserProfileProps } from '../../../types';
20+
import { ReplyType, RenderUserProfileProps, Nullable } from '../../../types';
2121
import { UserProfileProvider } from '../../../lib/UserProfileContext';
2222
import useSendbirdStateContext from '../../../hooks/useSendbirdStateContext';
2323
import { CoreMessageType } from '../../../utils';
@@ -105,7 +105,7 @@ interface MessageStoreInterface {
105105
initialized: boolean;
106106
unreadSince: string;
107107
isInvalid: boolean;
108-
currentGroupChannel: GroupChannel;
108+
currentGroupChannel: Nullable<GroupChannel>;
109109
hasMorePrev: boolean;
110110
oldestMessageTimeStamp: number;
111111
hasMoreNext: boolean;

src/modules/ChannelList/components/ChannelListHeader/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const ChannelListHeader: React.FC<ChannelListHeaderInterface> = ({
2222
onEdit,
2323
allowProfileEdit,
2424
}: ChannelListHeaderInterface) => {
25-
const { stores, config } = useSendbirdStateContext?.();
26-
const { user } = stores?.userStore;
25+
const { stores, config } = useSendbirdStateContext();
26+
const { user } = stores.userStore;
2727
const { logger } = config;
2828

2929
const { stringSet } = useContext(LocalizationContext);

src/modules/OpenChannelSettings/components/EditDetailsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const EditDetails = (props: Props): ReactElement => {
2727
onCancel,
2828
} = props;
2929
const globalState = useSendbirdStateContext();
30-
const { logger, theme, pubSub } = globalState?.config;
30+
const { logger, theme, pubSub } = globalState.config;
3131
const {
3232
channel,
3333
onBeforeUpdateChannel,

src/modules/Thread/components/ParentMessageInfo/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export default function ParentMessageInfo({
4242
isOnline,
4343
userMention,
4444
} = config;
45-
const userId = stores?.userStore?.user?.userId;
46-
const { dateLocale } = useLocalization?.();
45+
const userId = stores.userStore.user?.userId ?? '';
46+
const { dateLocale } = useLocalization();
4747
const {
4848
currentChannel,
4949
parentMessage,

0 commit comments

Comments
 (0)