Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2ce56ae
Add ESLint configuration file and remove inline config from package.json
lposen Nov 7, 2024
1d73a8d
Enhance ESLint configuration for TypeScript support: add TypeScript p…
lposen Nov 7, 2024
b6797da
Enhance ESLint configuration: add jest plugin and update lint command…
lposen Nov 7, 2024
0bd3f0c
Fixed autofixabe lint issues
lposen Nov 7, 2024
46c5710
Fixed linting issues for IterableInboxMessageCell
lposen Nov 7, 2024
bc32769
eslint fixes
lposen Nov 7, 2024
6f87314
Add IterableEdgeInsetDetails type and update related classes for bett…
lposen Nov 7, 2024
61d143d
Refactor IterableConfig and IterableInAppMessage for improved type sa…
lposen Nov 7, 2024
888ee75
Enhance type safety by refining types in IterableCommerceItem, Iterab…
lposen Nov 7, 2024
a8ac6a1
Refactor fromDict methods in IterableAction and IterableActionContext…
lposen Nov 7, 2024
7b0104a
Refactor Iterable class methods to enhance type safety; replace 'any'…
lposen Nov 7, 2024
ad2cf2d
Allow `requires` for package.json and in tests
lposen Nov 7, 2024
9cbfc82
Refactor ESLint configuration for improved TypeScript support; update…
lposen Nov 8, 2024
4b20c6e
Merge branch '2.0.0-alpha/MOB-9995-reorganize-source-code' into 2.0.0…
lposen Nov 14, 2024
6ebc953
Merge branch '2.0.0-alpha/MOB-9995-reorganize-source-code' into 2.0.0…
lposen Nov 15, 2024
d76e662
Refactor ESLint configuration and improve type definitions. Excluded…
lposen Nov 16, 2024
5d96ec5
Refactor ESLint configuration and move Prettier settings to a separat…
lposen Nov 16, 2024
cc96da8
Update ESLint configuration and ignore settings; remove node_modules …
lposen Nov 16, 2024
d029374
Enhance ESLint configuration and improve component styles for better …
lposen Nov 16, 2024
c556a9f
Refactor IterableInboxMessageDisplay to use color constants for impro…
lposen Nov 16, 2024
835786f
Refactor IterableInboxMessageCell to use color constants for improved…
lposen Nov 16, 2024
52a6422
Refactor IterableInboxEmptyState to use color constants for improved …
lposen Nov 16, 2024
e2ebcf1
Refactor IterableInbox to use color constants and improve style consi…
lposen Nov 16, 2024
241c5f6
Refactor Commerce and Login components to use shadow constants for im…
lposen Nov 16, 2024
15add53
Update ESLint configuration to use the full plugin path for better cl…
lposen Nov 16, 2024
575cfbf
Merge branch '2.0.0-alpha/MOB-9995-reorganize-source-code' into 2.0.0…
lposen Nov 25, 2024
989dead
Merge branch '2.0.0-alpha/MOB-9995-reorganize-source-code' into 2.0.0…
lposen Nov 26, 2024
e5ade24
Merge branch '2.0.0-alpha/MOB-9995-reorganize-source-code' into 2.0.0…
lposen Nov 27, 2024
89ac82b
Merge branch '2.0.0-alpha/master' into 2.0.0-alpha/MOB-10141-make-lin…
evantk91 Dec 7, 2024
cbc3418
Merge branch '2.0.0-alpha/master' into 2.0.0-alpha/MOB-10141-make-lin…
lposen Dec 9, 2024
f2f5122
refactor: added constants instead of values as per PR review
lposen Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
integration-testing/
lib/
node_modules/
50 changes: 50 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
root: true,
extends: [
'@react-native',
'plugin:react/recommended',
'plugin:react-native/all',
'prettier', // Disables ESLint rules that conflict with Prettier
],
rules: {
'react/react-in-jsx-scope': 'off',
},
overrides: [
{
files: ['*.ts', '*.tsx'],
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
// We need more verbose typing to enable the below rule, but we should
// do this in the future
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
rules: {
'@typescript-eslint/no-var-requires': [
'error',
{ allow: ['/package\\.json$'] },
],
'@typescript-eslint/no-require-imports': [
'error',
{ allow: ['/package\\.json$'] },
],
},
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is done here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making ts rules in eslint stricter

{
files: ['**/*.test.{js,ts,tsx}', '**/__mocks__/*', '**/__tests__/*'],
plugins: ['jest'],
env: {
jest: true,
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-require-imports': 'off',
},
},
],
};
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"quoteProps": "consistent",
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
2 changes: 1 addition & 1 deletion example/src/components/App/App.utils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Icon from 'react-native-vector-icons/Ionicons';

