Skip to content

Commit

Permalink
feat(BUN-2087): refactoring hooks eslint rule (#947)
Browse files Browse the repository at this point in the history
* feat(BUN-2087): refactoring eslint rule

* feat(BUN-2087): nit
  • Loading branch information
bc-victor authored Feb 28, 2024
1 parent 6129f7e commit 612f8b3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
8 changes: 6 additions & 2 deletions apps/storefront/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"src/pages/**/*.{ts,tsx}",
"src/utils/**/*.{ts,tsx}",
"src/components/**/*.{ts,tsx}",
"src/hooks/dom/*.ts",
"src/shared/**/**.*ts"
],
"rules": {
Expand Down Expand Up @@ -151,7 +150,12 @@
"rules": { "react/jsx-wrap-multilines": 0 }
},
{
"files": ["src/components/**/*.tsx", "src/pages/**/*.{ts,tsx}"],
"files": [
"src/components/**/*.tsx",
"src/pages/**/*.{ts,tsx}",
"src/hooks/**/*.ts",
"src/hooks/*.ts"
],
"rules": { "import/extensions": 0 }
},
{
Expand Down
5 changes: 3 additions & 2 deletions apps/storefront/src/hooks/dom/useCartToQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ const useCartToQuote = ({
}

if (document.querySelectorAll('.b2b-cart-to-quote')?.length) {
const cartToQuoteBtn = document.querySelectorAll('.b2b-cart-to-quote')
cartToQuoteBtn.forEach((cartToQuoteBtn: CustomFieldItems) => {
const cartToQuoteBtns = document.querySelectorAll('.b2b-cart-to-quote')
cartToQuoteBtns.forEach((button: CustomFieldItems) => {
const cartToQuoteBtn = button
cartToQuoteBtn.innerHTML = cartToQuoteBtnLabel
cartToQuoteBtn.setAttribute('style', customCss)
cartToQuoteBtn.style.backgroundColor = color
Expand Down
3 changes: 2 additions & 1 deletion apps/storefront/src/hooks/dom/useDomVariation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const useDomVariation = (dom: string, quoteCallBbck?: () => void) => {
if (doms.length) {
doms.forEach((dom: CustomFieldItems) => {
if (!dom?.ready) {
dom.ready = true
const d = dom
d.ready = true
changeQuickview()
}
})
Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/src/hooks/dom/useHideGoogleCustomerReviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const useHideGoogleCustomerReviews = (
const newVisibilityStyle = isOpen ? 'none' : 'inline-block'

googleCustomerReviewsDoms.forEach((dom) => {
if (dom?.parentElement)
dom.parentElement.style.display = newVisibilityStyle
const d = dom
if (d?.parentElement) d.parentElement.style.display = newVisibilityStyle
})
}, [isOpen])
}
Expand Down
3 changes: 2 additions & 1 deletion apps/storefront/src/hooks/dom/useMyQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ const useMyQuote = ({

const addBtnStyle = () => {
const myQuoteBtn = document.querySelectorAll('.b2b-add-to-quote')
myQuoteBtn.forEach((myQuote: CustomFieldItems) => {
myQuoteBtn.forEach((quote: CustomFieldItems) => {
const myQuote = quote
myQuote.innerHTML = myQuoteBtnLabel
myQuote.setAttribute(
'style',
Expand Down
5 changes: 3 additions & 2 deletions apps/storefront/src/hooks/dom/useOpenPDP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ export const useOpenPDP = ({ setOpenPage, role }: MutationObserverProps) => {
(shoppingListBtn as CustomFieldItems)[key]
)
if (!isAddStyle) {
const myShoppingListBtn = document.querySelectorAll('.b2b-add-to-list')
myShoppingListBtn.forEach((myShoppingListBtn: CustomFieldItems) => {
const myShoppingListBtns = document.querySelectorAll('.b2b-add-to-list')
myShoppingListBtns.forEach((button: CustomFieldItems) => {
const myShoppingListBtn = button
myShoppingListBtn.innerHTML = myShoppingListBtnLabel
myShoppingListBtn.setAttribute('style', customCss)
myShoppingListBtn.style.backgroundColor = color
Expand Down

0 comments on commit 612f8b3

Please sign in to comment.