Skip to content

Commit

Permalink
fix lint infrastructure problems
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Nov 1, 2022
1 parent d5dd140 commit 6eaf1a0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 61 deletions.
112 changes: 56 additions & 56 deletions tests/manual/js/theme-chooser.js
@@ -1,149 +1,149 @@

function initThemeChooser(settings) {
var isInitialized = false;
var currentThemeSystem; // don't set this directly. use setThemeSystem
var currentStylesheetEl;
var loadingEl = document.getElementById('loading');
var systemSelectEl = document.querySelector('#theme-system-selector select');
var isInitialized = false
var currentThemeSystem // don't set this directly. use setThemeSystem
var currentStylesheetEl
var loadingEl = document.getElementById('loading')
var systemSelectEl = document.querySelector('#theme-system-selector select')
var themeSelectWrapEls = Array.prototype.slice.call( // convert to real array
document.querySelectorAll('.selector[data-theme-system]')
);
document.querySelectorAll('.selector[data-theme-system]'),
)

systemSelectEl.addEventListener('change', function() {
setThemeSystem(this.value);
});
setThemeSystem(this.value)
})

setThemeSystem(systemSelectEl.value);
setThemeSystem(systemSelectEl.value)

themeSelectWrapEls.forEach(function(themeSelectWrapEl) {
var themeSelectEl = themeSelectWrapEl.querySelector('select');
var themeSelectEl = themeSelectWrapEl.querySelector('select')

themeSelectWrapEl.addEventListener('change', function() {
setTheme(
currentThemeSystem,
themeSelectEl.options[themeSelectEl.selectedIndex].value
);
});
});
themeSelectEl.options[themeSelectEl.selectedIndex].value,
)
})
})


function setThemeSystem(themeSystem) {
var selectedTheme;
var selectedTheme

currentThemeSystem = themeSystem;
currentThemeSystem = themeSystem

themeSelectWrapEls.forEach(function(themeSelectWrapEl) {
var themeSelectEl = themeSelectWrapEl.querySelector('select');
var themeSelectEl = themeSelectWrapEl.querySelector('select')
var themeSystems = (themeSelectWrapEl.getAttribute('data-theme-system') || '').split(',')

if (themeSystems.includes(themeSystem)) {
selectedTheme = themeSelectEl.options[themeSelectEl.selectedIndex].value;
themeSelectWrapEl.style.display = 'inline-block';
selectedTheme = themeSelectEl.options[themeSelectEl.selectedIndex].value
themeSelectWrapEl.style.display = 'inline-block'
} else {
themeSelectWrapEl.style.display = 'none';
themeSelectWrapEl.style.display = 'none'
}
});
})

setTheme(themeSystem, selectedTheme);
setTheme(themeSystem, selectedTheme)
}


function setTheme(themeSystem, themeName) {
var stylesheetUrl = generateStylesheetUrl(themeSystem, themeName);
var stylesheetEl;
var stylesheetUrl = generateStylesheetUrl(themeSystem, themeName)
var stylesheetEl

function done() {
if (!isInitialized) {
isInitialized = true;
settings.init(themeSystem);
isInitialized = true
settings.init(themeSystem)
}
else {
settings.change(themeSystem);
settings.change(themeSystem)
}

showCredits(themeSystem, themeName);
showCredits(themeSystem, themeName)
}

if (stylesheetUrl) {
stylesheetEl = document.createElement('link');
stylesheetEl.setAttribute('rel', 'stylesheet');
stylesheetEl.setAttribute('href', stylesheetUrl);
document.querySelector('head').appendChild(stylesheetEl);
stylesheetEl = document.createElement('link')
stylesheetEl.setAttribute('rel', 'stylesheet')
stylesheetEl.setAttribute('href', stylesheetUrl)
document.querySelector('head').appendChild(stylesheetEl)

loadingEl.style.display = 'inline';
loadingEl.style.display = 'inline'

whenStylesheetLoaded(stylesheetEl, function() {
if (currentStylesheetEl) {
currentStylesheetEl.parentNode.removeChild(currentStylesheetEl);
currentStylesheetEl.parentNode.removeChild(currentStylesheetEl)
}
currentStylesheetEl = stylesheetEl;
loadingEl.style.display = 'none';
done();
});
currentStylesheetEl = stylesheetEl
loadingEl.style.display = 'none'
done()
})
} else {
if (currentStylesheetEl) {
currentStylesheetEl.parentNode.removeChild(currentStylesheetEl);
currentStylesheetEl.parentNode.removeChild(currentStylesheetEl)
currentStylesheetEl = null
}
done();
done()
}
}