export const getIcon = (name: string, props: Record<string, any>) => (
export const getIcon = (name: string, props: Record<string, unknown>) => (
<Icon name={name} {...props} />
);
11 changes: 6 additions & 5 deletions example/src/components/App/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ export const Main = () => {
useEffect(() => {
if (loginInProgress) return;
if (isLoggedIn) {
Iterable.inAppManager.getMessages().then((messages) => {
setUnreadMessageCount(messages.length);
});
Iterable.inAppManager
.getMessages()
.then((messages) => setUnreadMessageCount(messages.length))
.catch((error) => console.error('Failed to get messages:', error));
} else {
// Reset unread message count when user logs out
setUnreadMessageCount(0);
Expand All @@ -42,9 +43,9 @@ export const Main = () => {
<>
<Tab.Navigator
screenOptions={({ route }) => {
const iconName = routeIcon[route.name as keyof typeof routeIcon];
const iconName = routeIcon[route.name];
return {
tabBarIcon: (props) => getIcon(iconName as string, props),
tabBarIcon: (props) => getIcon(iconName, props),
tabBarActiveTintColor: colors.brandPurple,
tabBarInactiveTintColor: colors.textSecondary,
headerShown: false,
Expand Down
7 changes: 6 additions & 1 deletion example/src/components/Commerce/Commerce.constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { ImageProps } from 'react-native';

export type CommerceItem = {
id: string;
name: string;
icon: any;
icon: ImageProps['source'];
subtitle: string;
price: number;
};
Expand All @@ -10,20 +12,23 @@ export const items: CommerceItem[] = [
{
id: 'black',
name: 'Black Coffee',
// eslint-disable-next-line @typescript-eslint/no-require-imports
icon: require('./img/black-coffee.png'),
subtitle: 'Maximize health benefits',
price: 2.53,
},
{
id: 'cappuccino',
name: 'Cappuccino',
// eslint-disable-next-line @typescript-eslint/no-require-imports
icon: require('./img/cappuccino.png'),
subtitle: 'Tasty and creamy',
price: 3.56,
},
{
id: 'mocha',
name: 'Mocha',
// eslint-disable-next-line @typescript-eslint/no-require-imports
icon: require('./img/mocha.png'),
subtitle: 'Indulge yourself',
price: 4.98,
Expand Down
71 changes: 36 additions & 35 deletions example/src/components/Commerce/Commerce.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,63 @@ import {
container,
title,
subtitle,
shadows,
} from '../../constants';

const styles = StyleSheet.create({
container,
title: { ...title, textAlign: 'center' },
subtitle: { ...subtitle, textAlign: 'center' },
button: { ...button, marginTop: 10, paddingVertical: 5, width: 100 },
buttonText,
cardContainer: {
backgroundColor: colors?.white,
borderWidth: 1,
padding: 15,
borderColor: colors?.grey5,
shadowColor: 'rgba(0,0,0, .2)',
shadowOffset: { height: 0, width: 0 },
shadowOpacity: 1,
shadowRadius: 1,
elevation: 10, // Required for Android
width: '100%',
borderWidth: 1,
elevation: shadows.card.elevation, // Required for Android
height: 150,
marginBottom: 10,
},
infoContainer: {
display: 'flex',
flexDirection: 'row',
gap: 10,
alignItems: 'center',
},
imageContainer: {
width: 120,
height: 100,
flex: 0,
},
textContainer: {
paddingTop: 10,
flex: 1,
marginLeft: 10,
padding: 15,
shadowColor: shadows.card.color,
shadowOffset: shadows.card.offset,
shadowOpacity: shadows.card.opacity,
shadowRadius: shadows.card.radius,
width: '100%',
},
cardImage: {
height: '100%',
width: '100%',
resizeMode: 'contain',
width: '100%',
},
cardSubtitle: {
color: colors.textSecondary,
fontSize: 14,
},
cardTitle: {
fontSize: 18,
fontWeight: 'bold',
},
cardSubtitle: {
fontSize: 14,
color: colors.textSecondary,
container,
imageContainer: {
flex: 0,
height: 100,
width: 120,
},
infoContainer: {
alignItems: 'center',
display: 'flex',
flexDirection: 'row',
gap: 10,
},
price: {
marginVertical: 5,
fontWeight: 'bold',
color: colors.salmon50,
fontWeight: 'bold',
marginVertical: 5,
},
button: { ...button, width: 100, marginTop: 10, paddingVertical: 5 },
buttonText,
subtitle: { ...subtitle, textAlign: 'center' },
textContainer: {
flex: 1,
marginLeft: 10,
paddingTop: 10,
},
title: { ...title, textAlign: 'center' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is alphabetical

});

export default styles;
3 changes: 2 additions & 1 deletion example/src/components/Commerce/Commerce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export const Commerce = () => {
<View style={styles.container}>
<Text style={styles.title}>Commerce</Text>
<Text style={styles.subtitle}>
Purchase will be tracked when "Buy" is clicked. See logs for output.
Purchase will be tracked when &quot;Buy&quot; is clicked. See logs for
output.
</Text>
{items.map((item) => (
<View key={item.id} style={styles.cardContainer}>
Expand Down
26 changes: 14 additions & 12 deletions example/src/components/Login/Login.styles.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { StyleSheet, type ViewStyle } from 'react-native';

import {
appName,
buttonBlock,
buttonDisabled,
buttonText,
buttonTextDisabled,
colors,
container,
input,
label,
Expand All @@ -19,22 +21,22 @@ const setButton = (buttonToSet: ViewStyle = {}) => ({
});

export const styles = StyleSheet.create({
loginScreenContainer: {
...container,
backgroundColor: 'white',
},
loadingContainer: {
flex: 1,
justifyContent: 'center',
},
formContainer: { marginTop: 24 },
appName,
title,
subtitle,
input: { ...input, marginBottom: 15 },
button: setButton(),
buttonDisabled: setButton(buttonDisabled),
buttonText,
buttonTextDisabled,
formContainer: { marginTop: 24 },
input: { ...input, marginBottom: 15 },
label,
loadingContainer: {
flex: 1,
justifyContent: 'center',
},
loginScreenContainer: {
...container,
backgroundColor: colors.white,
},
subtitle,
title,
});
6 changes: 1 addition & 5 deletions example/src/components/User/User.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ const text: TextStyle = {
};

const styles = StyleSheet.create({
container,
appName: appNameSmall,
button,
buttonText,
secondaryButton: {
...button,
backgroundColor: 'gray',
},
container,
text,
});

Expand Down
2 changes: 1 addition & 1 deletion example/src/components/User/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const User = () => {
<View style={styles.container}>
<Text style={styles.appName}>Welcome Iterator</Text>
<Text style={styles.text}>Logged in as {loggedInAs}</Text>
<TouchableOpacity style={styles.secondaryButton} onPress={logout}>
<TouchableOpacity style={styles.button} onPress={logout}>
<Text style={styles.buttonText}>Logout</Text>
</TouchableOpacity>
</View>
Expand Down
1 change: 1 addition & 0 deletions example/src/constants/styles/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './colors';
export * from './containers';
export * from './formElements';
export * from './shadows';
export * from './typography';
9 changes: 9 additions & 0 deletions example/src/constants/styles/shadows.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const shadows = {
card: {
color: 'rgba(0,0,0, .2)',
offset: { height: 0, width: 0 },
opacity: 1,
radius: 1,
elevation: 10, // Required for Android
},
};
3 changes: 2 additions & 1 deletion example/src/hooks/useIterableApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const IterableAppProvider: FunctionComponent<
for (const route of routeNames) {
if (url.includes(route.toLowerCase())) {
// TODO: Figure out typing for this
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
navigation.navigate(route);
return true;
Expand Down Expand Up @@ -158,7 +159,7 @@ export const IterableAppProvider: FunctionComponent<
}

// Initialize app
return Iterable.initialize(key as string, config)
return Iterable.initialize(key, config)
.then((isSuccessful) => {
setIsInitialized(isSuccessful);

Expand Down
6 changes: 1 addition & 5 deletions example/src/types/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@ export type MainScreenProps<T extends keyof MainScreenParamList> =
export type RootStackScreenProps<T extends keyof RootStackParamList> =
StackScreenProps<RootStackParamList, T>;

declare global {
namespace ReactNavigation {
interface RootParamList extends RootStackParamList {}
}
}
export type { RootStackParamList as RootParamList };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whats going on here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the rule I was fixing: https://typescript-eslint.io/rules/no-namespace/

Loading