Skip to content

Commit

Permalink
feat(BUN-2089): no-console eslint rule clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed Mar 22, 2024
1 parent ea890ce commit ab43d1f
Show file tree
Hide file tree
Showing 37 changed files with 105 additions and 188 deletions.
13 changes: 1 addition & 12 deletions apps/storefront/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,7 @@
}
},
{
"files": [
"src/*.ts",
"src/components/*.tsx",
"src/components/**/*.tsx",
"src/hooks/dom/*.ts",
"src/pages/**/*.{ts,tsx}",
"src/shared/*.ts",
"src/shared/**/*.ts",
"src/utils/*.{ts,tsx}",
"src/utils/b3Product/*.ts",
"src/utils/b3Product/shared/*.ts"
],
"files": ["src/utils/b3Logger.ts"],
"rules": {
"no-console": 0
}
Expand Down
6 changes: 4 additions & 2 deletions apps/storefront/src/buyerPortal.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { b2bLogger } from '@/utils'

const { MODE: mode, VITE_LOCAL_GRAPHQL_ORIGIN } = import.meta.env

interface ScriptNodeChildren extends HTMLScriptElement {
Expand Down Expand Up @@ -114,7 +116,7 @@ function init() {
insertScript(storefrontScript.script)
})
.catch((error) => {
console.error('There was a problem with the fetch operation:', error)
b2bLogger.error('There was a problem with the fetch operation:', error)
})
}

Expand All @@ -124,7 +126,7 @@ function init() {

await getScriptContent(origin)
} catch (error) {
console.error('Interface error')
b2bLogger.error('Interface error')
}
}

Expand Down
39 changes: 0 additions & 39 deletions apps/storefront/src/components/B3Socket.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions apps/storefront/src/components/upload/B3Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
BcProductsBulkUploadCSV,
guestProductsBulkUploadCSV,
} from '@/shared/service/b2b'
import { getDefaultCurrencyInfo } from '@/utils'
import { b2bLogger, getDefaultCurrencyInfo } from '@/utils'

import B3Dialog from '../B3Dialog'

Expand Down Expand Up @@ -170,7 +170,7 @@ export default function B3Upload(props: B3UploadProps) {
}
} catch (e) {
setStep('init')
console.error(e)
b2bLogger.error(e)
}
}

Expand Down
5 changes: 3 additions & 2 deletions apps/storefront/src/hooks/dom/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getCart } from '@/shared/service/bc/graphql/cart'
import {
addQuoteDraftProduce,
addQuoteDraftProducts,
b2bLogger,
B3LStorage,
B3SStorage,
calculateProductsPrice,
Expand Down Expand Up @@ -270,7 +271,7 @@ const addProductsFromCartToQuote = (

await addProductsToDraftQuote(cartProductsList, setOpenPage, entityId)
} catch (e) {
console.log(e)
b2bLogger.error(e)
} finally {
removeLoadding()
}
Expand Down Expand Up @@ -374,7 +375,7 @@ const addProductFromProductPageToQuote = (setOpenPage: DispatchProps) => {
})
}
} catch (e) {
console.log(e)
b2bLogger.error(e)
} finally {
removeLoadding()
}
Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/src/pages/accountSetting/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Fields, ParamProps } from '@/types/accountSetting'
import { validatorRules } from '@/utils'
import { b2bLogger, validatorRules } from '@/utils'
import { bcBaseUrl } from '@/utils/basicConfig'

import { deCodeField } from '../registered/config'
Expand Down Expand Up @@ -92,7 +92,7 @@ function sendEmail(data: any, extraFields: any) {
resolve(!isFlag)
})
.catch((error) => {
console.error('Error:', error)
b2bLogger.error('Error:', error)
reject()
})
})
Expand Down
6 changes: 3 additions & 3 deletions apps/storefront/src/pages/address/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
getB2BCountries,
getBCCustomerAddress,
} from '@/shared/service/b2b'
import { snackbar } from '@/utils'
import { b2bLogger, snackbar } from '@/utils'

