From e39aac7d6487c9a516930f1a74896fd8524aa007 Mon Sep 17 00:00:00 2001 From: kris liu Date: Tue, 22 Nov 2022 11:12:00 +0800 Subject: [PATCH] feat: resolve eslint console --- apps/storefront/src/components/B3InfiniteScroll.tsx | 1 + apps/storefront/src/components/filter/B3FilterPicker.tsx | 8 ++++---- apps/storefront/src/components/form/B3ControlPicker.tsx | 6 +++--- apps/storefront/src/components/layout/B3Logo.tsx | 6 +++--- apps/storefront/src/components/layout/B3Mainheader.tsx | 2 -- apps/storefront/src/components/layout/B3Nav.tsx | 4 ++-- apps/storefront/src/components/layout/B3RenderRouter.tsx | 4 ++-- apps/storefront/src/pages/dashboard/Dashboard.tsx | 4 ++-- apps/storefront/src/pages/login/ForgotPassword.tsx | 1 - apps/storefront/src/pages/login/Login.tsx | 1 - apps/storefront/src/pages/login/config.ts | 1 - .../storefront/src/pages/order/components/OrderStatus.tsx | 6 +++--- apps/storefront/src/pages/order/config.ts | 6 +++--- .../src/pages/orderDetail/components/OrderDialog.tsx | 5 +++-- apps/storefront/src/pages/registered/RegisterComplete.tsx | 1 - apps/storefront/src/pages/registered/Registered.tsx | 3 --- .../storefront/src/pages/registered/RegisteredBCToB2B.tsx | 4 ---- apps/storefront/src/pages/seleRep/SeleRep.tsx | 6 +++--- apps/storefront/src/shared/service/bc/api/login.ts | 2 +- apps/storefront/src/shared/service/request/fetch.ts | 2 +- apps/storefront/src/utils/loginInfo.ts | 2 +- packages/eslint-config-b3/index.js | 1 + 22 files changed, 33 insertions(+), 43 deletions(-) diff --git a/apps/storefront/src/components/B3InfiniteScroll.tsx b/apps/storefront/src/components/B3InfiniteScroll.tsx index 1cf043432..ed05340e4 100644 --- a/apps/storefront/src/components/B3InfiniteScroll.tsx +++ b/apps/storefront/src/components/B3InfiniteScroll.tsx @@ -40,6 +40,7 @@ export const B3InfiniteScroll = (props: InfiniteScrollProps) => { const handleLoadMore = () => { if (!isLoading) { + console.log(allCount) onPaginationChange({ offset: offset + first, first, diff --git a/apps/storefront/src/components/filter/B3FilterPicker.tsx b/apps/storefront/src/components/filter/B3FilterPicker.tsx index aafd075e4..d12d96f37 100644 --- a/apps/storefront/src/components/filter/B3FilterPicker.tsx +++ b/apps/storefront/src/components/filter/B3FilterPicker.tsx @@ -9,9 +9,9 @@ import { Box, } from '@mui/material' -import { - useMobile, -} from '@/hooks' +// import { +// useMobile, +// } from '@/hooks' import { distanceDay, @@ -53,7 +53,7 @@ const B3FilterPickers = ({ pickerKey: endPickerKey = 'end', } = endPicker - const [isMobile] = useMobile() + // const [isMobile] = useMobile() const [startValue, setStartValue] = useState(startDateDefaultValue) const [endValue, setEndValue] = useState(endDateDefaultValue) diff --git a/apps/storefront/src/components/form/B3ControlPicker.tsx b/apps/storefront/src/components/form/B3ControlPicker.tsx index 66fffcad9..27f90d5d0 100644 --- a/apps/storefront/src/components/form/B3ControlPicker.tsx +++ b/apps/storefront/src/components/form/B3ControlPicker.tsx @@ -1,9 +1,9 @@ import { TextField, } from '@mui/material' -import { - useState, -} from 'react' +// import { +// useState, +// } from 'react' import { Controller, } from 'react-hook-form' diff --git a/apps/storefront/src/components/layout/B3Logo.tsx b/apps/storefront/src/components/layout/B3Logo.tsx index 015c36792..e602d8c1f 100644 --- a/apps/storefront/src/components/layout/B3Logo.tsx +++ b/apps/storefront/src/components/layout/B3Logo.tsx @@ -1,9 +1,9 @@ import { useContext, } from 'react' -import { - styled, -} from '@mui/material/styles' +// import { +// styled, +// } from '@mui/material/styles' import { Box, diff --git a/apps/storefront/src/components/layout/B3Mainheader.tsx b/apps/storefront/src/components/layout/B3Mainheader.tsx index ae750a160..8fdf7cec8 100644 --- a/apps/storefront/src/components/layout/B3Mainheader.tsx +++ b/apps/storefront/src/components/layout/B3Mainheader.tsx @@ -1,6 +1,4 @@ import { - useState, - useEffect, useContext, } from 'react' diff --git a/apps/storefront/src/components/layout/B3Nav.tsx b/apps/storefront/src/components/layout/B3Nav.tsx index 1180cabce..3f8f28789 100644 --- a/apps/storefront/src/components/layout/B3Nav.tsx +++ b/apps/storefront/src/components/layout/B3Nav.tsx @@ -48,8 +48,8 @@ export const B3Nav = ({ const { state: { isB2BUser, - isAgenting, - role, + // isAgenting, + // role, }, } = useContext(GlobaledContext) diff --git a/apps/storefront/src/components/layout/B3RenderRouter.tsx b/apps/storefront/src/components/layout/B3RenderRouter.tsx index 2d8be52c3..2e3e0d1cc 100644 --- a/apps/storefront/src/components/layout/B3RenderRouter.tsx +++ b/apps/storefront/src/components/layout/B3RenderRouter.tsx @@ -59,8 +59,8 @@ export const B3RenderRouter = (props: B3RenderRouterProps) => { const { state: { isB2BUser, - isAgenting, - role, + // isAgenting, + // role, }, } = useContext(GlobaledContext) diff --git a/apps/storefront/src/pages/dashboard/Dashboard.tsx b/apps/storefront/src/pages/dashboard/Dashboard.tsx index e38a4bbe4..979f09b21 100644 --- a/apps/storefront/src/pages/dashboard/Dashboard.tsx +++ b/apps/storefront/src/pages/dashboard/Dashboard.tsx @@ -20,14 +20,14 @@ import { import { B3SStorage, - storeHash, + // storeHash, } from '@/utils' const Dashboard = () => { const { state: { isB2BUser, - isAgenting, + // isAgenting, role, customerId, B3UserId, diff --git a/apps/storefront/src/pages/login/ForgotPassword.tsx b/apps/storefront/src/pages/login/ForgotPassword.tsx index 642e82e30..dfe56e6a6 100644 --- a/apps/storefront/src/pages/login/ForgotPassword.tsx +++ b/apps/storefront/src/pages/login/ForgotPassword.tsx @@ -79,7 +79,6 @@ const ForgotPassword = (props: ForgotPasswordProps) => { setLoading(false) navigate('/login?loginFlag=2') } catch (e) { - // eslint-disable-next-line no-console console.log(e) } } diff --git a/apps/storefront/src/pages/login/Login.tsx b/apps/storefront/src/pages/login/Login.tsx index 7e484ac70..1f11f11c2 100644 --- a/apps/storefront/src/pages/login/Login.tsx +++ b/apps/storefront/src/pages/login/Login.tsx @@ -180,7 +180,6 @@ export default function Login(props:RegisteredProps) { setLogo(registerLogo) setLoading(false) } catch (e) { - // eslint-disable-next-line no-console console.log(e) } } diff --git a/apps/storefront/src/pages/login/config.ts b/apps/storefront/src/pages/login/config.ts index 5e3fe619c..4e2c5c6ae 100644 --- a/apps/storefront/src/pages/login/config.ts +++ b/apps/storefront/src/pages/login/config.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ import { B3Lang, } from '@b3/lang' diff --git a/apps/storefront/src/pages/order/components/OrderStatus.tsx b/apps/storefront/src/pages/order/components/OrderStatus.tsx index 3c8dbfcbd..ed34da18a 100644 --- a/apps/storefront/src/pages/order/components/OrderStatus.tsx +++ b/apps/storefront/src/pages/order/components/OrderStatus.tsx @@ -1,6 +1,6 @@ -import { - ReactNode, -} from 'react' +// import { +// ReactNode, +// } from 'react' import { B3Tag, diff --git a/apps/storefront/src/pages/order/config.ts b/apps/storefront/src/pages/order/config.ts index 1afb6a6c6..546403c9e 100644 --- a/apps/storefront/src/pages/order/config.ts +++ b/apps/storefront/src/pages/order/config.ts @@ -2,9 +2,9 @@ import { distanceDay, } from '@/utils' -import { - orderStatusCode, -} from './shared/getOrderStatus' +// import { +// orderStatusCode, +// } from './shared/getOrderStatus' export interface FilterSearchProps { [key: string]: string | number diff --git a/apps/storefront/src/pages/orderDetail/components/OrderDialog.tsx b/apps/storefront/src/pages/orderDetail/components/OrderDialog.tsx index 1bbb23df5..ec833fbd3 100644 --- a/apps/storefront/src/pages/orderDetail/components/OrderDialog.tsx +++ b/apps/storefront/src/pages/orderDetail/components/OrderDialog.tsx @@ -35,7 +35,7 @@ import { OrderCurrency, } from '../../../types' -interface OrderDialogProps { +interface OrderDialogProps { open: boolean, setOpen: (open: boolean) => void, products?: OrderProductItem[], @@ -45,7 +45,7 @@ interface OrderDialogProps { currencyInfo: OrderCurrency, } -export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({ +export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({ open, products = [], type, @@ -150,6 +150,7 @@ export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({ diff --git a/apps/storefront/src/pages/registered/RegisterComplete.tsx b/apps/storefront/src/pages/registered/RegisterComplete.tsx index 58d414274..fb096a2ef 100644 --- a/apps/storefront/src/pages/registered/RegisterComplete.tsx +++ b/apps/storefront/src/pages/registered/RegisterComplete.tsx @@ -296,7 +296,6 @@ export default function RegisterComplete(props: RegisterCompleteProps) { return fileList } catch (error) { - // eslint-disable-next-line no-console console.log(error) throw error } diff --git a/apps/storefront/src/pages/registered/Registered.tsx b/apps/storefront/src/pages/registered/Registered.tsx index b8a2621e6..e4d8308c9 100644 --- a/apps/storefront/src/pages/registered/Registered.tsx +++ b/apps/storefront/src/pages/registered/Registered.tsx @@ -183,7 +183,6 @@ export default function Registered(props: RegisteredProps) { } setLogo(registerLogo) } catch (e) { - // eslint-disable-next-line no-console console.log(e) } } @@ -261,7 +260,6 @@ export default function Registered(props: RegisteredProps) { await loginCheckout(data) window.location.reload() } catch (error) { - // eslint-disable-next-line no-console console.log(error) } } else { @@ -286,7 +284,6 @@ export default function Registered(props: RegisteredProps) { } clearRegisterInfo() } catch (error) { - // eslint-disable-next-line no-console console.log(error) } } diff --git a/apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx b/apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx index 61c985b59..fa9ed667a 100644 --- a/apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx +++ b/apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx @@ -204,7 +204,6 @@ export default function RegisteredBCToB2B(props: RegisteredProps) { } setLogo(registerLogo) } catch (e) { - // eslint-disable-next-line no-console console.error(e) } } @@ -290,7 +289,6 @@ export default function RegisteredBCToB2B(props: RegisteredProps) { return fileList } catch (error) { - // eslint-disable-next-line no-console console.log(error) throw error } @@ -394,7 +392,6 @@ export default function RegisteredBCToB2B(props: RegisteredProps) { setErrorMessage('') return true } catch (error) { - // eslint-disable-next-line no-console console.log(error) throw error } @@ -444,7 +441,6 @@ export default function RegisteredBCToB2B(props: RegisteredProps) { } } } catch (err: any) { - // eslint-disable-next-line no-console console.log(err) setErrorMessage(err?.message || err) } finally { diff --git a/apps/storefront/src/pages/seleRep/SeleRep.tsx b/apps/storefront/src/pages/seleRep/SeleRep.tsx index 3c5ae5668..c772db5d1 100644 --- a/apps/storefront/src/pages/seleRep/SeleRep.tsx +++ b/apps/storefront/src/pages/seleRep/SeleRep.tsx @@ -16,14 +16,14 @@ import { import { B3SStorage, - storeHash, + // storeHash, } from '@/utils' const SeleRep = () => { const { state: { - isB2BUser, - isAgenting, + // isB2BUser, + // isAgenting, role, customerId, }, diff --git a/apps/storefront/src/shared/service/bc/api/login.ts b/apps/storefront/src/shared/service/bc/api/login.ts index b26708624..6b42a8449 100644 --- a/apps/storefront/src/shared/service/bc/api/login.ts +++ b/apps/storefront/src/shared/service/bc/api/login.ts @@ -10,4 +10,4 @@ import { export const getBCForgotPassword = (data: CustomFieldItems): CustomFieldItems => B3Request.post(`${bcBaseUrl}/login.php?action=send_password_email`, RequestType.BCRest, data) -export const getBcCurrentJWT = (data: CustomFieldItems): CustomFieldItems => B3Request.get(`${bcBaseUrl}/customer/current.jwt`, RequestType.BCRest, data) +export const getBcCurrentJWT = (data: CustomFieldItems) => B3Request.get(`${bcBaseUrl}/customer/current.jwt`, RequestType.BCRest, data) diff --git a/apps/storefront/src/shared/service/request/fetch.ts b/apps/storefront/src/shared/service/request/fetch.ts index 9686b89f3..b04fc8825 100644 --- a/apps/storefront/src/shared/service/request/fetch.ts +++ b/apps/storefront/src/shared/service/request/fetch.ts @@ -8,7 +8,7 @@ import { const originFetch = window.fetch -function b3Fetch(path: string, init: any, type?: string) { +function b3Fetch(path: string, init: any, type?: string) { return new Promise((resolve, reject) => { originFetch(path, init).then((res: Response) => (path.includes('current.jwt') ? res.text() : res.json())).then(async (res) => { if (res?.code === 500) { diff --git a/apps/storefront/src/utils/loginInfo.ts b/apps/storefront/src/utils/loginInfo.ts index e7d395e43..8961f6e0b 100644 --- a/apps/storefront/src/utils/loginInfo.ts +++ b/apps/storefront/src/utils/loginInfo.ts @@ -155,7 +155,7 @@ const getCurrentJwtAndB2BToken = async (userType: number) => { if (userType === 3) { const data = await getB2BToken(res) if (data) { - const B3B2BToken: string = (data as B2BToken).authorization.result.token + const B3B2BToken = (data as B2BToken).authorization.result.token B3SStorage.set('B3B2BToken', B3B2BToken) } } diff --git a/packages/eslint-config-b3/index.js b/packages/eslint-config-b3/index.js index 528e8c144..c29220219 100644 --- a/packages/eslint-config-b3/index.js +++ b/packages/eslint-config-b3/index.js @@ -6,6 +6,7 @@ module.exports = { 'no-shadow': 0, 'no-param-reassign': 0, 'no-underscore-dangle': 0, + 'no-console': 'off', semi: ['error', 'never'], quotes: ['error', 'single'], 'max-len': [