From bd8a79e8984cac3d19a1d094840374e7425396b8 Mon Sep 17 00:00:00 2001 From: ajaykumar97 <38132295+ajaykumar97@users.noreply.github.com> Date: Wed, 19 Jun 2024 22:45:05 +0530 Subject: [PATCH] fix: lint issues --- template/_eslintrc.js | 11 ++++++++ template/package.json | 1 + template/src/App.tsx | 21 ++++++-------- .../TextInputAccessoryView/index.tsx | 4 +-- template/src/localization/index.tsx | 4 +-- template/src/navigation/AppNavigator.tsx | 4 +-- template/src/navigation/AuthNavigator.tsx | 8 +++--- template/src/navigation/MainNavigator.tsx | 8 +++--- .../AuthScreens/BootstrapApp/index.tsx | 10 +++---- .../src/screens/AuthScreens/Login/styles.tsx | 2 -- .../src/screens/AuthScreens/Signup/index.tsx | 13 ++++----- .../Users/components/UserCard.tsx | 4 +-- .../screens/MainAppScreens/Users/index.tsx | 28 +++++++++---------- .../screens/MainAppScreens/Users/slice.tsx | 4 +-- .../utilities/helperFunctions/validators.tsx | 4 +-- 15 files changed, 65 insertions(+), 61 deletions(-) diff --git a/template/_eslintrc.js b/template/_eslintrc.js index e474cd3..610d21b 100644 --- a/template/_eslintrc.js +++ b/template/_eslintrc.js @@ -12,4 +12,15 @@ module.exports = { env: { 'jest/globals': true, }, + settings: { + 'import/parsers': { + '@typescript-eslint/parser': ['.ts', '.tsx'], + }, + 'import/resolver': { + typescript: { + alwaysTryTypes: true, + project: './tsconfig.json', + }, + }, + }, }; diff --git a/template/package.json b/template/package.json index d42e852..bbda5f2 100644 --- a/template/package.json +++ b/template/package.json @@ -12,6 +12,7 @@ "iosTestingDebug": "react-native run-ios --scheme 'testing'", "iosDevelopmentDebug": "react-native run-ios --scheme 'development'", "lint": "eslint .", + "lint:fix": "eslint . --fix", "start": "react-native start", "test": "jest", "test:watch": "npx cross-env NODE_ENV=test jest --watchAll", diff --git a/template/src/App.tsx b/template/src/App.tsx index 7486a7c..eabc3a3 100755 --- a/template/src/App.tsx +++ b/template/src/App.tsx @@ -1,16 +1,16 @@ -import {useNetInfo} from "@react-native-community/netinfo"; +import {useNetInfo} from '@react-native-community/netinfo'; import {NavigationContainer} from '@react-navigation/native'; import React, {useEffect} from 'react'; import {I18nextProvider, useTranslation} from 'react-i18next'; -import {Alert, StatusBar} from "react-native"; -import FlashMessage from "react-native-flash-message"; +import {Alert, StatusBar} from 'react-native'; +import FlashMessage from 'react-native-flash-message'; import {Provider} from 'react-redux'; import i18next from './localization'; -import AppNavigator from "./navigation/AppNavigator"; -import store from "./store"; -import {COLORS} from "./utilities/constants"; -import {navigationRef} from "./utilities/navigationService"; +import AppNavigator from './navigation/AppNavigator'; +import store from './store'; +import {COLORS} from './utilities/constants'; +import {navigationRef} from './utilities/navigationService'; function App(): React.JSX.Element { const {isConnected} = useNetInfo(); @@ -18,12 +18,9 @@ function App(): React.JSX.Element { useEffect(() => { if (isConnected === false) { - Alert.alert( - t('noInternetConnected'), - t('checkInternetConnection'), - ); + Alert.alert(t('noInternetConnected'), t('checkInternetConnection')); } - }, [isConnected]); + }, [isConnected, t]); return ( diff --git a/template/src/commonComponents/TextInputAccessoryView/index.tsx b/template/src/commonComponents/TextInputAccessoryView/index.tsx index 501f85e..c99366a 100644 --- a/template/src/commonComponents/TextInputAccessoryView/index.tsx +++ b/template/src/commonComponents/TextInputAccessoryView/index.tsx @@ -1,11 +1,11 @@ import React from 'react'; -import {useTranslation} from "react-i18next"; +import {useTranslation} from 'react-i18next'; import { View, InputAccessoryView, Pressable, GestureResponderEvent, -} from "react-native"; +} from 'react-native'; import {COLORS, LAYOUT} from '../../utilities/constants'; import {Body2} from '../TextComponents'; diff --git a/template/src/localization/index.tsx b/template/src/localization/index.tsx index 30bbfd1..baa4834 100755 --- a/template/src/localization/index.tsx +++ b/template/src/localization/index.tsx @@ -1,5 +1,5 @@ -import i18next from "i18next"; -import {initReactI18next} from "react-i18next"; +import i18next from 'i18next'; +import {initReactI18next} from 'react-i18next'; import en from './en.json'; diff --git a/template/src/navigation/AppNavigator.tsx b/template/src/navigation/AppNavigator.tsx index 89c95ca..f99e1b2 100755 --- a/template/src/navigation/AppNavigator.tsx +++ b/template/src/navigation/AppNavigator.tsx @@ -1,8 +1,8 @@ import { CardStyleInterpolators, createStackNavigator, -} from "@react-navigation/stack"; -import React from "react"; +} from '@react-navigation/stack'; +import React from 'react'; import 'react-native-gesture-handler'; import BootstrapApp from '../screens/AuthScreens/BootstrapApp'; diff --git a/template/src/navigation/AuthNavigator.tsx b/template/src/navigation/AuthNavigator.tsx index f24cbdf..3ed6622 100755 --- a/template/src/navigation/AuthNavigator.tsx +++ b/template/src/navigation/AuthNavigator.tsx @@ -1,8 +1,8 @@ -import {createStackNavigator} from "@react-navigation/stack"; -import React from "react"; +import {createStackNavigator} from '@react-navigation/stack'; +import React from 'react'; -import ForgotPassword from "../screens/AuthScreens/ForgotPassword"; -import Login from "../screens/AuthScreens/Login"; +import ForgotPassword from '../screens/AuthScreens/ForgotPassword'; +import Login from '../screens/AuthScreens/Login'; import Signup from '../screens/AuthScreens/Signup'; import {SCREEN_NAMES} from '../utilities/constants'; diff --git a/template/src/navigation/MainNavigator.tsx b/template/src/navigation/MainNavigator.tsx index eee9850..a1d3d6e 100755 --- a/template/src/navigation/MainNavigator.tsx +++ b/template/src/navigation/MainNavigator.tsx @@ -1,8 +1,8 @@ -import {createStackNavigator} from "@react-navigation/stack"; -import React from "react"; +import {createStackNavigator} from '@react-navigation/stack'; +import React from 'react'; -import Users from "../screens/MainAppScreens/Users"; -import {SCREEN_NAMES} from "../utilities/constants"; +import Users from '../screens/MainAppScreens/Users'; +import {SCREEN_NAMES} from '../utilities/constants'; const MainStack = createStackNavigator(); diff --git a/template/src/screens/AuthScreens/BootstrapApp/index.tsx b/template/src/screens/AuthScreens/BootstrapApp/index.tsx index 18d7218..74b3b76 100755 --- a/template/src/screens/AuthScreens/BootstrapApp/index.tsx +++ b/template/src/screens/AuthScreens/BootstrapApp/index.tsx @@ -1,9 +1,9 @@ -import {hideAsync} from "expo-splash-screen"; -import React, {useEffect} from "react"; -import logger from "react-native-simple-logger"; +import {hideAsync} from 'expo-splash-screen'; +import React, {useEffect} from 'react'; +import logger from 'react-native-simple-logger'; -import {ACCESS_TOKEN, SCREEN_NAMES} from "../../../utilities/constants"; -import {getSecuredData} from "../../../utilities/helperFunctions/localStorage"; +import {ACCESS_TOKEN, SCREEN_NAMES} from '../../../utilities/constants'; +import {getSecuredData} from '../../../utilities/helperFunctions/localStorage'; import {replace} from '../../../utilities/navigationService'; interface BootStrapAppProps {} diff --git a/template/src/screens/AuthScreens/Login/styles.tsx b/template/src/screens/AuthScreens/Login/styles.tsx index da12f0d..7aa6b1d 100644 --- a/template/src/screens/AuthScreens/Login/styles.tsx +++ b/template/src/screens/AuthScreens/Login/styles.tsx @@ -1,8 +1,6 @@ import {StyleSheet} from 'react-native'; import {scale} from 'react-native-size-matters'; -import {COLORS} from '../../../utilities/constants'; - const styles = StyleSheet.create({ container: { flex: 0.35, diff --git a/template/src/screens/AuthScreens/Signup/index.tsx b/template/src/screens/AuthScreens/Signup/index.tsx index a985b2d..f9d382e 100755 --- a/template/src/screens/AuthScreens/Signup/index.tsx +++ b/template/src/screens/AuthScreens/Signup/index.tsx @@ -48,16 +48,13 @@ const Signup: React.FC = () => { } }; - const onSignupPress = useCallback( - async formData => { - setSecuredData(ACCESS_TOKEN, formData.email.trim()); + const onSignupPress = useCallback(async formData => { + setSecuredData(ACCESS_TOKEN, formData.email.trim()); - Keyboard.dismiss(); + Keyboard.dismiss(); - replace(SCREEN_NAMES.MainNavigator); - }, - [t], - ); + replace(SCREEN_NAMES.MainNavigator); + }, []); return ( diff --git a/template/src/screens/MainAppScreens/Users/components/UserCard.tsx b/template/src/screens/MainAppScreens/Users/components/UserCard.tsx index 9b36f22..45da378 100755 --- a/template/src/screens/MainAppScreens/Users/components/UserCard.tsx +++ b/template/src/screens/MainAppScreens/Users/components/UserCard.tsx @@ -2,8 +2,8 @@ import React from 'react'; import {View, StyleSheet} from 'react-native'; import {scale} from 'react-native-size-matters'; -import {Body1, Body2} from "../../../../commonComponents/TextComponents"; -import {COLORS, commonStyles} from "../../../../utilities/constants"; +import {Body1, Body2} from '../../../../commonComponents/TextComponents'; +import {COLORS, commonStyles} from '../../../../utilities/constants'; interface UserCardProps { user: { diff --git a/template/src/screens/MainAppScreens/Users/index.tsx b/template/src/screens/MainAppScreens/Users/index.tsx index c6c845d..cb9f3eb 100755 --- a/template/src/screens/MainAppScreens/Users/index.tsx +++ b/template/src/screens/MainAppScreens/Users/index.tsx @@ -1,25 +1,25 @@ import React, {useCallback, useEffect} from 'react'; -import {useTranslation} from "react-i18next"; -import {FlatList} from "react-native"; -import {useDispatch, useSelector} from "react-redux"; +import {useTranslation} from 'react-i18next'; +import {FlatList} from 'react-native'; +import {useDispatch, useSelector} from 'react-redux'; -import Button from "../../../commonComponents/Button"; -import EmptyListPlaceholder from "../../../commonComponents/EmptyListPlaceholder"; -import Header from "../../../commonComponents/Header"; -import ItemSeparatorComponent from "../../../commonComponents/ItemSeparatorComponent"; -import Loader from "../../../commonComponents/Loader"; -import Wrapper from "../../../commonComponents/Wrapper"; +import Button from '../../../commonComponents/Button'; +import EmptyListPlaceholder from '../../../commonComponents/EmptyListPlaceholder'; +import Header from '../../../commonComponents/Header'; +import ItemSeparatorComponent from '../../../commonComponents/ItemSeparatorComponent'; +import Loader from '../../../commonComponents/Loader'; +import Wrapper from '../../../commonComponents/Wrapper'; import {ACCESS_TOKEN, COLORS, SCREEN_NAMES} from '../../../utilities/constants'; import { deleteUnsecuredData, removeSecuredData, } from '../../../utilities/helperFunctions/localStorage'; -import {keyExtractor} from "../../../utilities/helperFunctions/miscellaneous"; -import {replace} from "../../../utilities/navigationService"; +import {keyExtractor} from '../../../utilities/helperFunctions/miscellaneous'; +import {replace} from '../../../utilities/navigationService'; -import UserCard from "./components/UserCard"; -import {getUsers} from "./slice"; -import styles from "./styles"; +import UserCard from './components/UserCard'; +import {getUsers} from './slice'; +import styles from './styles'; type useSelectorType = { users: { diff --git a/template/src/screens/MainAppScreens/Users/slice.tsx b/template/src/screens/MainAppScreens/Users/slice.tsx index 23c0ee2..2fb30d8 100644 --- a/template/src/screens/MainAppScreens/Users/slice.tsx +++ b/template/src/screens/MainAppScreens/Users/slice.tsx @@ -1,7 +1,7 @@ import {createAsyncThunk, createSlice} from '@reduxjs/toolkit'; -import {URLS} from "../../../utilities/constants"; -import {request} from "../../../utilities/request"; +import {URLS} from '../../../utilities/constants'; +import {request} from '../../../utilities/request'; export const getUsers = createAsyncThunk('users/getUsers', async () => { try { diff --git a/template/src/utilities/helperFunctions/validators.tsx b/template/src/utilities/helperFunctions/validators.tsx index c936d7e..f431b4c 100644 --- a/template/src/utilities/helperFunctions/validators.tsx +++ b/template/src/utilities/helperFunctions/validators.tsx @@ -43,6 +43,6 @@ export const signupFormSchema = yup.object().shape({ .required(t('enterValidEmail')), password: yup .string() - .required(t("pleaseEnterPassword")) - .matches(REGEX.password, t("passwordCanContainOnly")), + .required(t('pleaseEnterPassword')) + .matches(REGEX.password, t('passwordCanContainOnly')), });