From e0cd01ce1f6acd5acba0bac5f23907014c29a838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Ste=CC=A8pien=CC=81?= Date: Tue, 10 Oct 2023 00:10:15 +0200 Subject: [PATCH] eslint fix --- _dev/js/theme/components/product.js | 2 +- _dev/js/theme/components/quickview.js | 2 +- _dev/js/theme/components/responsive.js | 32 ++++++++++++----------- _dev/js/theme/components/sliders/index.js | 2 +- _dev/js/theme/components/useThemeForm.js | 14 +++++----- _dev/js/theme/index.js | 2 -- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/_dev/js/theme/components/product.js b/_dev/js/theme/components/product.js index 66e584f8..d43ebb34 100644 --- a/_dev/js/theme/components/product.js +++ b/_dev/js/theme/components/product.js @@ -1,7 +1,7 @@ import prestashop from 'prestashop'; import useCustomQuantityInput from './useCustomQuantityInput'; import { each } from '../utils/DOMHelpers'; -import DOMReady from "../utils/DOMReady"; +import DOMReady from '../utils/DOMReady'; import productEventContextSelector from '../core/product/utils/productEventContextSelector'; DOMReady(() => { diff --git a/_dev/js/theme/components/quickview.js b/_dev/js/theme/components/quickview.js index bc27665f..20ff3d76 100644 --- a/_dev/js/theme/components/quickview.js +++ b/_dev/js/theme/components/quickview.js @@ -6,7 +6,7 @@ import parseToHtml from '../utils/parseToHtml'; * Handle open quick view */ const handleQuickViewOpen = ({ resp }) => { - const body = document.body; + const { body } = document; const quickviewHtml = parseToHtml(resp.quickview_html); body.appendChild(quickviewHtml); diff --git a/_dev/js/theme/components/responsive.js b/_dev/js/theme/components/responsive.js index bdf59872..003b71d7 100644 --- a/_dev/js/theme/components/responsive.js +++ b/_dev/js/theme/components/responsive.js @@ -1,29 +1,31 @@ -import DOMReady from "../utils/DOMReady"; import prestashop from 'prestashop'; +import DOMReady from '../utils/DOMReady'; +function isMobile() { + return prestashop.responsive.current_width < prestashop.responsive.min_width; +} + +/* eslint-disable */ prestashop.responsive = {}; +/* eslint-enable */ prestashop.responsive.current_width = window.innerWidth; prestashop.responsive.min_width = 768; prestashop.responsive.mobile = isMobile(); -function isMobile() { - return prestashop.responsive.current_width < prestashop.responsive.min_width; -} - function swapChildren(obj1, obj2) { - const temp = Array.from(obj2.children).map(child => child.cloneNode(true)); + const temp = Array.from(obj2.children).map((child) => child.cloneNode(true)); obj2.innerHTML = ''; - temp.forEach(child => obj2.appendChild(child)); + temp.forEach((child) => obj2.appendChild(child)); const childrenObj1 = Array.from(obj1.children); - childrenObj1.forEach(child => obj1.removeChild(child)); - childrenObj1.forEach(child => obj2.appendChild(child)); + childrenObj1.forEach((child) => obj1.removeChild(child)); + childrenObj1.forEach((child) => obj2.appendChild(child)); } function toggleMobileStyles() { if (prestashop.responsive.mobile) { - document.querySelectorAll('*[id^="_desktop_"]').forEach(el => { + document.querySelectorAll('*[id^="_desktop_"]').forEach((el) => { const target = document.getElementById(el.id.replace('_desktop_', '_mobile_')); if (target) { @@ -31,9 +33,9 @@ function toggleMobileStyles() { } }); - document.querySelectorAll('[data-collapse-hide-mobile]').forEach(el => el.classList.add('collapse')); + document.querySelectorAll('[data-collapse-hide-mobile]').forEach((el) => el.classList.add('collapse')); } else { - document.querySelectorAll('*[id^="_mobile_"]').forEach(el => { + document.querySelectorAll('*[id^="_mobile_"]').forEach((el) => { const target = document.getElementById(el.id.replace('_mobile_', '_desktop_')); if (target) { @@ -41,8 +43,8 @@ function toggleMobileStyles() { } }); - document.querySelectorAll('[data-collapse-hide-mobile]:not(.show)').forEach(el => el.classList.remove('collapse')); - document.querySelectorAll('[data-modal-hide-mobile].show').forEach(el => el.classList.remove('show')); + document.querySelectorAll('[data-collapse-hide-mobile]:not(.show)').forEach((el) => el.classList.remove('collapse')); + document.querySelectorAll('[data-modal-hide-mobile].show').forEach((el) => el.classList.remove('show')); } prestashop.emit('responsive update', { mobile: prestashop.responsive.mobile, @@ -60,7 +62,7 @@ const handleResize = () => { if (toggle) { toggleMobileStyles(); } -} +}; window.addEventListener('resize', handleResize); diff --git a/_dev/js/theme/components/sliders/index.js b/_dev/js/theme/components/sliders/index.js index a63e90d1..ad4c1230 100644 --- a/_dev/js/theme/components/sliders/index.js +++ b/_dev/js/theme/components/sliders/index.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import DOMReady from "../../utils/DOMReady"; +import DOMReady from '../../utils/DOMReady'; import PageSlider from './PageSlider'; import SwiperSlider from './SwiperSlider'; diff --git a/_dev/js/theme/components/useThemeForm.js b/_dev/js/theme/components/useThemeForm.js index b3c055be..73fa0146 100644 --- a/_dev/js/theme/components/useThemeForm.js +++ b/_dev/js/theme/components/useThemeForm.js @@ -42,7 +42,7 @@ const formValidation = (form) => { const divToScroll = { value: null }; - Array.from(form.querySelectorAll('input, textarea')).forEach(field => { + Array.from(form.querySelectorAll('input, textarea')).forEach((field) => { field.addEventListener('blur', (e) => { const inputField = e.currentTarget; inputField.value = inputField.value.trim(); @@ -54,7 +54,7 @@ const formValidation = (form) => { event.preventDefault(); event.stopPropagation(); - Array.from(form.querySelectorAll('input:invalid, select:invalid, textarea:invalid')).forEach(field => { + Array.from(form.querySelectorAll('input:invalid, select:invalid, textarea:invalid')).forEach((field) => { const inputField = field; const parent = inputField.closest('.form-group'); const invalidFeedback = parent.querySelector('.js-invalid-feedback-browser'); @@ -90,15 +90,15 @@ const useThemeForm = ( ) => { const DOM_SELECTORS = { SELECT_LINK: '.js-select-link', - } + }; const handleSelectChange = (event) => { - const target = event.target; + const { target } = event; if (target) { window.location.href = target.value; } - } + }; const init = () => { each(document.querySelectorAll(passwordToggleSelector), togglePasswordVisibility); @@ -106,11 +106,11 @@ const useThemeForm = ( each(document.querySelectorAll(DOM_SELECTORS.SELECT_LINK), (select) => { select.addEventListener('change', handleSelectChange); }); - } + }; return { init, - } + }; }; export default useThemeForm; diff --git a/_dev/js/theme/index.js b/_dev/js/theme/index.js index f3e3cf37..d15bbba5 100644 --- a/_dev/js/theme/index.js +++ b/_dev/js/theme/index.js @@ -1,5 +1,3 @@ -import $ from 'jquery'; - import EventEmitter from 'events'; import './core/index';