function generateStylesheetUrl(themeSystem, themeName) {
if (themeSystem === 'bootstrap') {
if (themeName) {
return 'https://bootswatch.com/4/' + themeName + '/bootstrap.min.css';
return 'https://bootswatch.com/4/' + themeName + '/bootstrap.min.css'
}
else { // the default bootstrap theme
return 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css';
return 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css'
}
} else if (themeSystem === 'bootstrap5') {
if (themeName) {
return 'https://bootswatch.com/5/' + themeName + '/bootstrap.min.css';
return 'https://bootswatch.com/5/' + themeName + '/bootstrap.min.css'
}
else { // the default bootstrap theme
return 'https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css';
return 'https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css'
}
}
}


function showCredits(themeSystem, themeName) {
var creditId;
var creditId

if (themeSystem.match('bootstrap')) {
if (themeName) {
creditId = 'bootstrap-custom';
creditId = 'bootstrap-custom'
}
else {
creditId = 'bootstrap-standard';
creditId = 'bootstrap-standard'
}
}

Array.prototype.slice.call( // convert to real array
document.querySelectorAll('.credits')
document.querySelectorAll('.credits'),
).forEach(function(creditEl) {
if (creditEl.getAttribute('data-credit-id') === creditId) {
creditEl.style.display = 'block';
creditEl.style.display = 'block'
} else {
creditEl.style.display = 'none';
creditEl.style.display = 'none'
}
})
}


function whenStylesheetLoaded(linkNode, callback) {
var isReady = false;
var isReady = false

function ready() {
if (!isReady) { // avoid double-call
isReady = true;
callback();
isReady = true
callback()
}
}

linkNode.onload = ready; // does not work cross-browser
setTimeout(ready, 2000); // max wait. also handles browsers that don't support onload
linkNode.onload = ready // does not work cross-browser
setTimeout(ready, 2000) // max wait. also handles browsers that don't support onload
}
}
10 changes: 5 additions & 5 deletions tests/scripts/generate-index-iife.js
Expand Up @@ -11,9 +11,9 @@ export default async function main() {
const srcDir = resolvePath('./src') // HACK: works when called from other test dirs

let testPaths = await capture(
"find . -mindepth 2 -type f \\( -name '*.ts' -or -name '*.tsx' \\) -print0 | " +
'find . -mindepth 2 -type f \\( -name \'*.ts\' -or -name \'*.tsx\' \\) -print0 | ' +
'xargs -0 grep -E "(fdescribe|fit)\\("',
{ cwd: srcDir }
{ cwd: srcDir },
).then(
(res) => strToLines(res.stdout).map((line) => line.trim().split(':')[0]),
() => [], // TODO: somehow look at stderr string. if empty, simply no testPaths. if populated, real error
Expand All @@ -22,12 +22,12 @@ export default async function main() {
if (testPaths.length) {
console.log(
'Only test files that have fdescribe/fit:\n' +
testPaths.map((path) => ` - ${path}`).join('\n')
testPaths.map((path) => ` - ${path}`).join('\n'),
)
} else {
testPaths = strToLines((await capture(
"find . -mindepth 2 -type f \\( -name '*.ts' -or -name '*.tsx' \\)",
{ cwd: srcDir }
'find . -mindepth 2 -type f \\( -name \'*.ts\' -or -name \'*.tsx\' \\)',
{ cwd: srcDir },
)).stdout)

console.log(`Using all ${testPaths.length} test files.`)
Expand Down
1 change: 1 addition & 0 deletions tests/src/lib/ListenerCounter.ts
Expand Up @@ -12,6 +12,7 @@ export class ListenerCounter {
}

startWatching() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
let t = this
let el = t.el
let origAddEventListened = el.addEventListener
Expand Down
1 change: 1 addition & 0 deletions tests/src/lib/globals.ts
Expand Up @@ -275,6 +275,7 @@ declare global {
sortable: any
}

// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jasmine {
interface Matchers<T> {
toEqualDate: any
Expand Down

0 comments on commit 6eaf1a0

Please sign in to comment.