import B3Filter from '../../components/filter/B3Filter'
import {
Expand Down Expand Up @@ -89,7 +89,7 @@ function Address() {
)
setAddressFields(addressFields || [])
} catch (err) {
console.log(err)
b2bLogger.error(err)
} finally {
setIsRequestLoading(false)
}
Expand Down Expand Up @@ -191,7 +191,7 @@ function Address() {

setEditPermission(editPermission)
} catch (error) {
console.error(error)
b2bLogger.error(error)
}
}
}
Expand Down
37 changes: 4 additions & 33 deletions apps/storefront/src/pages/address/shared/getAddressFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
getB2BAccountFormFields,
getB2BAddressExtraFields,
} from '@/shared/service/b2b'
import { b2bLogger } from '@/utils'

import {
AccountFormFieldsItems,
Expand Down Expand Up @@ -42,36 +43,6 @@ interface ExtraFieldsProp extends RegisterFieldsItems {
xs: number
}

// interface B2bExtraFields {
// name: string;
// label: string;
// required: boolean;
// fieldType: string,
// xs: number,
// default: string | number | null,
// variant: string,
// size?: string,
// bcLabel?: string,
// custom?: boolean,
// fieldId?: string | null,
// groupId?: number,
// groupName?: string,
// id?: string,
// max?: string | number | null,
// maxLength?: string | number | null,
// min?: string | number | null,
// minlength?: string | number | null,
// rows?: string | number | null,
// type?: string | null,
// visible?: boolean,
// replaceOptions?: {
// [k: string]: string
// },
// options?: {
// [k: string]: any
// }
// }

const convertExtraFields = (
extraFields: B2bExtraFieldsProps[]
): [] | ExtraFieldsProp[] => {
Expand Down Expand Up @@ -117,7 +88,7 @@ const getBcAddressFields = async () => {

return bcAddressFields
} catch (e) {
console.log(e)
b2bLogger.error(e)
}
return undefined
}
Expand All @@ -129,7 +100,7 @@ const getB2BAddressFields = async () => {
const addressFields = [...b2bAddressFields, ...b2bExtraFields]
return addressFields
} catch (e) {
console.log(e)
b2bLogger.error(e)
}
return []
}
Expand Down Expand Up @@ -165,7 +136,7 @@ export const getAddressFields = async (

return allAddressFields
} catch (e) {
console.log(e)
b2bLogger.error(e)
}
return []
}
7 changes: 4 additions & 3 deletions apps/storefront/src/pages/invoice/Invoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from '@/shared/service/b2b'
import { InvoiceList, InvoiceListNode } from '@/types/invoice'
import {
b2bLogger,
B3SStorage,
currencyFormat,
currencyFormatInfo,
Expand Down Expand Up @@ -179,7 +180,7 @@ function Invoice() {
setOverdueAmount(+overDueBalance.toFixed(decimalPlaces))
}
} catch (err) {
console.error(err)
b2bLogger.error(err)
} finally {
setIsRequestLoading(false)
}
Expand Down Expand Up @@ -263,7 +264,7 @@ function Invoice() {

window.open(pdfUrl, '_blank', 'fullscreen=yes')
} catch (err) {
console.error(err)
b2bLogger.error(err)
} finally {
setIsRequestLoading(false)
}
Expand Down Expand Up @@ -345,7 +346,7 @@ function Invoice() {
window.open(invoicesExport?.url, '_blank')
}
} catch (err) {
console.error(err)
b2bLogger.error(err)
} finally {
setIsRequestLoading(false)
}
Expand Down
3 changes: 2 additions & 1 deletion apps/storefront/src/pages/invoice/utils/payment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getInvoiceCheckoutUrl } from '@/shared/service/b2b'
import { BcCartData } from '@/types/invoice'
import { b2bLogger } from '@/utils'
import { attemptCheckoutLoginAndRedirect } from '@/utils/b3checkout'

