From 5da2e9a5e28c6af71ee01c9d3c537ff2fb9896fd Mon Sep 17 00:00:00 2001 From: kamilkifer <47425451+kamilkifer@users.noreply.github.com> Date: Mon, 20 May 2024 10:07:59 +0100 Subject: [PATCH] style: linting fixes --- src/index.ts | 2 +- src/main.ts | 8 +++++--- src/ui.dev.ts | 26 +++++++++++++++----------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/index.ts b/src/index.ts index 379637b..0acaa54 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,7 @@ import { import { SplitTest } from './splitTest'; import { uiFactory } from './ui'; import { CookiePersister } from './userSessionPersister'; -import type { UserSessionPersister } from "./userSessionPersister"; +import type { UserSessionPersister } from './userSessionPersister'; const ui = uiFactory( testsObservable, diff --git a/src/main.ts b/src/main.ts index 161d3db..50f5dea 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,7 +36,7 @@ export function config(userConfig: Partial = {}) { _config.sessionPersister = userConfig.sessionPersister; _config.sessionPersister.saveUserSession( session, - _config.userSessionDaysToLive + _config.userSessionDaysToLive, ); } configLoaded = true; @@ -130,8 +130,10 @@ export function reset(): void { const waitUntil = (condition: () => any, checkInterval = 100) => { return new Promise((resolve) => { - let interval = setInterval(() => { - if (!condition()) return; + const interval = setInterval(() => { + if (!condition()) { + return; + } clearInterval(interval); resolve(); }, checkInterval); diff --git a/src/ui.dev.ts b/src/ui.dev.ts index 61beda7..299dfe8 100644 --- a/src/ui.dev.ts +++ b/src/ui.dev.ts @@ -27,7 +27,7 @@ export const uiFactory = ( } function renderLink(splitTest: SplitTest, variation: InternalVariation) { - return renderButton("currently active", () => { + return renderButton('currently active', () => { const button = document.createElement('button'); button.value = splitTest.getVariationUrl(variation.name); document.body.appendChild(button); @@ -56,7 +56,7 @@ export const uiFactory = ( ) { const item = document.createElement('li'); item.textContent = variation.name; - const open = renderButton("change to this variant", () => { + const open = renderButton('change to this variant', () => { setCurrentTestVariation(splitTest.name, variation.name); }); @@ -88,8 +88,8 @@ export const uiFactory = ( .map( (key) => `
- ${key} - ${data[key]} + ${key} + ${data[key]}
`, ) @@ -108,11 +108,11 @@ export const uiFactory = ( if (currentVariation.name === variation.name) { return list.appendChild( renderSelectedVaraition(splitTest, variation), - ).className = "ab-test-variants"; + ).className = 'ab-test-variants'; } else { return list.appendChild( renderUnselectedVariation(splitTest, variation), - ).className = "ab-test-variants"; + ).className = 'ab-test-variants'; } }); @@ -120,17 +120,21 @@ export const uiFactory = ( variations.appendChild(list); return [test, variations]; - } - // ** Unsure what this does, when uncommented, renders a list of the same test multiple times, saying "not initialised" - perhaps the tests get mounted multiple times? ** + } + /* Unsure what this does, when uncommented, + renders a list of the same test multiple times, + saying 'not initialised' + - perhaps the tests get mounted multiple times? */ + // else { // const canRun = await splitTest.shouldRun(getUserAgentInfo()); // const test = document.createElement('div'); // test.className = 'test'; // test.innerHTML = ` - //
Test ${splitTest.name} is not initialized
+ //
Test ${splitTest.name} is not initialized
//
- // Can run - // ${canRun} + // Can run + // ${canRun} //
// `;