Skip to content

Commit 0082e41

Browse files
committed
Style: Fix various eslint warnings and errors
1 parent 096b6bd commit 0082e41

File tree

2 files changed

+35
-51
lines changed

2 files changed

+35
-51
lines changed

src/LmcCookieConsentManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,18 @@ const LmcCookieConsentManager: CookieConsentManager = (serviceName, args) => {
132132
cookie_name: cookieName, // Predefined cookie name. Do not override.
133133
current_lang: defaultLang, // Default language used when auto_language is false (or when autodetect failed)
134134
delay: 0, // Show the modal immediately after init
135-
force_consent: displayMode == DisplayMode.FORCE,
135+
force_consent: displayMode === DisplayMode.FORCE,
136136
hide_from_bots: true, // To be hidden also from Selenium
137137
page_scripts: true, // Manage third-party scripts loaded using <script>
138138
use_rfc_cookie: true, // Store cookie content in RFC compatible format.
139139
gui_options: {
140140
consent_modal: {
141141
layout:
142-
displayMode == DisplayMode.FORCE
142+
displayMode === DisplayMode.FORCE
143143
? VanillaCookieConsent.GuiConsentLayout.BOX
144144
: VanillaCookieConsent.GuiConsentLayout.BAR,
145145
position:
146-
displayMode == DisplayMode.FORCE
146+
displayMode === DisplayMode.FORCE
147147
? VanillaCookieConsent.GuiConsentPosition.MIDDLE_CENTER
148148
: VanillaCookieConsent.GuiConsentPosition.BOTTOM_CENTER,
149149
transition: VanillaCookieConsent.Transition.SLIDE, // zoom/slide

src/utils.ts

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,101 +38,85 @@ export const assembleSecondaryButton = (
3838
secondaryButtonMode: Values<typeof SecondaryButtonMode>,
3939
textAcceptNecessary: string,
4040
textShowSettings: string,
41-
): VanillaCookieConsent.ModalSecondaryButton => {
42-
return {
43-
text: secondaryButtonMode === SecondaryButtonMode.ACCEPT_NECESSARY ? textAcceptNecessary : textShowSettings,
44-
role:
45-
secondaryButtonMode === SecondaryButtonMode.ACCEPT_NECESSARY
46-
? VanillaCookieConsent.SecondaryButtonRole.ACCEPT_NECESSARY
47-
: VanillaCookieConsent.SecondaryButtonRole.SETTINGS,
48-
};
49-
};
41+
): VanillaCookieConsent.ModalSecondaryButton => ({
42+
text: secondaryButtonMode === SecondaryButtonMode.ACCEPT_NECESSARY ? textAcceptNecessary : textShowSettings,
43+
role:
44+
secondaryButtonMode === SecondaryButtonMode.ACCEPT_NECESSARY
45+
? VanillaCookieConsent.SecondaryButtonRole.ACCEPT_NECESSARY
46+
: VanillaCookieConsent.SecondaryButtonRole.SETTINGS,
47+
});
5048

51-
export const isSettingsButtonNotShown = (secondaryButtonMode: Values<typeof SecondaryButtonMode>): boolean => {
52-
return secondaryButtonMode !== SecondaryButtonMode.SHOW_SETTINGS;
53-
};
49+
export const isSettingsButtonNotShown = (secondaryButtonMode: Values<typeof SecondaryButtonMode>): boolean =>
50+
secondaryButtonMode !== SecondaryButtonMode.SHOW_SETTINGS;
51+
52+
const assembleCategoryBlock = (
53+
category: CookieConsentCategoryValues,
54+
title: string,
55+
description: string,
56+
readonly: boolean,
57+
cookieTableItems: VanillaCookieConsent.CookieTableItem[] | undefined,
58+
): VanillaCookieConsent.ModalBlock => ({
59+
title,
60+
description,
61+
toggle: { value: category, enabled: readonly, readonly },
62+
...(typeof cookieTableItems !== 'undefined' && { cookie_table: cookieTableItems }),
63+
});
5464

5565
export const assembleCategoryNecessary = (
5666
title: string,
5767
description: string,
5868
cookieTable: CookieTableCategories,
59-
): VanillaCookieConsent.ModalBlock => {
60-
return assembleCategoryBlock(
69+
): VanillaCookieConsent.ModalBlock =>
70+
assembleCategoryBlock(
6171
CookieConsentCategory.NECESSARY,
6272
title,
6373
description,
6474
true,
6575
cookieTable[CookieConsentCategory.NECESSARY],
6676
);
67-
};
6877

6978
export const assembleCategoryAd = (
7079
title: string,
7180
description: string,
7281
cookieTable: CookieTableCategories,
73-
): VanillaCookieConsent.ModalBlock => {
74-
return assembleCategoryBlock(
75-
CookieConsentCategory.AD,
76-
title,
77-
description,
78-
false,
79-
cookieTable[CookieConsentCategory.AD],
80-
);
81-
};
82+
): VanillaCookieConsent.ModalBlock =>
83+
assembleCategoryBlock(CookieConsentCategory.AD, title, description, false, cookieTable[CookieConsentCategory.AD]);
8284

8385
export const assembleCategoryAnalytics = (
8486
title: string,
8587
description: string,
8688
cookieTable: CookieTableCategories,
87-
): VanillaCookieConsent.ModalBlock => {
88-
return assembleCategoryBlock(
89+
): VanillaCookieConsent.ModalBlock =>
90+
assembleCategoryBlock(
8991
CookieConsentCategory.ANALYTICS,
9092
title,
9193
description,
9294
false,
9395
cookieTable[CookieConsentCategory.ANALYTICS],
9496
);
95-
};
9697

9798
export const assembleCategoryFunctionality = (
9899
title: string,
99100
description: string,
100101
cookieTable: CookieTableCategories,
101-
): VanillaCookieConsent.ModalBlock => {
102-
return assembleCategoryBlock(
102+
): VanillaCookieConsent.ModalBlock =>
103+
assembleCategoryBlock(
103104
CookieConsentCategory.FUNCTIONALITY,
104105
title,
105106
description,
106107
false,
107108
cookieTable[CookieConsentCategory.FUNCTIONALITY],
108109
);
109-
};
110110

111111
export const assembleCategoryPersonalization = (
112112
title: string,
113113
description: string,
114114
cookieTable: CookieTableCategories,
115-
): VanillaCookieConsent.ModalBlock => {
116-
return assembleCategoryBlock(
115+
): VanillaCookieConsent.ModalBlock =>
116+
assembleCategoryBlock(
117117
CookieConsentCategory.PERSONALIZATION,
118118
title,
119119
description,
120120
false,
121121
cookieTable[CookieConsentCategory.PERSONALIZATION],
122122
);
123-
};
124-
125-
const assembleCategoryBlock = (
126-
category: CookieConsentCategoryValues,
127-
title: string,
128-
description: string,
129-
readonly: boolean,
130-
cookieTableItems: VanillaCookieConsent.CookieTableItem[] | undefined,
131-
): VanillaCookieConsent.ModalBlock => {
132-
return {
133-
title,
134-
description,
135-
toggle: { value: category, enabled: readonly, readonly },
136-
...(cookieTableItems !== undefined && { cookie_table: cookieTableItems }),
137-
};
138-
};

0 commit comments

Comments
 (0)