Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 21 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,21 @@ module.exports = {
'sonarjs',
'jest'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
ignorePatterns: [
"node_modules",
"*.config.js",
"docs",
"cli",
"android",
"ios",
"lint-staged.config.js",
"i18next-syntax-validation.js",
".eslintrc.js"
],
rules: {
'import/no-duplicates': 'error',
'@typescript-eslint/no-explicit-any': 'error',
Expand All @@ -42,7 +54,7 @@ module.exports = {
'react/require-default-props': 'off', // Allow non-defined react props as undefined
'@typescript-eslint/comma-dangle': 'off', // Avoid conflict rule between Eslint and Prettier
'@typescript-eslint/consistent-type-imports': [
'warn',
'error',
{
prefer: 'type-imports',
fixStyle: 'inline-type-imports',
Expand Down Expand Up @@ -81,7 +93,14 @@ module.exports = {
'object-shorthand': 'error',
'arrow-body-style': ["error", "as-needed"],
'no-console': ['error', {allow: ['error']}],
'guard-for-in': 'error'
'guard-for-in': 'error',
'@typescript-eslint/no-magic-numbers': ["error",
{ ignoreArrayIndexes: true,
ignoreEnums: true,
ignore: [-1, 0, 1]
}
],
'@typescript-eslint/prefer-nullish-coalescing': "error"
},
overrides: [
// Configuration for translations files (i18next)
Expand Down
2 changes: 1 addition & 1 deletion cli/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const execShellCommand = (cmd) => {
console.warn(error);
reject(error);
}
resolve(stdout ? stdout : stderr);
resolve(stdout || stderr);
});
});
};
Expand Down
3 changes: 2 additions & 1 deletion src/app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ export default function TabLayout() {
await SplashScreen.hideAsync();
}, []);
useEffect(() => {
const TIMEOUT = 1000
if (status !== 'idle') {
setTimeout(() => {
hideSplash();
}, 1000);
}, TIMEOUT);
}
}, [hideSplash, status]);

Expand Down
6 changes: 4 additions & 2 deletions src/app/feed/add-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { z } from 'zod';
import { useAddPost } from '@/api';
import { Button, ControlledInput, showErrorMessage, View } from '@/ui';

const TITLE_MIN_CHARS = 10
const BODY_MIN_CHARS = 120
const schema = z.object({
title: z.string().min(10),
body: z.string().min(120),
title: z.string().min(TITLE_MIN_CHARS),
body: z.string().min(BODY_MIN_CHARS),
});

type FormType = z.infer<typeof schema>;
Expand Down
3 changes: 2 additions & 1 deletion src/components/login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import z from 'zod';

import { Button, ControlledInput, Text, View } from '@/ui';

const MIN_CHARS = 6
const schema = z.object({
name: z.string().optional(),
email: z
Expand All @@ -17,7 +18,7 @@ const schema = z.object({
.string({
required_error: 'Password is required',
})
.min(6, 'Password must be at least 6 characters'),
.min(MIN_CHARS, 'Password must be at least 6 characters'),
});

export type FormType = z.infer<typeof schema>;
Expand Down
2 changes: 1 addition & 1 deletion src/core/i18n/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export * from './utils';

i18n.use(initReactI18next).init({
resources,
lng: getLanguage() || locale, // TODO: if you are not supporting multiple languages or languages with multiple directions you can set the default value to `en`
lng: getLanguage() ?? locale, // TODO: if you are not supporting multiple languages or languages with multiple directions you can set the default value to `en`
fallbackLng: 'en',
compatibilityJSON: 'v3', // By default React Native projects does not support Intl

Expand Down
8 changes: 5 additions & 3 deletions src/ui/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const Modal = forwardRef(
ref={modal.ref}
index={0}
snapPoints={snapPoints}
backdropComponent={props.backdropComponent || renderBackdrop}
backdropComponent={props.backdropComponent ?? renderBackdrop}
handleComponent={renderHandleComponent}
/>
);
Expand All @@ -121,11 +121,13 @@ const AnimatedPressable = Animated.createAnimatedComponent(Pressable);

const CustomBackdrop = ({ style }: BottomSheetBackdropProps) => {
const { close } = useBottomSheet();
const FADE_IN_DURATION = 50
const FADE_OUT_DURATION = 20
return (
<AnimatedPressable
onPress={() => close()}
entering={FadeIn.duration(50)}
exiting={FadeOut.duration(20)}
entering={FadeIn.duration(FADE_IN_DURATION)}
exiting={FadeOut.duration(FADE_OUT_DURATION)}
style={[style, { backgroundColor: 'rgba(0, 0, 0, 0.4)' }]}
/>
);
Expand Down
7 changes: 4 additions & 3 deletions src/ui/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { useColorScheme } from 'nativewind';
import { forwardRef, memo, useCallback, useMemo } from 'react';
import type { FieldValues } from 'react-hook-form';
import { useController } from 'react-hook-form';
import { Platform, TouchableOpacity, View } from 'react-native';
import { Pressable, type PressableProps } from 'react-native';
import { Platform, Pressable, type PressableProps,TouchableOpacity, View } from 'react-native';
import type { SvgProps } from 'react-native-svg';
import Svg, { Path } from 'react-native-svg';
import { tv } from 'tailwind-variants';
Expand Down Expand Up @@ -72,7 +71,9 @@ function keyExtractor(item: OptionType) {

export const Options = forwardRef<BottomSheetModal, OptionsProps>(
({ options, onSelect, value, testID }, ref) => {
const height = options.length * 70 + 100;
const HEIGHT_MARGIN = 100
const OPTION_HEIGHT = 70
const height = options.length * OPTION_HEIGHT + HEIGHT_MARGIN;
const snapPoints = useMemo(() => [height], [height]);
const { colorScheme } = useColorScheme();
const isDark = colorScheme === 'dark';
Expand Down
4 changes: 2 additions & 2 deletions src/ui/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export const Text = ({
[className]
);

const nStyle = useMemo(
const nStyle: TextStyle = useMemo(
() =>
StyleSheet.flatten([
{
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
},
style,
]) as TextStyle,
]),
[style]
);
return (
Expand Down
2 changes: 1 addition & 1 deletion src/ui/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const showError = (error: AxiosError) => {
const description = extractError(error?.response?.data).trimEnd();

showMessage({
message: 'Error',
description,
message: 'Error',
type: 'danger',
duration: 4000,
icon: 'danger',
Expand Down