From 4dcc5832fbb81ce2982847f71306a85c0533a438 Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:44 +0100 Subject: [PATCH 01/93] chore(components/abtesting/hooks): lint js files --- .../hooks/jest-tests/experiment-core.test.js | 137 ++++-------------- .../hooks/jest-tests/optimizely-x.test.js | 4 +- components/abtesting/hooks/src/index.js | 4 +- .../hooks/src/useExperiment/index.js | 4 +- .../hooks/src/useExperimentCore/index.js | 42 ++---- .../src/useExperimentCore/optimizely-x.js | 11 +- 6 files changed, 42 insertions(+), 160 deletions(-) diff --git a/components/abtesting/hooks/jest-tests/experiment-core.test.js b/components/abtesting/hooks/jest-tests/experiment-core.test.js index 280a20c09..354bf16f2 100644 --- a/components/abtesting/hooks/jest-tests/experiment-core.test.js +++ b/components/abtesting/hooks/jest-tests/experiment-core.test.js @@ -5,9 +5,7 @@ import Enzyme, {mount} from 'enzyme' import Adapter from '@wojtekmaj/enzyme-adapter-react-17' -import AbTestOptimizelyXExperiment, { - getExperimentContext -} from '../../optimizelyXExperiment/src' +import AbTestOptimizelyXExperiment, {getExperimentContext} from '../../optimizelyXExperiment/src' import {useExperiment as useExperimentRaw, useExperimentCore} from '../src' import OptimizelyX from '../src/useExperimentCore/optimizely-x' @@ -18,13 +16,9 @@ jest.useFakeTimers() // configure dependencies const useExperiment = params => useExperimentRaw( - typeof params === 'string' - ? {getExperimentContext, name: params} - : {getExperimentContext, ...params} + typeof params === 'string' ? {getExperimentContext, name: params} : {getExperimentContext, ...params} ) -const OptimizelyXExperiment = props => ( - -) +const OptimizelyXExperiment = props => describe('Experiment', () => { let activationHandler @@ -32,24 +26,17 @@ describe('Experiment', () => { beforeEach(() => { const noop = () => {} activationHandler = {single: noop} - jest - .spyOn(OptimizelyX, 'addActivationListener') - .mockImplementation((experimentId, handler) => { - activationHandler.single = handler - activationHandler[experimentId] = handler - }) + jest.spyOn(OptimizelyX, 'addActivationListener').mockImplementation((experimentId, handler) => { + activationHandler.single = handler + activationHandler[experimentId] = handler + }) }) afterEach(() => { OptimizelyX.addActivationListener.mockRestore() }) - const assertActivation = ( - Component, - expectedFromDefault, - variationId, - expectedFromVariation - ) => { + const assertActivation = (Component, expectedFromDefault, variationId, expectedFromVariation) => { let mounted act(() => { mounted = mount() @@ -88,11 +75,7 @@ describe('Experiment', () => { () => { const experimentData = useExperiment({ experimentId: 40000, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) return ( @@ -119,11 +102,7 @@ describe('Experiment', () => { const experimentData = useExperiment({ name: 'myexperiment', experimentId: 40000, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) return ( @@ -164,20 +143,12 @@ describe('Experiment', () => { const catsExperimentData = useExperiment({ name: 'cats', experimentId: 40000, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const dogsExperimentData = useExperiment({ name: 'dogs', experimentId: 50000, - variations: [ - {id: 900000, isDefault: true}, - {id: 900001}, - {id: 900002} - ] + variations: [{id: 900000, isDefault: true}, {id: 900001}, {id: 900002}] }) return ( @@ -222,20 +193,12 @@ describe('Experiment', () => { () => { const catsExperimentData = useExperiment({ experimentId: 40000, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const dogsExperimentData = useExperiment({ name: 'dogs', experimentId: 50000, - variations: [ - {id: 900000, isDefault: true}, - {id: 900001}, - {id: 900002} - ] + variations: [{id: 900000, isDefault: true}, {id: 900001}, {id: 900002}] }) return ( @@ -261,11 +224,7 @@ describe('Experiment', () => { () => { const experimentData = useExperiment({ experimentId: 40000, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {isWrapped} = experimentData return isWrapped.toString() @@ -281,11 +240,7 @@ describe('Experiment', () => { () => { const experimentData = useExperiment({ experimentId: 40000, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {isActive} = experimentData return isActive.toString() @@ -301,11 +256,7 @@ describe('Experiment', () => { () => { const experimentData = useExperiment({ experimentId: 40000, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {isDefault} = experimentData return isDefault.toString() @@ -321,11 +272,7 @@ describe('Experiment', () => { () => { const experimentData = useExperiment({ experimentId: 40000, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {isVariation} = experimentData return isVariation.toString() @@ -341,11 +288,7 @@ describe('Experiment', () => { () => { const experimentData = useExperiment({ experimentId: 40000, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {experimentId, variationId} = experimentData return `${experimentId}/${variationId}` @@ -361,11 +304,7 @@ describe('Experiment', () => { () => { const experimentData = useExperiment({ experimentId: 40000, - variations: [ - {id: 700000}, - {id: 700001}, - {id: 700002, isDefault: true} - ] + variations: [{id: 700000}, {id: 700001}, {id: 700002, isDefault: true}] }) const {variationName} = experimentData return variationName @@ -381,11 +320,7 @@ describe('Experiment', () => { () => { const experimentData = useExperiment({ experimentId: 40000, - variations: [ - {id: 700000}, - {id: 700001}, - {id: 700002, isDefault: true} - ] + variations: [{id: 700000}, {id: 700001}, {id: 700002, isDefault: true}] }) const {isVariationA, isVariationB, isVariationC} = experimentData return `${isVariationA}:${isVariationB}:${isVariationC}` @@ -402,11 +337,7 @@ describe('Experiment', () => { const experimentData = useExperiment({ experimentId: 40000, forceVariation: 700001, // B - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {variationName} = experimentData return variationName @@ -423,11 +354,7 @@ describe('Experiment', () => { const experimentData = useExperiment({ experimentId: 40000, forceVariation: 'B', - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {variationName} = experimentData return variationName @@ -444,11 +371,7 @@ describe('Experiment', () => { const experimentData = useExperiment({ experimentId: 40000, forceActivation: 700001, // B - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {variationName} = experimentData return variationName @@ -465,11 +388,7 @@ describe('Experiment', () => { const experimentData = useExperiment({ experimentId: 40000, forceActivation: 'B', - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {variationName} = experimentData return variationName @@ -489,11 +408,7 @@ describe('Experiment', () => { onActivation: experimentData => { dataFromOnActivation = experimentData }, - variations: [ - {id: 700000, isDefault: true}, - {id: 700001}, - {id: 700002} - ] + variations: [{id: 700000, isDefault: true}, {id: 700001}, {id: 700002}] }) const {variationName} = experimentData return variationName diff --git a/components/abtesting/hooks/jest-tests/optimizely-x.test.js b/components/abtesting/hooks/jest-tests/optimizely-x.test.js index 328730a5d..4cf007ead 100644 --- a/components/abtesting/hooks/jest-tests/optimizely-x.test.js +++ b/components/abtesting/hooks/jest-tests/optimizely-x.test.js @@ -30,9 +30,7 @@ describe('OptimizelyXExperiments', () => { get: jest.fn().mockReturnValue({ getExperimentStates: () => fakeExperiments }), - push: jest - .fn() - .mockImplementation(listener => (sdkHandler = listener.handler)) + push: jest.fn().mockImplementation(listener => (sdkHandler = listener.handler)) } }) diff --git a/components/abtesting/hooks/src/index.js b/components/abtesting/hooks/src/index.js index d43d97bd2..5c5f50143 100644 --- a/components/abtesting/hooks/src/index.js +++ b/components/abtesting/hooks/src/index.js @@ -1,8 +1,6 @@ export default function ReactHooks() { /* eslint-disable-next-line no-console */ - console.warn( - "[@s-ui/react-abtesting-hooks] can't be used as a standalone package.\nYou must import a specific hook." - ) + console.warn("[@s-ui/react-abtesting-hooks] can't be used as a standalone package.\nYou must import a specific hook.") return null } diff --git a/components/abtesting/hooks/src/useExperiment/index.js b/components/abtesting/hooks/src/useExperiment/index.js index 8f652955e..1b1a68990 100644 --- a/components/abtesting/hooks/src/useExperiment/index.js +++ b/components/abtesting/hooks/src/useExperiment/index.js @@ -29,8 +29,6 @@ export default (params = {}) => { const contextGetter = getExperimentContext || getExperimentContextFromPackage const experimentName = typeof params === 'string' ? params : params.name const ExperimentContext = contextGetter(experimentName) - const experimentData = - useContext(ExperimentContext) || - NON_WRAPPED_BY_CONTEXT_PROVIDER_FALLBACK_OBJECT + const experimentData = useContext(ExperimentContext) || NON_WRAPPED_BY_CONTEXT_PROVIDER_FALLBACK_OBJECT return experimentData } diff --git a/components/abtesting/hooks/src/useExperimentCore/index.js b/components/abtesting/hooks/src/useExperimentCore/index.js index a704f148b..cb58bb17b 100644 --- a/components/abtesting/hooks/src/useExperimentCore/index.js +++ b/components/abtesting/hooks/src/useExperimentCore/index.js @@ -41,16 +41,13 @@ export default params => { variations.find( variation => // name or id are both valid ways to force a variation - variationId === getNameFromVariation(variation) || - variationId === variation.id + variationId === getNameFromVariation(variation) || variationId === variation.id ) return checkedVariation ? checkedVariation.id : null } const getNameFromVariationId = variationId => { - return getNameFromVariation( - variations.find(variation => variationId === variation.id) - ) + return getNameFromVariation(variations.find(variation => variationId === variation.id)) } const getFlagsFromVariationId = variationId => { @@ -59,8 +56,7 @@ export default params => { // capitalize variation name in order to get a well-formed camel case key // i. e. for a name 'foo' → isVariationFoo - const capitalizedVariationName = - variationName.charAt(0).toUpperCase() + variationName.slice(1) + const capitalizedVariationName = variationName.charAt(0).toUpperCase() + variationName.slice(1) return { ...obj, @@ -84,8 +80,7 @@ export default params => { } } - const initialVariationId = - checkVariationId(params.forceVariation) || defaultVariationId + const initialVariationId = checkVariationId(params.forceVariation) || defaultVariationId // set state which will be used to provide context const initialState = buildExperimentState({variationId: initialVariationId}) @@ -122,10 +117,7 @@ export default params => { * Activate variation via `forceActivation` API flag */ if (forceActivation) { - setTimeout( - () => activationHandler(checkVariationId(forceActivation)), - forceActivationDelay - ) + setTimeout(() => activationHandler(checkVariationId(forceActivation)), forceActivationDelay) logWatchOutMessage(getMessageForParam('forceActivation')) return } @@ -156,41 +148,27 @@ export default params => { const splitNames = forceExperiment => forceExperiment.split('|') const getForceExperimentToBeApplied = () => { - if ( - forceExperimentFromQueryParam && - forceExperimentFromSessionStorage - ) { + if (forceExperimentFromQueryParam && forceExperimentFromSessionStorage) { // When both query param and session storage entry are present, // query param has preference BUT only if it's the same name, // so it can override session storage entry. const [nameFromQP] = splitNames(forceExperimentFromQueryParam) const [nameFromSS] = splitNames(forceExperimentFromSessionStorage) - return nameFromQP === nameFromSS - ? forceExperimentFromQueryParam - : forceExperimentFromSessionStorage + return nameFromQP === nameFromSS ? forceExperimentFromQueryParam : forceExperimentFromSessionStorage } // Otherwise, whether any of them are present preference rule is simple - return ( - forceExperimentFromQueryParam || forceExperimentFromSessionStorage - ) + return forceExperimentFromQueryParam || forceExperimentFromSessionStorage } const forceExperiment = getForceExperimentToBeApplied() if (forceExperiment) { const [experimentName, variationName] = splitNames(forceExperiment) - if ( - !experimentName || - !variationName || - state.name !== experimentName - ) { + if (!experimentName || !variationName || state.name !== experimentName) { return } // fake activation is ready to trigger - setTimeout( - () => activationHandler(checkVariationId(variationName)), - forceActivationDelay - ) + setTimeout(() => activationHandler(checkVariationId(variationName)), forceActivationDelay) storage({ method: 'setItem', diff --git a/components/abtesting/hooks/src/useExperimentCore/optimizely-x.js b/components/abtesting/hooks/src/useExperimentCore/optimizely-x.js index 1f7548b00..28f8b6081 100644 --- a/components/abtesting/hooks/src/useExperimentCore/optimizely-x.js +++ b/components/abtesting/hooks/src/useExperimentCore/optimizely-x.js @@ -26,8 +26,7 @@ const waitUntil = (truthyFn, callback, delay = 100, interval = 100) => { }, interval) } -const getOptimizely = () => - window && window.optimizely && window.optimizely.get && window.optimizely +const getOptimizely = () => window && window.optimizely && window.optimizely.get && window.optimizely /** * Register handler to optimizely ONCE @@ -105,9 +104,7 @@ class OptimizelyXExperiments { */ static async getInfo(experimentId) { const sdk = await this.getSDK() - return ( - sdk && sdk.get && sdk.get('state').getExperimentStates()[experimentId] - ) + return sdk && sdk.get && sdk.get('state').getExperimentStates()[experimentId] } /** @@ -153,9 +150,7 @@ class OptimizelyXExperiments { static async removeActivationListener(experimentId, removedHandler) { const handlers = activationHandlers[experimentId] if (!handlers) return - activationHandlers[experimentId] = handlers.filter( - handler => handler !== removedHandler - ) + activationHandlers[experimentId] = handlers.filter(handler => handler !== removedHandler) } /** From 29d1cebc40d1c991eba8595fb25f46c5ef75dc3b Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:46 +0100 Subject: [PATCH 02/93] chore(components/abtesting/optimizelyXExperiment): lint js files --- .../src/experiment-provider-and-core/index.js | 10 +++------- .../src/experiment-provider-only/index.js | 6 +----- .../abtesting/optimizelyXExperiment/src/index.js | 3 +-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/components/abtesting/optimizelyXExperiment/src/experiment-provider-and-core/index.js b/components/abtesting/optimizelyXExperiment/src/experiment-provider-and-core/index.js index 5b451041f..97e412b5e 100644 --- a/components/abtesting/optimizelyXExperiment/src/experiment-provider-and-core/index.js +++ b/components/abtesting/optimizelyXExperiment/src/experiment-provider-and-core/index.js @@ -9,17 +9,13 @@ import experimentPropsMapper from './experiment-props-mapper' function ExperimentProviderAndCore(props) { const {deps, children} = props - const useExperimentCore = - (deps && deps.useExperimentCore) || useExperimentCoreFromPackage + const useExperimentCore = (deps && deps.useExperimentCore) || useExperimentCoreFromPackage const experimentParams = experimentPropsMapper(props) - const {experimentData: experimentDataFromCore} = - useExperimentCore(experimentParams) + const {experimentData: experimentDataFromCore} = useExperimentCore(experimentParams) return ( - - {children} - + {children} ) } diff --git a/components/abtesting/optimizelyXExperiment/src/experiment-provider-only/index.js b/components/abtesting/optimizelyXExperiment/src/experiment-provider-only/index.js index 0df159a3e..d3f130c6c 100644 --- a/components/abtesting/optimizelyXExperiment/src/experiment-provider-only/index.js +++ b/components/abtesting/optimizelyXExperiment/src/experiment-provider-only/index.js @@ -4,11 +4,7 @@ import {getExperimentContext} from '../context' function ExperimentProviderOnly({children, experimentData}) { const ExperimentContext = getExperimentContext(experimentData.name) - return ( - - {children} - - ) + return {children} } ExperimentProviderOnly.propTypes = { diff --git a/components/abtesting/optimizelyXExperiment/src/index.js b/components/abtesting/optimizelyXExperiment/src/index.js index 70369484a..82f42fc4d 100644 --- a/components/abtesting/optimizelyXExperiment/src/index.js +++ b/components/abtesting/optimizelyXExperiment/src/index.js @@ -10,8 +10,7 @@ function AbTestOptimizelyXExperiment(props) { // ACT AS AN EXPERIMENT CONTEXT PROVIDER ONLY // - feeds from an external experiment and provides data from it to the context - if (isProviderOnly) - return + if (isProviderOnly) return // ACT AS AN EXPERIMENT CORE RUNNER AND CONTEXT PROVIDER // - internally runs the experiment and provides data from it to the context From 116fb2e6d9f2965032b7f076dcac3ccd81b83e1c Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:47 +0100 Subject: [PATCH 03/93] chore(components/abtesting/toggle): lint js files --- components/abtesting/toggle/src/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/abtesting/toggle/src/index.js b/components/abtesting/toggle/src/index.js index 883c1b57d..089fbeb85 100644 --- a/components/abtesting/toggle/src/index.js +++ b/components/abtesting/toggle/src/index.js @@ -5,9 +5,7 @@ import {createElement} from 'react' import PropTypes from 'prop-types' export default function AbTestToggle({children, variation}) { - const filterFunc = variation - ? child => child.props.variationId == variation - : child => child.props.defaultVariation + const filterFunc = variation ? child => child.props.variationId == variation : child => child.props.defaultVariation let child = children.filter(filterFunc)[0] || null From d774b81b5b38f786d0c58ba70eff159b437287f7 Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:47 +0100 Subject: [PATCH 04/93] chore(components/ad/smartbanner): lint js files --- components/ad/smartbanner/src/RatingStar/component.js | 9 ++------- components/ad/smartbanner/src/index.js | 6 +----- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/components/ad/smartbanner/src/RatingStar/component.js b/components/ad/smartbanner/src/RatingStar/component.js index 0dcf9d5ce..6dcebf6a7 100644 --- a/components/ad/smartbanner/src/RatingStar/component.js +++ b/components/ad/smartbanner/src/RatingStar/component.js @@ -5,8 +5,7 @@ import IconStarEmptyDefault from '@s-ui/react-icons/lib/Starempty' import IconStarHalfDefault from '@s-ui/react-icons/lib/Starhalf' const baseNumber = 0.5 -const checkRatingValue = ({ratingValue, ratingMax}) => - ratingValue % baseNumber === 0 && ratingValue <= ratingMax +const checkRatingValue = ({ratingValue, ratingMax}) => ratingValue % baseNumber === 0 && ratingValue <= ratingMax const RatingStar = ({ ratingValue = 0, @@ -43,11 +42,7 @@ const RatingStar = ({ return } - return ( - - {Array(ratingMax).fill().map(_renderStar)} - - ) + return {Array(ratingMax).fill().map(_renderStar)} } RatingStar.propTypes = { diff --git a/components/ad/smartbanner/src/index.js b/components/ad/smartbanner/src/index.js index 730b8da4c..90aa60b30 100644 --- a/components/ad/smartbanner/src/index.js +++ b/components/ad/smartbanner/src/index.js @@ -45,11 +45,7 @@ function AdSmartbanner({

