Skip to content

Commit

Permalink
style: linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkifer committed May 20, 2024
1 parent c147f6e commit 5da2e9a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function config(userConfig: Partial<Config> = {}) {
_config.sessionPersister = userConfig.sessionPersister;
_config.sessionPersister.saveUserSession(
session,
_config.userSessionDaysToLive
_config.userSessionDaysToLive,
);
}
configLoaded = true;
Expand Down Expand Up @@ -130,8 +130,10 @@ export function reset(): void {

const waitUntil = (condition: () => any, checkInterval = 100) => {
return new Promise<void>((resolve) => {
let interval = setInterval(() => {
if (!condition()) return;
const interval = setInterval(() => {
if (!condition()) {
return;
}
clearInterval(interval);
resolve();
}, checkInterval);
Expand Down
26 changes: 15 additions & 11 deletions src/ui.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -88,8 +88,8 @@ export const uiFactory = (
.map(
(key) => `
<div>
<span class="data-label">${key}</span>
<span class="data-value">${data[key]}</span>
<span class='data-label'>${key}</span>
<span class='data-value'>${data[key]}</span>
</div>
`,
)
Expand All @@ -108,29 +108,33 @@ 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';
}
});

variations.appendChild(legend);
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 = `
// <div>Test <span class="data-value">${splitTest.name}</span> is not initialized</div>
// <div>Test <span class='data-value'>${splitTest.name}</span> is not initialized</div>
// <div>
// <span class="data-label">Can run</span>
// <span class="data-value">${canRun}</span>
// <span class='data-label'>Can run</span>
// <span class='data-value'>${canRun}</span>
// </div>
// `;

Expand Down

0 comments on commit 5da2e9a

Please sign in to comment.