Skip to content

Commit f4560d5

Browse files
committed
feat: add typedoc validation and refactor component to include PropsWithChildren
1 parent 03ee074 commit f4560d5

11 files changed

+103
-95
lines changed

lefthook.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ pre-commit:
33
commands:
44
lint:
55
glob: "*.{js,ts,jsx,tsx}"
6-
run: npx eslint {staged_files}
6+
run: yarn eslint {staged_files}
77
types:
88
glob: "*.{js,ts,jsx,tsx}"
9-
run: npx tsc
9+
run: yarn typecheck
10+
typedoc-validation:
11+
run: yarn docs --validation
1012
# version-check:
1113
# glob: "package.json"
1214
# run: node scripts/checkVersionAndUpdateBuildInfo.js
1315
commit-msg:
1416
parallel: true
1517
commands:
1618
commitlint:
17-
run: npx commitlint --edit
19+
run: yarn commitlint --edit

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
"test:coverage": "jest --coverage",
4141
"typecheck": "tsc",
4242
"lint": "eslint \"**/*.{js,ts,tsx}\"",
43+
"eslint": "eslint",
44+
"commitlint": "commitlint",
4345
"docs": "typedoc",
4446
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
4547
"prebuild": "yarn add_build_info",

src/inbox/components/HeaderBackButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { PropsWithChildren, ReactElement } from 'react';
12
import {
23
Image,
34
PixelRatio,
@@ -73,7 +74,7 @@ export const HeaderBackButton = ({
7374
height: PixelRatio.getPixelSizeForLayoutSize(ICON_SIZE),
7475
},
7576
...props
76-
}: HeaderBackButtonProps) => {
77+
}: PropsWithChildren<HeaderBackButtonProps>): ReactElement => {
7778
return (
7879
<TouchableWithoutFeedback {...props}>
7980
<View style={styles.returnButton}>

src/inbox/components/IterableInbox.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { useIsFocused } from '@react-navigation/native';
2-
import { useEffect, useState } from 'react';
2+
import {
3+
useEffect,
4+
useState,
5+
type PropsWithChildren,
6+
type ReactElement,
7+
} from 'react';
38
import {
49
Animated,
510
NativeEventEmitter,
@@ -32,7 +37,6 @@ import {
3237
type IterableInboxMessageListProps,
3338
} from './IterableInboxMessageList';
3439

35-
3640
const RNEventEmitter = new NativeEventEmitter(RNIterableAPI);
3741

3842
const DEFAULT_HEADLINE_HEIGHT = 60;
@@ -186,7 +190,9 @@ export interface IterableInboxProps
186190
* )
187191
* ```
188192
*/
189-
export const IterableInbox = (params: IterableInboxProps) => {
193+
export const IterableInbox = (
194+
params: PropsWithChildren<IterableInboxProps>
195+
): ReactElement => {
190196
const {
191197
returnToInboxTrigger = true,
192198
messageListItemLayout = () => null,

src/inbox/components/IterableInboxEmptyState.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { StyleSheet, Text, View } from 'react-native';
2+
import type { PropsWithChildren, ReactElement } from 'react';
23

34
import { type IterableInboxCustomizations } from '../types';
45
import { ITERABLE_INBOX_COLORS } from '../constants';
@@ -26,7 +27,9 @@ export interface IterableInboxEmptyStateProps {
2627
/**
2728
* A functional component that renders an empty state for the inbox when there are no messages.
2829
*/
29-
export const IterableInboxEmptyState = (params: IterableInboxEmptyStateProps) => {
30+
export const IterableInboxEmptyState = (
31+
params: PropsWithChildren<IterableInboxEmptyStateProps>
32+
): ReactElement => {
3033
const {
3134
customizations,
3235
tabBarHeight,

src/inbox/components/IterableInboxMessageCell.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRef } from 'react';
1+
import { useRef, type PropsWithChildren, type ReactElement } from 'react';
22
import {
33
Animated,
44
Image,
@@ -280,7 +280,9 @@ export interface IterableInboxMessageCellProps {
280280
/**
281281
* Component which renders a single message cell in the Iterable inbox.
282282
*/
283-
export const IterableInboxMessageCell = (params: IterableInboxMessageCellProps) => {
283+
export const IterableInboxMessageCell = (
284+
params: PropsWithChildren<IterableInboxMessageCellProps>
285+
): ReactElement => {
284286
const {
285287
index,
286288
last,

src/inbox/components/IterableInboxMessageDisplay.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { useEffect, useState } from 'react';
1+
import {
2+
useEffect,
3+
useState,
4+
type PropsWithChildren,
5+
type ReactElement,
6+
} from 'react';
27
import {
38
Linking,
49
Platform,
@@ -73,7 +78,7 @@ export const IterableInboxMessageDisplay = ({
7378
deleteRow,
7479
contentWidth,
7580
isPortrait,
76-
}: IterableInboxMessageDisplayProps) => {
81+
}: PropsWithChildren<IterableInboxMessageDisplayProps>): ReactElement => {
7782
const messageTitle = rowViewModel.inAppMessage.inboxMetadata?.title;
7883
const [inAppContent, setInAppContent] =
7984
useState<IterableHtmlInAppContent | null>(null);
@@ -85,7 +90,7 @@ export const IterableInboxMessageDisplay = ({
8590

8691
header: {
8792
flexDirection: 'row',
88-
height: Platform.OS === 'ios' ? 44 : 56,
93+
height: Platform.OS === 'ios' ? 44 : 56,
8994
justifyContent: 'center',
9095
width: '100%',
9196
},

src/inbox/components/IterableInboxMessageList.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { useCallback, useRef, useState } from 'react';
1+
import {
2+
useCallback,
3+
useRef,
4+
useState,
5+
type PropsWithChildren,
6+
type ReactElement,
7+
} from 'react';
28
import { type ViewabilityConfig, type ViewToken, FlatList } from 'react-native';
39

410
import { IterableInAppMessage } from '../../inApp';
@@ -65,7 +71,7 @@ export const IterableInboxMessageList = ({
6571
updateVisibleMessageImpressions,
6672
contentWidth,
6773
isPortrait,
68-
}: IterableInboxMessageListProps) => {
74+
}: PropsWithChildren<IterableInboxMessageListProps>): ReactElement => {
6975
const [swiping, setSwiping] = useState<boolean>(false);
7076
const flatListRef = useRef<FlatList>(null);
7177

src/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ export {
6161
export {
6262
IterableInbox,
6363
IterableInboxDataModel,
64-
IterableInboxEmptyState,
65-
IterableInboxMessageCell,
6664
type IterableInboxCustomizations,
6765
type IterableInboxEmptyStateProps,
6866
type IterableInboxImpressionRowInfo,

tsdoc.json

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
33
"tagDefinitions": [
4-
{
5-
"tagName": "@param",
6-
"syntaxKind": "block",
7-
"allowMultiple": true
8-
},
9-
{
10-
"tagName": "@returns",
11-
"syntaxKind": "block"
12-
},
13-
{
14-
"tagName": "@remarks",
15-
"syntaxKind": "block"
16-
},
17-
{
18-
"tagName": "@example",
19-
"syntaxKind": "block",
20-
"allowMultiple": true
21-
},
22-
{
23-
"tagName": "@link",
24-
"syntaxKind": "inline"
25-
},
264
{
275
"tagName": "@os",
286
"syntaxKind": "block"
@@ -35,15 +13,5 @@
3513
"tagName": "@mermaid",
3614
"syntaxKind": "block"
3715
}
38-
],
39-
"supportForTags": {
40-
"@remarks": true,
41-
"@returns": true,
42-
"@example": true,
43-
"@link": true,
44-
"@param": true,
45-
"@includeCode": true,
46-
"@mermaid": true,
47-
"@os": true
48-
}
16+
]
4917
}

0 commit comments

Comments
 (0)