export const getCheckouUrlAndCart = async (params: BcCartData) => {
Expand Down Expand Up @@ -41,7 +42,7 @@ export const gotoInvoiceCheckoutUrl = async (
isReplaceCurrentUrl
)
} catch (e) {
console.error(e)
b2bLogger.error(e)
handleStencil()
}
}
3 changes: 2 additions & 1 deletion apps/storefront/src/pages/login/ForgotPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { B3Card, B3CustomForm, B3Sping, CustomButton } from '@/components'
import { useMobile } from '@/hooks'
import { CustomStyleContext } from '@/shared/customStyleButtton'
import { GlobaledContext } from '@/shared/global'
import { b2bLogger } from '@/utils'

import { getForgotPasswordFields, LoginConfig, sendEmail } from './config'
import { B3ResetPassWordButton, LoginImage } from './styled'
Expand Down Expand Up @@ -55,7 +56,7 @@ function ForgotPassword(props: ForgotPasswordProps) {
setLoading(false)
navigate('/login?loginFlag=2')
} catch (e) {
console.log(e)
b2bLogger.error(e)
}
}

Expand Down
3 changes: 2 additions & 1 deletion apps/storefront/src/pages/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '@/shared/service/b2b'
import { b2bLogin, bcLogoutLogin, customerLoginAPI } from '@/shared/service/bc'
import {
b2bLogger,
B3SStorage,
getCurrentCustomerInfo,
loginjump,
Expand Down Expand Up @@ -253,7 +254,7 @@ export default function Login(props: RegisteredProps) {
await loginCheckout(data)
window.location.reload()
} catch (error) {
console.log(error)
b2bLogger.error(error)
getforcePasswordReset(data.emailAddress)
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions apps/storefront/src/pages/login/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LangFormatFunction } from '@b3/lang'

import { storeHash, validatorRules } from '@/utils'
import { b2bLogger, storeHash, validatorRules } from '@/utils'
import { bcBaseUrl } from '@/utils/basicConfig'

export interface QuoteConfig {
Expand Down Expand Up @@ -109,7 +109,7 @@ export const loginCheckout = (data: LoginConfig) => {
requestOptions
)
.then((response) => response.text())
.catch((error) => console.log('error', error))
.catch((error) => b2bLogger.error('error', error))
}

export const sendEmail = (emailAddress: string) => {
Expand All @@ -130,7 +130,7 @@ export const sendEmail = (emailAddress: string) => {
requestOptions
)
.then((response) => response.text())
.catch((error) => console.log('error', error))
.catch((error) => b2bLogger.error('error', error))
}

export const getloginTokenInfo = (channelId: number) => {
Expand Down
3 changes: 2 additions & 1 deletion apps/storefront/src/pages/orderDetail/OrderDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getBcOrderStatusType,
getOrderStatusType,
} from '@/shared/service/b2b'
import { b2bLogger } from '@/utils'

import {
AddressConfigItem,
Expand Down Expand Up @@ -185,7 +186,7 @@ function OrderDetail() {
},
})
} catch (error) {
console.error(error)
b2bLogger.error(error)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
getBcVariantInfoBySkus,
} from '@/shared/service/b2b'
import { globalStateSelector } from '@/store'
import { b3TriggerCartNumber, snackbar } from '@/utils'
import { b2bLogger, b3TriggerCartNumber, snackbar } from '@/utils'
import { bcBaseUrl } from '@/utils/basicConfig'
import { callCart } from '@/utils/cartUtils'

Expand Down Expand Up @@ -161,7 +161,7 @@ export default function OrderDialog({
setIsRequestLoading(false)
handleClose()
} catch (err) {
console.log(err)
b2bLogger.error(err)
}
}

Expand Down
Loading

0 comments on commit ab43d1f

Please sign in to comment.