{text}

{ratingValue !== null && (
- +
)} From ac486a8c0b82a64f4b2e0c22eab07fdeff3bdcaa Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:47 +0100 Subject: [PATCH 05/93] chore(components/alert/basic): lint js files --- components/alert/basic/src/index.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/components/alert/basic/src/index.js b/components/alert/basic/src/index.js index f98c83d2a..980a04fa1 100644 --- a/components/alert/basic/src/index.js +++ b/components/alert/basic/src/index.js @@ -24,21 +24,10 @@ function _renderAction({handle, text, className}) { } function _renderActions(actions) { - return ( -
- {actions.map((action, index) => _renderAction(action))} -
- ) + return
{actions.map((action, index) => _renderAction(action))}
} -export default function AlertBasic({ - type, - children, - icon, - actions, - iconClose: IconClose, - handleClose -}) { +export default function AlertBasic({type, children, icon, actions, iconClose: IconClose, handleClose}) { const AlertIcon = icon || icons[type] return (
From fc091d1c18c89fe4cc114ed3b2c19f9f05cfd07e Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:47 +0100 Subject: [PATCH 06/93] chore(components/atom/badgeCounter): lint js files --- components/atom/badgeCounter/src/index.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/components/atom/badgeCounter/src/index.js b/components/atom/badgeCounter/src/index.js index 05aaf2e40..d6023c7b2 100644 --- a/components/atom/badgeCounter/src/index.js +++ b/components/atom/badgeCounter/src/index.js @@ -1,15 +1,9 @@ import PropTypes from 'prop-types' -export default function BadgeCounter({ - size = 'medium', - type = 'bullet', - thickness = 'medium' -}) { +export default function BadgeCounter({size = 'medium', type = 'bullet', thickness = 'medium'}) { return (
- +
) } From d1998d9d8b5beeee51e3d98b4265496b29766d58 Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:48 +0100 Subject: [PATCH 07/93] chore(components/button/basic): lint js files --- components/button/basic/src/index.js | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/components/button/basic/src/index.js b/components/button/basic/src/index.js index 210f6caab..0d705d89d 100644 --- a/components/button/basic/src/index.js +++ b/components/button/basic/src/index.js @@ -1,23 +1,10 @@ import cx from 'classnames' import PropTypes from 'prop-types' -function ButtonBasic({ - disabled, - icon, - text, - layout, - onClick, - size = 'medium', - type = 'primary' -}) { - const className = cx( - 'sui-ButtonBasic', - `sui-ButtonBasic--${size}`, - `sui-ButtonBasic--${type}`, - { - [`sui-ButtonBasic--${layout}`]: layout - } - ) +function ButtonBasic({disabled, icon, text, layout, onClick, size = 'medium', type = 'primary'}) { + const className = cx('sui-ButtonBasic', `sui-ButtonBasic--${size}`, `sui-ButtonBasic--${type}`, { + [`sui-ButtonBasic--${layout}`]: layout + }) return ( - + - +
- - + - +
diff --git a/components/css/transition/src/index.js b/components/css/transition/src/index.js index 56e231567..e5805ccd8 100644 --- a/components/css/transition/src/index.js +++ b/components/css/transition/src/index.js @@ -1,7 +1,4 @@ -import { - CSSTransition as Transition, - TransitionGroup as AnimationTransitionGroup -} from 'react-transition-group' +import {CSSTransition as Transition, TransitionGroup as AnimationTransitionGroup} from 'react-transition-group' import PropTypes from 'prop-types' From 80561dd91e2b2b5ff48d556f898a325543ea5439 Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:52 +0100 Subject: [PATCH 24/93] chore(components/dropdown/basic): lint js files --- components/dropdown/basic/src/index.js | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/components/dropdown/basic/src/index.js b/components/dropdown/basic/src/index.js index fbdeb738c..c861a79e3 100644 --- a/components/dropdown/basic/src/index.js +++ b/components/dropdown/basic/src/index.js @@ -10,23 +10,8 @@ const BASE_CLASS = 'sui-DropdownBasic' const MENU_CLASS = `${BASE_CLASS}Menu` const NO_OP = () => {} -const defaultLinkFactory = ({ - href, - className, - children, - onClick, - rel, - target, - title -}) => ( -
+const defaultLinkFactory = ({href, className, children, onClick, rel, target, title}) => ( + {children} ) From cfd97e7eb738b79c8ca4bd67387e3f2ece4739a3 Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:52 +0100 Subject: [PATCH 25/93] chore(components/dropdown/user): lint js files --- components/dropdown/user/src/index.js | 48 ++++++------------------- components/dropdown/user/src/reducer.js | 6 +--- 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/components/dropdown/user/src/index.js b/components/dropdown/user/src/index.js index cd714ea64..f91a8ea0b 100644 --- a/components/dropdown/user/src/index.js +++ b/components/dropdown/user/src/index.js @@ -4,9 +4,7 @@ import {useReducer} from 'react' import cx from 'classnames' import PropTypes from 'prop-types' -import MoleculeBadgeCounter, { - moleculeBadgeCounterSizes -} from '@s-ui/react-molecule-badge-counter' +import MoleculeBadgeCounter, {moleculeBadgeCounterSizes} from '@s-ui/react-molecule-badge-counter' import {reducer, reducerActions, reducerInitialState} from './reducer' @@ -26,21 +24,15 @@ const DropdownUser = ({ const toggleMenu = () => dispatch({type: reducerActions.TOGGLE_MENU}) - const handleMouseOver = () => - expandOnMouseOver && dispatch({type: reducerActions.MOUSE_HOVER}) + const handleMouseOver = () => expandOnMouseOver && dispatch({type: reducerActions.MOUSE_HOVER}) - const handleMouseOut = () => - expandOnMouseOver && dispatch({type: reducerActions.MOUSE_OUT}) + const handleMouseOut = () => expandOnMouseOver && dispatch({type: reducerActions.MOUSE_OUT}) const handleClick = () => !expandOnMouseOver && toggleMenu() - const handleTouchStart = () => - expandOnMouseOver && collapseByTouch && toggleMenu() + const handleTouchStart = () => expandOnMouseOver && collapseByTouch && toggleMenu() - const renderLink = ( - {onClick, text, url, icon: Icon, notifications, highlight}, - index - ) => { + const renderLink = ({onClick, text, url, icon: Icon, notifications, highlight}, index) => { const linkClassName = cx('sui-DropdownUserMenu-listLink', { 'sui-DropdownUserMenu-listLinkHighlight': highlight }) @@ -51,22 +43,14 @@ const DropdownUser = ({ return (
  • - +
    {text} {hasLinkNotifications && ( - + )} @@ -82,22 +66,10 @@ const DropdownUser = ({ }) return ( -
    -
    +
    +
    - {`${name}-avatar`} + {`${name}-avatar`}
    {name}
    diff --git a/components/dropdown/user/src/reducer.js b/components/dropdown/user/src/reducer.js index 539f01a33..193bff585 100644 --- a/components/dropdown/user/src/reducer.js +++ b/components/dropdown/user/src/reducer.js @@ -30,8 +30,4 @@ const reducer = (state, {type}) => { } } -export { - ACTIONS as reducerActions, - INITIAL_STATE as reducerInitialState, - reducer -} +export {ACTIONS as reducerActions, INITIAL_STATE as reducerInitialState, reducer} From adb92dc019e640ce4f40e4fba36e7b3fddb38019 Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:53 +0100 Subject: [PATCH 26/93] chore(components/error/appBoundary): lint js files --- components/error/appBoundary/src/index.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/components/error/appBoundary/src/index.js b/components/error/appBoundary/src/index.js index 9667ebf0a..6b194752c 100644 --- a/components/error/appBoundary/src/index.js +++ b/components/error/appBoundary/src/index.js @@ -10,8 +10,7 @@ class ErrorAppBoundary extends Component { state = {errorCount: 0, hasError: false} componentDidCatch(errorMessage, errorStack) { - const {errorThreshold, onError, redirectUrlOnBreakingThreshold, silent} = - this.props + const {errorThreshold, onError, redirectUrlOnBreakingThreshold, silent} = this.props const {errorCount} = this.state onError({errorMessage, errorStack}) @@ -25,8 +24,7 @@ class ErrorAppBoundary extends Component { this.setState({errorCount: errorCount + 1}) return errorCount >= errorThreshold - ? redirectUrlOnBreakingThreshold && - (window.location.href = redirectUrlOnBreakingThreshold) + ? redirectUrlOnBreakingThreshold && (window.location.href = redirectUrlOnBreakingThreshold) : this.setState({hasError: true}) } @@ -78,10 +76,7 @@ ErrorAppBoundary.propTypes = { /** * Wrapped childrens to control errors */ - children: PropTypes.oneOfType([ - PropTypes.arrayOf(PropTypes.node), - PropTypes.node - ]), + children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]), /** * Message to show to the user in order to inform him about the error */ @@ -112,8 +107,7 @@ ErrorAppBoundary.defaultProps = { message: 'Error', errorThreshold: 4, silent: false, - onError: ({errorMessage, errorStack}) => - console.error({errorMessage, errorStack}) // eslint-disable-line + onError: ({errorMessage, errorStack}) => console.error({errorMessage, errorStack}) // eslint-disable-line } export default ErrorAppBoundary From f50aaa8ebf520f450fbace78f337ac837c52756b Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:53 +0100 Subject: [PATCH 27/93] chore(components/form/autocompleted): lint js files --- components/form/autocompleted/src/index.js | 27 ++++--------------- .../form/autocompleted/src/suggests-list.js | 7 +---- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/components/form/autocompleted/src/index.js b/components/form/autocompleted/src/index.js index f2db743bc..ffa28b9a5 100644 --- a/components/form/autocompleted/src/index.js +++ b/components/form/autocompleted/src/index.js @@ -121,9 +121,7 @@ export default function FormAutocompleted(props) { } } - const _handleOutsideClick = event => - !excludeFromOutsideClick.includes(event.target) && - setShowSuggestsList(false) + const _handleOutsideClick = event => !excludeFromOutsideClick.includes(event.target) && setShowSuggestsList(false) const _focusInput = () => { inputEl.current.focus() @@ -132,11 +130,7 @@ export default function FormAutocompleted(props) { const _renderSubmitButton = ( {text, icon: Icon} // eslint-disable-line ) => ( - @@ -144,18 +138,12 @@ export default function FormAutocompleted(props) { const _renderSuggestsList = () => suggests && suggests.length > 0 ? ( - + ) : null useMount(() => { excludeFromOutsideClick = [inputEl, submitEl, suggestList] - closeOnOutsideClick === true && - window.addEventListener('click', _handleOutsideClick, false) + closeOnOutsideClick === true && window.addEventListener('click', _handleOutsideClick, false) return () => { window.removeEventListener('click', _handleOutsideClick, false) @@ -181,12 +169,7 @@ export default function FormAutocompleted(props) { onFocus={handleFocus} onBlur={handleBlur} /> - {value && ( - - )} + {value && }
    {submit && _renderSubmitButton(submit)}
    diff --git a/components/form/autocompleted/src/suggests-list.js b/components/form/autocompleted/src/suggests-list.js index be7f73d01..a0ffd1370 100644 --- a/components/form/autocompleted/src/suggests-list.js +++ b/components/form/autocompleted/src/suggests-list.js @@ -8,12 +8,7 @@ const SuggestsList = forwardRef((props, ref) => { return (
      {props.suggests.map((suggest, index) => ( - + ))}
    ) From 770e4c5fc668dbe1db5918742ca2de2b751fc72c Mon Sep 17 00:00:00 2001 From: "jordi.munoz@adevinta.com" Date: Sun, 3 Dec 2023 21:06:53 +0100 Subject: [PATCH 28/93] chore(components/form/builder/demo): lint js files --- .../form/builder/demo/BasicFormSection.js | 7 +--- components/form/builder/demo/formList.js | 32 +++---------------- components/form/builder/demo/formPTACar.js | 3 +- components/form/builder/demo/formPTAFC.js | 22 ++++--------- .../form/builder/demo/formPTAMiscLite.js | 3 +- components/form/builder/demo/formPTAMotor.js | 19 +++-------- 6 files changed, 18 insertions(+), 68 deletions(-) diff --git a/components/form/builder/demo/BasicFormSection.js b/components/form/builder/demo/BasicFormSection.js index 5ea49029e..bbb2149b3 100644 --- a/components/form/builder/demo/BasicFormSection.js +++ b/components/form/builder/demo/BasicFormSection.js @@ -29,12 +29,7 @@ export default function BasicFormSection({ return (
    - setStateFields(fields)} - {...restProps} - /> + setStateFields(fields)} {...restProps} />
    Date: Sun, 3 Dec 2023 21:06:53 +0100
    Subject: [PATCH 29/93] chore(components/form/builder): lint js files
    
    ---
     components/form/builder/src/Checkbox/index.js | 17 +---
     components/form/builder/src/FieldSet/index.js | 12 +--
     .../form/builder/src/InlineButton/index.js    |  9 +--
     components/form/builder/src/Input/index.js    | 18 +----
     .../form/builder/src/MultiButton/index.js     | 19 +----
     .../form/builder/src/Multicheckbox/index.js   | 15 +---
     .../form/builder/src/PickerSlider/index.js    | 16 +---
     .../form/builder/src/ProxyField/index.js      | 11 +--
     components/form/builder/src/Radio/index.js    | 10 +--
     .../form/builder/src/Range/Default/index.js   | 27 +------
     .../builder/src/Select/Autosuggest/index.js   | 39 ++-------
     .../form/builder/src/Select/Default/index.js  | 16 +---
     components/form/builder/src/Select/index.js   | 12 +--
     .../src/Standard/Fields/FieldSet/index.js     | 11 +--
     .../Standard/Fields/Multicheckbox/index.js    | 11 +--
     .../src/Standard/Fields/Numeric/index.js      | 11 +--
     .../src/Standard/Fields/Picker/index.js       | 11 +--
     .../src/Standard/Fields/Range/index.js        | 11 +--
     .../builder/src/Standard/Fields/Text/index.js | 11 +--
     .../Standard/Localization/EsEsLocalization.js |  6 +-
     .../src/Standard/Localization/Localization.js |  4 +-
     components/form/builder/src/Standard/index.js | 33 ++------
     components/form/builder/src/Stepper/index.js  | 12 +--
     components/form/builder/src/Switch/index.js   | 15 +---
     components/form/builder/src/TextArea/index.js | 15 +---
     components/form/builder/src/index.js          | 44 ++--------
     .../form/builder/src/prop-types/index.js      |  6 +-
     components/form/builder/src/reducer/fields.js | 14 +---
     .../form/builder/src/reducer/fn-utils.js      |  3 +-
     components/form/builder/src/reducer/index.js  | 10 +--
     components/form/builder/src/reducer/rules.js  | 81 ++++++-------------
     components/form/builder/test/index.test.js    | 15 +---
     32 files changed, 95 insertions(+), 450 deletions(-)
    
    diff --git a/components/form/builder/src/Checkbox/index.js b/components/form/builder/src/Checkbox/index.js
    index 38ce06987..bd80aa3dd 100644
    --- a/components/form/builder/src/Checkbox/index.js
    +++ b/components/form/builder/src/Checkbox/index.js
    @@ -7,16 +7,7 @@ import MoleculeCheckboxField from '@s-ui/react-molecule-checkbox-field'
     import IconCheck from '../Icons/IconCheck.js'
     import {createComponentMemo, field} from '../prop-types/index.js'
     
    -const Checkbox = ({
    -  checkbox,
    -  tabIndex,
    -  onChange,
    -  onFocus,
    -  onBlur,
    -  errors,
    -  alerts,
    -  renderer
    -}) => {
    +const Checkbox = ({checkbox, tabIndex, onChange, onFocus, onBlur, errors, alerts, renderer}) => {
       const errorMessages = errors[checkbox.id]
       const alertMessages = alerts[checkbox.id]
     
    @@ -84,11 +75,7 @@ const Checkbox = ({
     
       // render SUI component
       return (
    -    
    +
    ) diff --git a/components/form/builder/src/FieldSet/index.js b/components/form/builder/src/FieldSet/index.js index 7c559a8f7..8ed84a290 100644 --- a/components/form/builder/src/FieldSet/index.js +++ b/components/form/builder/src/FieldSet/index.js @@ -7,17 +7,7 @@ import ProxyField from '../ProxyField' const baseClass = 'sui-FormBuilder-FieldSet' -const FieldSet = ({ - fieldset, - tabIndex, - onChange, - onFocus, - onBlur, - fieldSize, - errors, - alerts, - renderer -}) => { +const FieldSet = ({fieldset, tabIndex, onChange, onFocus, onBlur, fieldSize, errors, alerts, renderer}) => { if (fieldset.hidden) { return null } diff --git a/components/form/builder/src/InlineButton/index.js b/components/form/builder/src/InlineButton/index.js index 527b4e96f..8244cc272 100644 --- a/components/form/builder/src/InlineButton/index.js +++ b/components/form/builder/src/InlineButton/index.js @@ -7,14 +7,7 @@ import MoleculeButtonGroupField from '@s-ui/react-molecule-button-group-field' import {createComponentMemo, field} from '../prop-types' -const InlineButton = ({ - inlineButton, - tabIndex, - onChange, - errors, - alerts, - renderer -}) => { +const InlineButton = ({inlineButton, tabIndex, onChange, errors, alerts, renderer}) => { const errorMessages = errors[inlineButton.id] const alertMessages = alerts[inlineButton.id] const datalist = inlineButton.datalist diff --git a/components/form/builder/src/Input/index.js b/components/form/builder/src/Input/index.js index c389e99e2..95e69ff25 100644 --- a/components/form/builder/src/Input/index.js +++ b/components/form/builder/src/Input/index.js @@ -20,19 +20,7 @@ const INPUT_MODES = { DECIMAL: 'decimal' } -const Input = ({ - input, - tabIndex, - onChange, - onFocus, - onBlur, - size, - leftAddon, - rightAddon, - errors, - alerts, - renderer -}) => { +const Input = ({input, tabIndex, onChange, onFocus, onBlur, size, leftAddon, rightAddon, errors, alerts, renderer}) => { const errorMessages = errors[input.id] const alertMessages = alerts[input.id] @@ -151,9 +139,7 @@ const Input = ({ // render SUI component return ( -
    +
    ) diff --git a/components/form/builder/src/MultiButton/index.js b/components/form/builder/src/MultiButton/index.js index da611e1ee..f97a0cec6 100644 --- a/components/form/builder/src/MultiButton/index.js +++ b/components/form/builder/src/MultiButton/index.js @@ -7,23 +7,12 @@ import MoleculeField from '@s-ui/react-molecule-field' import {createComponentMemo, field} from '../prop-types' -const MultiButton = ({ - alerts, - errors, - multiButton, - onBlur, - onChange, - onFocus, - renderer, - tabIndex -}) => { +const MultiButton = ({alerts, errors, multiButton, onBlur, onChange, onFocus, renderer, tabIndex}) => { const errorMessages = errors[multiButton.id] const alertMessages = alerts[multiButton.id] const onClickCallback = ({value, checked}) => { - const newValue = checked - ? multiButton.value?.filter(id => id !== value) - : [...(multiButton.value || []), value] + const newValue = checked ? multiButton.value?.filter(id => id !== value) : [...(multiButton.value || []), value] return onChange(multiButton.id, newValue) } @@ -66,9 +55,7 @@ const MultiButton = ({ // render SUI component return (
    diff --git a/components/form/builder/src/Multicheckbox/index.js b/components/form/builder/src/Multicheckbox/index.js index b4c425520..10df83e75 100644 --- a/components/form/builder/src/Multicheckbox/index.js +++ b/components/form/builder/src/Multicheckbox/index.js @@ -8,16 +8,7 @@ import MoleculeField from '@s-ui/react-molecule-field' import IconCheck from '../Icons/IconCheck' import {createComponentMemo, field} from '../prop-types' -const Multipicker = ({ - multipicker, - tabIndex, - onChange, - onFocus, - onBlur, - errors, - alerts, - renderer -}) => { +const Multipicker = ({multipicker, tabIndex, onChange, onFocus, onBlur, errors, alerts, renderer}) => { const errorMessages = errors[multipicker.id] const alertMessages = alerts[multipicker.id] @@ -79,9 +70,7 @@ const Multipicker = ({ // render SUI component return (
    {multipicker.datalist.map(item => ( diff --git a/components/form/builder/src/PickerSlider/index.js b/components/form/builder/src/PickerSlider/index.js index ce0ec6589..4cbda5d5d 100644 --- a/components/form/builder/src/PickerSlider/index.js +++ b/components/form/builder/src/PickerSlider/index.js @@ -8,21 +8,9 @@ import MoleculeField from '@s-ui/react-molecule-field' import {createComponentMemo} from '../prop-types/index.js' -const PickerSlider = ({ - slider, - onChange, - onFocus, - onBlur, - errors, - alerts, - renderer -}) => { +const PickerSlider = ({slider, onChange, onFocus, onBlur, errors, alerts, renderer}) => { const {id, datalist} = slider - const className = cx( - 'sui-FormBuilder-field', - 'sui-FormBuilder-PickerSlider', - `sui-FormBuilder-${id}` - ) + const className = cx('sui-FormBuilder-field', 'sui-FormBuilder-PickerSlider', `sui-FormBuilder-${id}`) const min = 0 const max = datalist.length - 1 const value = datalist.findIndex(data => data.value === slider.value) diff --git a/components/form/builder/src/ProxyField/index.js b/components/form/builder/src/ProxyField/index.js index aeec2852f..229c536de 100644 --- a/components/form/builder/src/ProxyField/index.js +++ b/components/form/builder/src/ProxyField/index.js @@ -12,16 +12,7 @@ import RangeField from '../Standard/Fields/Range/index.js' import TextField from '../Standard/Fields/Text/index.js' import {FIELDS} from '../Standard/index.js' -const ProxyField = ({ - field, - tabIndex, - onChange, - onFocus, - onBlur, - errors, - alerts, - renderer -}) => { +const ProxyField = ({field, tabIndex, onChange, onFocus, onBlur, errors, alerts, renderer}) => { let Field switch (field.type) { case FIELDS.TEXT: diff --git a/components/form/builder/src/Radio/index.js b/components/form/builder/src/Radio/index.js index c7b50848a..f196eb68e 100644 --- a/components/form/builder/src/Radio/index.js +++ b/components/form/builder/src/Radio/index.js @@ -49,14 +49,8 @@ const Radio = ({radio, tabIndex, onChange, errors, alerts, renderer}) => { if (isValidElement(rendererResponse)) return rendererResponse // render SUI component return ( -
    - {radio.label && ( - - )} +
    + {radio.label && } { onChangeHandler(value) diff --git a/components/form/builder/src/Range/Default/index.js b/components/form/builder/src/Range/Default/index.js index abde3c94a..ea8663002 100644 --- a/components/form/builder/src/Range/Default/index.js +++ b/components/form/builder/src/Range/Default/index.js @@ -19,16 +19,7 @@ const splitInputValues = inputValues => { } } -const DefaultRange = ({ - range, - tabIndex, - onChange, - onFocus, - onBlur, - errors, - alerts, - renderer -}) => { +const DefaultRange = ({range, tabIndex, onChange, onFocus, onBlur, errors, alerts, renderer}) => { const fromInputId = `${range.id}-from` const toInputId = `${range.id}-to` @@ -107,23 +98,13 @@ const DefaultRange = ({ : inputValues return ( -
    +
    - +
    - +
    {children} diff --git a/components/form/builder/src/Select/Autosuggest/index.js b/components/form/builder/src/Select/Autosuggest/index.js index f25b97849..3139331f7 100644 --- a/components/form/builder/src/Select/Autosuggest/index.js +++ b/components/form/builder/src/Select/Autosuggest/index.js @@ -15,23 +15,11 @@ const fromValueToText = datalist => value => { } const fromTextToValue = datalist => text => { - const item = datalist.find( - item => item.text.toLowerCase() === text.toLowerCase() - ) + const item = datalist.find(item => item.text.toLowerCase() === text.toLowerCase()) return item?.value } -const AutosuggestSelect = ({ - select, - tabIndex, - onChange, - onFocus, - onBlur, - size, - errors, - alerts, - renderer -}) => { +const AutosuggestSelect = ({select, tabIndex, onChange, onFocus, onBlur, size, errors, alerts, renderer}) => { const errorMessages = errors[select.id] || [] const alertMessages = alerts[select.id] || [] @@ -43,8 +31,7 @@ const AutosuggestSelect = ({ // case: a value is forced from outside the component // if text from prop is different from current local state text, update local text state - if (textFromValueProp && textFromValueProp !== localStateText) - setLocalStateText(textFromValueProp) + if (textFromValueProp && textFromValueProp !== localStateText) setLocalStateText(textFromValueProp) const onChangeCallback = useCallback( (evt, {value: text}) => { @@ -82,11 +69,7 @@ const AutosuggestSelect = ({ const normalize = str => removeAccents(str.toLowerCase()).replace(/\W|_/g) const getSuggestions = suggestionText => - suggestionText - ? datalist.filter(({text, value}) => - normalize(text).match(normalize(suggestionText)) - ) - : datalist + suggestionText ? datalist.filter(({text, value}) => normalize(text).match(normalize(suggestionText))) : datalist const suggestions = getSuggestions(localStateText) @@ -97,10 +80,7 @@ const AutosuggestSelect = ({ * - There are no other errors involved */ const showEmptySuggestionText = - !suggestions.length && - !!localStateText && - select.emptySuggestionText && - !errorMessages.length + !suggestions.length && !!localStateText && select.emptySuggestionText && !errorMessages.length if (showEmptySuggestionText) { errorMessages.push(select.emptySuggestionText) @@ -153,9 +133,7 @@ const AutosuggestSelect = ({ // render SUI component return ( -
    +
    {autosuggestProps.label && (