diff --git a/ui/analyse/src/autoplay.ts b/ui/analyse/src/autoplay.ts index 118fd8e091da3..bfab5e0c80634 100644 --- a/ui/analyse/src/autoplay.ts +++ b/ui/analyse/src/autoplay.ts @@ -61,7 +61,7 @@ export class Autoplay { this.stop(); this.delay = delay; this.schedule(); - if (delay == 'realtime') this.redrawInterval = setInterval(this.ctrl.redraw, 100); + if (delay === 'realtime') this.redrawInterval = setInterval(this.ctrl.redraw, 100); } stop(): void { diff --git a/ui/analyse/src/ctrl.ts b/ui/analyse/src/ctrl.ts index 60db5e2af416d..50fb17bbcbfa9 100644 --- a/ui/analyse/src/ctrl.ts +++ b/ui/analyse/src/ctrl.ts @@ -205,7 +205,7 @@ export default class AnalyseCtrl { this.tree = makeTree(treeReconstruct(this.data.treeParts, this.data.sidelines)); if (prevTree) this.tree.merge(prevTree); const mainline = treeOps.mainlineNodeList(this.tree.root); - if (this.data.game.status.name == 'draw') add3or5FoldGlyphs(mainline); + if (this.data.game.status.name === 'draw') add3or5FoldGlyphs(mainline); this.autoplay = new Autoplay(this); if (this.socket) this.socket.clearCache(); @@ -251,7 +251,7 @@ export default class AnalyseCtrl { this.onMainline = this.tree.pathIsMainline(path); this.fenInput = undefined; this.pgnInput = undefined; - if (this.wiki && this.data.game.variant.key == 'standard') this.wiki(this.nodeList); + if (this.wiki && this.data.game.variant.key === 'standard') this.wiki(this.nodeList); this.persistence?.save(); }; @@ -396,7 +396,7 @@ export default class AnalyseCtrl { jump(path: Tree.Path): void { const pathChanged = path !== this.path, - isForwardStep = pathChanged && path.length == this.path.length + 2; + isForwardStep = pathChanged && path.length === this.path.length + 2; this.setPath(path); if (pathChanged) { if (this.study) this.study.setPath(path, this.node); diff --git a/ui/analyse/src/explorer/explorerConfig.ts b/ui/analyse/src/explorer/explorerConfig.ts index 76fee98055f75..43e5c09e08fcb 100644 --- a/ui/analyse/src/explorer/explorerConfig.ts +++ b/ui/analyse/src/explorer/explorerConfig.ts @@ -91,9 +91,9 @@ export class ExplorerConfigCtrl { } selectPlayer = (name?: string) => { - name = name == 'me' ? this.myName : name; + name = name === 'me' ? this.myName : name; if (!name) return; - if (name != this.myName && !this.participants.includes(name)) { + if (name !== this.myName && !this.participants.includes(name)) { const previous = this.data.playerName.previous().filter(n => n !== name); previous.unshift(name); this.data.playerName.previous(previous.slice(0, 20)); @@ -125,7 +125,7 @@ export class ExplorerConfigCtrl { toggleOpen = () => { this.data.open(!this.data.open()); if (!this.data.open()) { - if (this.data.db() == 'player' && !this.data.playerName.value()) this.data.db('lichess'); + if (this.data.db() === 'player' && !this.data.playerName.value()) this.data.db('lichess'); this.onClose(); } }; @@ -133,9 +133,9 @@ export class ExplorerConfigCtrl { fullHouse = () => this.data.byDb().since() <= `${minYear}-01` && (!this.data.byDb().until() || new Date().toISOString().slice(0, 7) <= this.data.byDb().until()) && - (this.data.db() === 'masters' || this.data.speed().length == allSpeeds.length) && - (this.data.db() !== 'lichess' || this.data.rating().length == allRatings.length) && - (this.data.db() !== 'player' || this.data.mode().length == allModes.length); + (this.data.db() === 'masters' || this.data.speed().length === allSpeeds.length) && + (this.data.db() !== 'lichess' || this.data.rating().length === allRatings.length) && + (this.data.db() !== 'player' || this.data.mode().length === allModes.length); } export function view(ctrl: ExplorerConfigCtrl): VNode[] { @@ -182,7 +182,7 @@ const playerDb = (ctrl: ExplorerConfigCtrl) => { attrs: dataIcon(licon.ChasingArrows), hook: bind('click', ctrl.toggleColor, ctrl.root.redraw), }, - ` ${i18n.site[ctrl.data.color() == 'white' ? 'asWhite' : 'asBlack']}`, + ` ${i18n.site[ctrl.data.color() === 'white' ? 'asWhite' : 'asBlack']}`, ), ]), ]), diff --git a/ui/analyse/src/explorer/explorerCtrl.ts b/ui/analyse/src/explorer/explorerCtrl.ts index ff4bbfc29d19f..aefb40c493357 100644 --- a/ui/analyse/src/explorer/explorerCtrl.ts +++ b/ui/analyse/src/explorer/explorerCtrl.ts @@ -70,12 +70,12 @@ export default class ExplorerCtrl { private checkHash = (e?: HashChangeEvent) => { const parts = location.hash.split('/'); - if (parts[0] == '#explorer' || parts[0] == '#opening') { + if (parts[0] === '#explorer' || parts[0] === '#opening') { this.enabled(true); - if (parts[1] == 'lichess' || parts[1] === 'masters') this.config.data.db(parts[1]); + if (parts[1] === 'lichess' || parts[1] === 'masters') this.config.data.db(parts[1]); else if (parts[1]?.match(/[A-Za-z0-9_-]{2,30}/)) { this.config.selectPlayer(parts[1]); - this.config.data.color(parts[2] == 'black' ? 'black' : 'white'); + this.config.data.color(parts[2] === 'black' ? 'black' : 'white'); } if (e) this.reload(); } @@ -195,7 +195,7 @@ export default class ExplorerCtrl { this.root.setAutoShapes(); }; onFlip = () => { - if (this.db() == 'player') { + if (this.db() === 'player') { this.cache = {}; this.setNode(); } @@ -218,7 +218,7 @@ export default class ExplorerCtrl { fetchTablebaseHit = async (fen: FEN): Promise => { const res = await xhr.tablebase(this.opts.tablebaseEndpoint, this.effectiveVariant, fen); const move = res.moves[0]; - if (move && move.dtz == null) throw 'unknown tablebase position'; + if (move && move.dtz === null) throw 'unknown tablebase position'; return { fen, best: move && move.uci, diff --git a/ui/analyse/src/explorer/explorerView.ts b/ui/analyse/src/explorer/explorerView.ts index 86b7727dc545f..68cb59c338298 100644 --- a/ui/analyse/src/explorer/explorerView.ts +++ b/ui/analyse/src/explorer/explorerView.ts @@ -103,7 +103,7 @@ const showResult = (winner?: Color): VNode => function showGameTable(ctrl: AnalyseCtrl, fen: FEN, title: string, games: OpeningGame[]): VNode | null { if (!ctrl.explorer.withGames || !games.length) return null; const openedId = ctrl.explorer.gameMenu(), - isMasters = ctrl.explorer.db() == 'masters'; + isMasters = ctrl.explorer.db() === 'masters'; return h('table.games', [ h('thead', [h('tr', [h('th.title', { attrs: { colspan: isMasters ? 4 : 5 } }, title)])]), h( @@ -162,7 +162,7 @@ function gameActions(ctrl: AnalyseCtrl, game: OpeningGame): VNode { ctrl.redraw(); }; return h('tr', { key: game.id + '-m' }, [ - h('td.game_menu', { attrs: { colspan: ctrl.explorer.db() == 'masters' ? 4 : 5 } }, [ + h('td.game_menu', { attrs: { colspan: ctrl.explorer.db() === 'masters' ? 4 : 5 } }, [ h( 'div.game_title', `${game.white.name} - ${game.black.name}, ${showResult(game.winner).text}, ${game.year}`, @@ -263,7 +263,7 @@ function show(ctrl: AnalyseCtrl): MaybeVNode { data.fen, title, tooltip, - data.moves.filter(m => m.category == category), + data.moves.filter(m => m.category === category), ); if (data.moves.length) lastShow = h('div.data', [ @@ -320,7 +320,7 @@ const explorerTitle = (explorer: ExplorerCtrl) => { 'span.active.text.' + db, { attrs: { title, ...dataIcon(licon.Book) }, - hook: db == 'player' ? bind('click', explorer.config.toggleColor, explorer.reload) : undefined, + hook: db === 'player' ? bind('click', explorer.config.toggleColor, explorer.reload) : undefined, }, nodes, ); @@ -330,18 +330,18 @@ const explorerTitle = (explorer: ExplorerCtrl) => { const data = explorer.current(); const queuePosition = data && isOpening(data) && data.queuePosition; return h('div.explorer-title', [ - db == 'masters' + db === 'masters' ? active([h('strong', 'Masters'), ' database'], masterDbExplanation) : explorer.config.allDbs.includes('masters') && otherLink('Masters', masterDbExplanation), - db == 'lichess' + db === 'lichess' ? active([h('strong', 'Lichess'), ' database'], lichessDbExplanation) : otherLink('Lichess', lichessDbExplanation), - db == 'player' + db === 'player' ? playerName ? active( [ h(`strong${playerName.length > 14 ? '.long' : ''}`, playerName), - ` ${i18n.site[explorer.config.data.color() == 'white' ? 'asWhite' : 'asBlack']}`, + ` ${i18n.site[explorer.config.data.color() === 'white' ? 'asWhite' : 'asBlack']}`, explorer.isIndexing() && !explorer.config.data.open() && h('i.ddloader', { diff --git a/ui/analyse/src/ground.ts b/ui/analyse/src/ground.ts index cea2d37e544ab..83271f82a5c56 100644 --- a/ui/analyse/src/ground.ts +++ b/ui/analyse/src/ground.ts @@ -16,7 +16,7 @@ export const render = (ctrl: AnalyseCtrl): VNode => export function promote(ground: CgApi, key: Key, role: Role) { const piece = ground.state.pieces.get(key); - if (piece && piece.role == 'pawn') { + if (piece && piece.role === 'pawn') { ground.setPieces(new Map([[key, { color: piece.color, role, promoted: true }]])); } } diff --git a/ui/analyse/src/keyboard.ts b/ui/analyse/src/keyboard.ts index c1d08160dbfd6..f170fb024f549 100644 --- a/ui/analyse/src/keyboard.ts +++ b/ui/analyse/src/keyboard.ts @@ -132,7 +132,7 @@ export const bind = (ctrl: AnalyseCtrl) => { for (let i = 1; i < 7; i++) kbd.bind(i.toString(), () => ctrl.study?.glyphForm.toggleGlyph(i)); // = ∞ ⩲ ⩱ ± ∓ +- -+ for (let i = 1; i < 9; i++) - kbd.bind(`shift+${i}`, () => ctrl.study?.glyphForm.toggleGlyph(i == 1 ? 10 : 11 + i)); + kbd.bind(`shift+${i}`, () => ctrl.study?.glyphForm.toggleGlyph(i === 1 ? 10 : 11 + i)); } }; diff --git a/ui/analyse/src/retrospect/retroCtrl.ts b/ui/analyse/src/retrospect/retroCtrl.ts index 894bb75172157..967cdb0edf142 100644 --- a/ui/analyse/src/retrospect/retroCtrl.ts +++ b/ui/analyse/src/retrospect/retroCtrl.ts @@ -58,7 +58,7 @@ export function make(root: AnalyseCtrl, color: Color): RetroCtrl { } function findNextNode(): Tree.Node | undefined { - const colorModulo = color == 'white' ? 1 : 0; + const colorModulo = color === 'white' ? 1 : 0; candidateNodes = evalSwings( root.mainline, n => n.ply % 2 === colorModulo && !explorerCancelPlies.includes(n.ply), @@ -248,7 +248,7 @@ export function make(root: AnalyseCtrl, color: Color): RetroCtrl { }, preventGoingToNextMove: () => { const cur = current(); - return isSolving() && !!cur && root.path == cur.prev.path; + return isSolving() && !!cur && root.path === cur.prev.path; }, close: root.toggleRetro, node: () => root.node, diff --git a/ui/analyse/src/serverSideUnderboard.ts b/ui/analyse/src/serverSideUnderboard.ts index 8c8ce8a69ae29..6b2ef4d74a361 100644 --- a/ui/analyse/src/serverSideUnderboard.ts +++ b/ui/analyse/src/serverSideUnderboard.ts @@ -91,12 +91,12 @@ export default function (element: HTMLElement, ctrl: AnalyseCtrl) { .removeClass('active') .filter('.' + panel) .addClass('active'); - if ((panel == 'move-times' || ctrl.opts.hunter) && !timeChartLoaded) + if ((panel === 'move-times' || ctrl.opts.hunter) && !timeChartLoaded) site.asset.loadEsm('chart.game').then(m => { timeChartLoaded = true; m.movetime($('#movetimes-chart')[0] as HTMLCanvasElement, data, ctrl.opts.hunter); }); - if ((panel == 'computer-analysis' || ctrl.opts.hunter) && $('#acpl-chart-container').length) + if ((panel === 'computer-analysis' || ctrl.opts.hunter) && $('#acpl-chart-container').length) setTimeout(startAdvantageChart, 200); }; $menu.on('mousedown', 'span', function (this: HTMLElement) { diff --git a/ui/analyse/src/study/chapterNewForm.ts b/ui/analyse/src/study/chapterNewForm.ts index 3fbb5a5200d69..5567b92a3c93a 100644 --- a/ui/analyse/src/study/chapterNewForm.ts +++ b/ui/analyse/src/study/chapterNewForm.ts @@ -64,7 +64,7 @@ export class StudyChapterNewForm { setTab = (key: ChapterTab) => { this.tab(key); - if (key != 'pgn' && this.orientation == 'automatic') this.orientation = 'white'; + if (key != 'pgn' && this.orientation === 'automatic') this.orientation = 'white'; this.root.redraw(); }; diff --git a/ui/analyse/src/study/gamebook/gamebookPlayView.ts b/ui/analyse/src/study/gamebook/gamebookPlayView.ts index 73d3dd01237af..782052a2e3745 100644 --- a/ui/analyse/src/study/gamebook/gamebookPlayView.ts +++ b/ui/analyse/src/study/gamebook/gamebookPlayView.ts @@ -6,15 +6,15 @@ import { richHTML } from 'common/richText'; export function render(ctrl: GamebookPlayCtrl): VNode { const state = ctrl.state; return h('div.gamebook', { hook: { insert: _ => site.asset.loadCssPath('analyse.gamebook.play') } }, [ - (state.comment || state.feedback == 'play' || state.feedback == 'end') && + (state.comment || state.feedback === 'play' || state.feedback === 'end') && h('div.comment', { class: { hinted: state.showHint } }, [ state.comment ? h('div.content', { hook: richHTML(state.comment) }) : h( 'div.content', - state.feedback == 'play' + state.feedback === 'play' ? i18n.study.whatWouldYouPlay - : state.feedback == 'end' && i18n.study.youCompletedThisLesson, + : state.feedback === 'end' && i18n.study.youCompletedThisLesson, ), hintZone(ctrl), ]), diff --git a/ui/analyse/src/study/multiBoard.ts b/ui/analyse/src/study/multiBoard.ts index 053d90aa529b6..1e188c36fd5af 100644 --- a/ui/analyse/src/study/multiBoard.ts +++ b/ui/analyse/src/study/multiBoard.ts @@ -45,7 +45,9 @@ export class MultiBoardCtrl { private chapterFilter = (c: ChapterPreview) => { const t = this.teamSelect(); - return (!this.playing() || c.playing) && (!t || c.players?.white.team == t || c.players?.black.team == t); + return ( + (!this.playing() || c.playing) && (!t || c.players?.white.team === t || c.players?.black.team === t) + ); }; setMaxPerPage = (nb: string) => { @@ -130,7 +132,7 @@ function renderPagerNav(pager: Paginator, ctrl: MultiBoardCtrl): 'select.study__multiboard__pager__max-per-page', { hook: bind('change', (e: Event) => ctrl.setMaxPerPage((e.target as HTMLOptionElement).value)) }, [4, 6, 8, 10, 12, 16, 20, 24, 32].map(nb => - h('option', { attrs: { value: nb, selected: nb == max } }, i18n.study.perPage(nb)), + h('option', { attrs: { value: nb, selected: nb === max } }, i18n.study.perPage(nb)), ), ), ]); @@ -146,7 +148,7 @@ const teamSelector = (ctrl: MultiBoardCtrl) => { hook: bind('change', e => ctrl.teamSelect((e.target as HTMLOptionElement).value), ctrl.redraw), }, [i18n.broadcast.allTeams, ...allTeams].map((t, i) => - h('option', { attrs: { value: i ? t : '', selected: i && t == currentTeam } }, t), + h('option', { attrs: { value: i ? t : '', selected: i && t === currentTeam } }, t), ), ) : undefined; @@ -229,13 +231,13 @@ const makePreview = }; export const verticalEvalGauge = (chap: ChapterPreview, cloudEval: MultiCloudEval): MaybeVNode => { - const tag = `span.mini-game__gauge${chap.orientation == 'black' ? ' mini-game__gauge--flip' : ''}${ - chap.check == '#' ? ' mini-game__gauge--set' : '' + const tag = `span.mini-game__gauge${chap.orientation === 'black' ? ' mini-game__gauge--flip' : ''}${ + chap.check === '#' ? ' mini-game__gauge--set' : '' }`; - return chap.check == '#' + return chap.check === '#' ? h(tag, { attrs: { 'data-id': chap.id, title: 'Checkmate' } }, [ h('span.mini-game__gauge__black', { - attrs: { style: `height: ${fenColor(chap.fen) == 'white' ? 100 : 0}%` }, + attrs: { style: `height: ${fenColor(chap.fen) === 'white' ? 100 : 0}%` }, }), h('tick'), ]) @@ -276,7 +278,7 @@ const renderUser = (player: StudyPlayer): VNode => export const renderClock = (chapter: ChapterPreview, color: Color) => { const turnColor = fenColor(chapter.fen); const timeleft = computeTimeLeft(chapter, color); - const ticking = turnColor == color && otbClockIsRunning(chapter.fen); + const ticking = turnColor === color && otbClockIsRunning(chapter.fen); return defined(timeleft) ? h( 'span.mini-game__clock.mini-game__clock', @@ -289,7 +291,7 @@ export const renderClock = (chapter: ChapterPreview, color: Color) => { const computeTimeLeft = (preview: ChapterPreview, color: Color): number | undefined => { const clock = preview.players?.[color]?.clock; if (notNull(clock)) { - if (defined(preview.lastMoveAt) && fenColor(preview.fen) == color) { + if (defined(preview.lastMoveAt) && fenColor(preview.fen) === color) { const spent = (Date.now() - preview.lastMoveAt) / 1000; return Math.max(0, clock / 100 - spent); } else { diff --git a/ui/analyse/src/study/relay/relayCtrl.ts b/ui/analyse/src/study/relay/relayCtrl.ts index 26b99861ae87e..77f8aee390370 100644 --- a/ui/analyse/src/study/relay/relayCtrl.ts +++ b/ui/analyse/src/study/relay/relayCtrl.ts @@ -106,7 +106,7 @@ export default class RelayCtrl { }); }; - roundById = (id: string) => this.data.rounds.find(r => r.id == id); + roundById = (id: string) => this.data.rounds.find(r => r.id === id); currentRound = () => this.roundById(this.id)!; roundName = () => this.currentRound().name; diff --git a/ui/analyse/src/study/relay/relayGames.ts b/ui/analyse/src/study/relay/relayGames.ts index a0a0d03bf6ce2..5d7869b6ff828 100644 --- a/ui/analyse/src/study/relay/relayGames.ts +++ b/ui/analyse/src/study/relay/relayGames.ts @@ -25,13 +25,13 @@ export const gamesList = (study: StudyCtrl, relay: RelayCtrl) => { }, }, }, - chapters.length == 1 && chapters[0].name == 'Chapter 1' + chapters.length === 1 && chapters[0].name === 'Chapter 1' ? [] : chapters.map((c, i) => { const status = - !c.status || c.status == '*' ? renderClocks(c) : [c.status.slice(2, 3), c.status.slice(0, 1)]; + !c.status || c.status === '*' ? renderClocks(c) : [c.status.slice(2, 3), c.status.slice(0, 1)]; const players = [c.players?.black, c.players?.white]; - if (c.orientation == 'black') { + if (c.orientation === 'black') { players.reverse(); status.reverse(); } @@ -58,7 +58,7 @@ export const gamesList = (study: StudyCtrl, relay: RelayCtrl) => { playerFed(p.fed), h('span.name', [userTitle(p), p.name]), ]), - h(s == '1' ? 'good' : s == '0' ? 'bad' : 'status', [s]), + h(s === '1' ? 'good' : s === '0' ? 'bad' : 'status', [s]), ] : [h('span.mini-game__user', h('span.name', 'Unknown player'))], ); diff --git a/ui/analyse/src/study/relay/relayPlayers.ts b/ui/analyse/src/study/relay/relayPlayers.ts index 937b1f5c8b3ff..7eadbcf447201 100644 --- a/ui/analyse/src/study/relay/relayPlayers.ts +++ b/ui/analyse/src/study/relay/relayPlayers.ts @@ -147,7 +147,7 @@ const playerView = (ctrl: RelayPlayers, show: PlayerToShow, tour: RelayTour): VN h('div.relay-tour__player__cards', [ ...(p.fide?.ratings ? ratingCategs.map(([key, name]) => - h(`div.relay-tour__player__card${key == tc ? '.active' : ''}`, [ + h(`div.relay-tour__player__card${key === tc ? '.active' : ''}`, [ h('em', name), h('span', [p.fide?.ratings[key] || '-']), ]), @@ -368,7 +368,13 @@ const renderPlayerGames = (ctrl: RelayPlayers, p: RelayPlayerWithGames, withTips h('td.is.color-icon.' + game.color), h( 'td.tpp__games__status', - points ? (points == '1' ? h('good', '1') : points == '0' ? h('bad', '0') : h('span', '½')) : '*', + points + ? points === '1' + ? h('good', '1') + : points === '0' + ? h('bad', '0') + : h('span', '½') + : '*', ), h('td', defined(game.ratingDiff) ? ratingDiff(game) : undefined), ], diff --git a/ui/analyse/src/study/relay/relayTeams.ts b/ui/analyse/src/study/relay/relayTeams.ts index 3dbf79926d1bd..b2cea40d7abf6 100644 --- a/ui/analyse/src/study/relay/relayTeams.ts +++ b/ui/analyse/src/study/relay/relayTeams.ts @@ -90,7 +90,7 @@ const renderTeams = ( const players = chap?.players; if (!players) return; const sortedPlayers = - game.pov == 'white' ? [players.white, players.black] : [players.black, players.white]; + game.pov === 'white' ? [players.white, players.black] : [players.black, players.white]; return ( chap && h('a.relay-tour__team-match__game', { attrs: gameLinkAttrs(roundPath, chap) }, [ @@ -114,10 +114,10 @@ const playerView = (players: RelayPlayers, p: StudyPlayer) => ]); const statusView = (g: ChapterPreview, pov: Color, chapters: StudyChapters, cloudEval?: MultiCloudEval) => { - const status = pov == 'white' ? g.status : (g.status?.split('').reverse().join('') as StatusStr); + const status = pov === 'white' ? g.status : (g.status?.split('').reverse().join('') as StatusStr); return h( 'span.relay-tour__team-match__game__status', - status && status != '*' ? status : cloudEval ? evalGauge(g, pov, chapters, cloudEval) : '*', + status && status !== '*' ? status : cloudEval ? evalGauge(g, pov, chapters, cloudEval) : '*', ); }; diff --git a/ui/analyse/src/study/relay/relayTourView.ts b/ui/analyse/src/study/relay/relayTourView.ts index 2f08c7695dd56..5b27fcaf1c5ac 100644 --- a/ui/analyse/src/study/relay/relayTourView.ts +++ b/ui/analyse/src/study/relay/relayTourView.ts @@ -26,13 +26,13 @@ import { watchers } from 'common/watchers'; export function renderRelayTour(ctx: RelayViewContext): VNode | undefined { const tab = ctx.relay.tab(); const content = - tab == 'boards' + tab === 'boards' ? games(ctx) - : tab == 'teams' + : tab === 'teams' ? teams(ctx) - : tab == 'stats' + : tab === 'stats' ? stats(ctx) - : tab == 'players' + : tab === 'players' ? players(ctx) : overview(ctx); @@ -231,7 +231,7 @@ const groupSelect = (ctx: RelayViewContext, group: RelayGroup) => { h( 'label.mselect__label', clickHook, - group.tours.find(t => t.id == ctx.relay.data.tour.id)?.name || ctx.relay.data.tour.name, + group.tours.find(t => t.id === ctx.relay.data.tour.id)?.name || ctx.relay.data.tour.name, ), ...(toggle() ? [ @@ -240,7 +240,7 @@ const groupSelect = (ctx: RelayViewContext, group: RelayGroup) => { 'nav.mselect__list', group.tours.map(tour => h( - `a.mselect__item${tour.id == ctx.relay.data.tour.id ? '.current' : ''}`, + `a.mselect__item${tour.id === ctx.relay.data.tour.id ? '.current' : ''}`, { attrs: { href: ctx.study.embeddablePath(`/broadcast/-/${tour.id}`) } }, tour.name, ), @@ -287,7 +287,7 @@ const roundSelect = (relay: RelayCtrl, study: StudyCtrl) => { }), }, relay.data.rounds.map((round, i) => - h(`tr.mselect__item${round.id == study.data.id ? '.current-round' : ''}`, [ + h(`tr.mselect__item${round.id === study.data.id ? '.current-round' : ''}`, [ h( 'td.name', h( diff --git a/ui/analyse/src/study/studyChapters.ts b/ui/analyse/src/study/studyChapters.ts index d509ebcc45bb6..a235cc3613647 100644 --- a/ui/analyse/src/study/studyChapters.ts +++ b/ui/analyse/src/study/studyChapters.ts @@ -41,7 +41,7 @@ export class StudyChapters { first = () => this.list()[0]; looksNew = () => { const cs = this.all(); - return cs.length === 1 && cs[0].name == 'Chapter 1'; + return cs.length === 1 && cs[0].name === 'Chapter 1'; }; } @@ -139,8 +139,8 @@ export const looksLikeLichessGame = (tags: TagArray[]) => export function resultOf(tags: TagArray[], isWhite: boolean): string | undefined { const both = findTag(tags, 'result')?.split('-'); - const mine = both && both.length == 2 ? both[isWhite ? 0 : 1] : undefined; - return mine == '1/2' ? '½' : mine; + const mine = both && both.length === 2 ? both[isWhite ? 0 : 1] : undefined; + return mine === '1/2' ? '½' : mine; } export const gameLinkAttrs = (roundPath: string, game: { id: ChapterId }) => ({ diff --git a/ui/analyse/src/study/studyCtrl.ts b/ui/analyse/src/study/studyCtrl.ts index 8f05ea57fe04a..51532b0127e72 100644 --- a/ui/analyse/src/study/studyCtrl.ts +++ b/ui/analyse/src/study/studyCtrl.ts @@ -633,7 +633,7 @@ export default class StudyCtrl { this.redraw(); }, addNode: d => { - if (d.relayPath == '!') d.relayPath = d.p.path + d.n.id; + if (d.relayPath === '!') d.relayPath = d.p.path + d.n.id; const position = d.p, node = { ...d.n, diff --git a/ui/analyse/src/study/studySearch.ts b/ui/analyse/src/study/studySearch.ts index be6d9dd768b5e..3be0b08190c0a 100644 --- a/ui/analyse/src/study/studySearch.ts +++ b/ui/analyse/src/study/studySearch.ts @@ -62,7 +62,7 @@ export function view(ctrl: SearchCtrl) { el.addEventListener('input', (e: KeyboardEvent) => ctrl.query((e.target as HTMLInputElement).value.trim()), ); - el.addEventListener('keydown', (e: KeyboardEvent) => e.key == 'Enter' && ctrl.setFirstChapter()); + el.addEventListener('keydown', (e: KeyboardEvent) => e.key === 'Enter' && ctrl.setFirstChapter()); }), }), h( diff --git a/ui/analyse/src/view/actionMenu.ts b/ui/analyse/src/view/actionMenu.ts index 1c8799a78bb10..18602b38079ee 100644 --- a/ui/analyse/src/view/actionMenu.ts +++ b/ui/analyse/src/view/actionMenu.ts @@ -41,7 +41,7 @@ function autoplayButtons(ctrl: AnalyseCtrl): VNode { return h( 'div.autoplay', speeds.map(speed => { - const active = ctrl.autoplay.getDelay() == speed.delay; + const active = ctrl.autoplay.getDelay() === speed.delay; return h( 'a.button', { diff --git a/ui/analyse/src/view/components.ts b/ui/analyse/src/view/components.ts index 82eaaa5517652..093b8940f16fc 100644 --- a/ui/analyse/src/view/components.ts +++ b/ui/analyse/src/view/components.ts @@ -442,7 +442,7 @@ function repeater(ctrl: AnalyseCtrl, action: 'prev' | 'next', e: Event) { let delay = 350; let timeout = setTimeout(repeat, 500); control[action](ctrl); - const eventName = e.type == 'touchstart' ? 'touchend' : 'mouseup'; + const eventName = e.type === 'touchstart' ? 'touchend' : 'mouseup'; document.addEventListener(eventName, () => clearTimeout(timeout), { once: true }); } diff --git a/ui/analyse/src/wiki.ts b/ui/analyse/src/wiki.ts index 18a4dae8015c6..a5b01c488a1d6 100644 --- a/ui/analyse/src/wiki.ts +++ b/ui/analyse/src/wiki.ts @@ -19,7 +19,7 @@ export function wikiToggleBox() { $(box) .children('legend') .on('click', toggle) - .on('keypress', e => e.key == 'Enter' && toggle()); + .on('keypress', e => e.key === 'Enter' && toggle()); }); } diff --git a/ui/bits/src/bits.account.ts b/ui/bits/src/bits.account.ts index 65d7a1161b751..01192b4c23bd5 100644 --- a/ui/bits/src/bits.account.ts +++ b/ui/bits/src/bits.account.ts @@ -34,8 +34,8 @@ site.load.then(() => { $form.find('input').on('change', function (this: HTMLInputElement) { computeBitChoices($form, 'behavior.submitMove'); localPrefs.forEach(([categ, name, storeKey]) => { - if (this.name == `${categ}.${name}`) { - storage.boolean(storeKey).set(this.value == '1'); + if (this.name === `${categ}.${name}`) { + storage.boolean(storeKey).set(this.value === '1'); showSaved(); } }); diff --git a/ui/bits/src/bits.captcha.ts b/ui/bits/src/bits.captcha.ts index 90874563e2f63..2586bef8e0326 100644 --- a/ui/bits/src/bits.captcha.ts +++ b/ui/bits/src/bits.captcha.ts @@ -58,8 +58,8 @@ function init() { const submit = function (solution: string) { $input.val(solution); xhr.text(xhr.url($captcha.data('check-url'), { solution })).then(data => { - $captcha.toggleClass('success', data == '1').toggleClass('failure', data != '1'); - if (data == '1') domData.get($board[0]!, 'chessground').stop(); + $captcha.toggleClass('success', data === '1').toggleClass('failure', data !== '1'); + if (data === '1') domData.get($board[0]!, 'chessground').stop(); else setTimeout( () => diff --git a/ui/bits/src/bits.checkout.ts b/ui/bits/src/bits.checkout.ts index b571688789c7d..b81b0d51c0732 100644 --- a/ui/bits/src/bits.checkout.ts +++ b/ui/bits/src/bits.checkout.ts @@ -32,9 +32,9 @@ export function initModule({ stripePublicKey, pricing }: { stripePublicKey: stri const onFreqChange = function () { const freq = getFreq(); - $checkout.find('.amount_fixed').toggleClass('none', freq != 'lifetime'); - $checkout.find('.amount_choice').toggleClass('none', freq == 'lifetime'); - const sub = freq == 'monthly'; + $checkout.find('.amount_fixed').toggleClass('none', freq !== 'lifetime'); + $checkout.find('.amount_choice').toggleClass('none', freq === 'lifetime'); + const sub = freq === 'monthly'; $checkout.find('.paypal--order').toggle(!sub); $checkout.find('.paypal--subscription').toggle(sub); }; @@ -43,7 +43,7 @@ export function initModule({ stripePublicKey, pricing }: { stripePublicKey: stri $checkout.find('group.freq input').on('change', onFreqChange); $checkout.find('group.dest input').on('change', () => { - const isGift = getDest() == 'gift'; + const isGift = getDest() === 'gift'; const $monthly = $('#freq_monthly'); toggleInput($monthly, !isGift); $checkout.find('.gift').toggleClass('none', !isGift).find('input').val(''); @@ -79,12 +79,12 @@ export function initModule({ stripePublicKey, pricing }: { stripePublicKey: stri const getGiftDest = () => { const raw = ($userInput.val() as string).trim().toLowerCase(); - return raw != myUserId() && raw.match(/^[a-z0-9][\w-]{2,29}$/) ? raw : null; + return raw !== myUserId() && raw.match(/^[a-z0-9][\w-]{2,29}$/) ? raw : null; }; const toggleCheckout = () => { const giftDest = getGiftDest(); - const enabled = getDest() != 'gift' || !!giftDest; + const enabled = getDest() !== 'gift' || !!giftDest; toggleInput($checkout.find('.service button'), enabled); $checkout.find('.service .paypal--disabled').toggleClass('none', enabled); $checkout.find('.service .paypal:not(.paypal--disabled)').toggleClass('none', !enabled); @@ -95,7 +95,7 @@ export function initModule({ stripePublicKey, pricing }: { stripePublicKey: stri const getAmountToCharge = () => { const freq = getFreq(), amount = - freq == 'lifetime' + freq === 'lifetime' ? pricing.lifetime : parseFloat($checkout.find('group.amount input:checked').data('amount')); if (amount && amount >= pricing.min && amount <= pricing.max) return amount; diff --git a/ui/bits/src/bits.cms.ts b/ui/bits/src/bits.cms.ts index 077be62c69398..77b6836fd0941 100644 --- a/ui/bits/src/bits.cms.ts +++ b/ui/bits/src/bits.cms.ts @@ -21,7 +21,7 @@ site.load.then(() => { .each(function (this: HTMLTableRowElement) { const match = $(this).find('.title').text().toLowerCase().includes(query) || - $(this).find('.lang').text().toLowerCase() == query; + $(this).find('.lang').text().toLowerCase() === query; this.hidden = !!query && !match; }); }); diff --git a/ui/bits/src/bits.cropDialog.ts b/ui/bits/src/bits.cropDialog.ts index 3b6948fdd2f63..9414167412ff7 100644 --- a/ui/bits/src/bits.cropDialog.ts +++ b/ui/bits/src/bits.cropDialog.ts @@ -18,7 +18,7 @@ export async function initModule(o?: CropOpts): Promise { const url = opts.source instanceof Blob ? URL.createObjectURL(opts.source) - : typeof opts.source == 'string' + : typeof opts.source === 'string' ? URL.createObjectURL((opts.source = await (await fetch(opts.source)).blob())) : URL.createObjectURL((opts.source = await chooseImage())); if (!url) { @@ -113,7 +113,7 @@ export async function initModule(o?: CropOpts): Promise { const formData = new FormData(); formData.append(opts.post.field ?? 'picture', cropped); const rsp = await fetch(opts.post.url, { method: 'POST', body: formData }); - if (rsp.status / 100 == 3) redirect = rsp.headers.get('Location')!; + if (rsp.status / 100 === 3) redirect = rsp.headers.get('Location')!; else if (!rsp.ok) { cropped = false; const body = await rsp.text(); diff --git a/ui/bits/src/bits.gameSearch.ts b/ui/bits/src/bits.gameSearch.ts index d532de47fef04..5d6f5b40e74b0 100644 --- a/ui/bits/src/bits.gameSearch.ts +++ b/ui/bits/src/bits.gameSearch.ts @@ -24,7 +24,7 @@ site.load.then(() => { dataKey: string, ): boolean => { const player: string = $form.data(dataKey); - return row.classList.contains(rowClassName) && !!player.length && user == player; + return row.classList.contains(rowClassName) && !!player.length && user === player; }; const usernames = getUsernames(); const $select = $(row).find('select').html(''); @@ -56,8 +56,8 @@ site.load.then(() => { const toggleAiLevel = function () { $form.find('.opponent select').each(function (this: HTMLSelectElement) { - $form.find('.aiLevel').toggleClass('none', this.value != '1'); - $form.find('.opponentName').toggleClass('none', this.value == '1'); + $form.find('.aiLevel').toggleClass('none', this.value !== '1'); + $form.find('.opponentName').toggleClass('none', this.value === '1'); }); }; toggleAiLevel(); diff --git a/ui/bits/src/bits.userGamesDownload.ts b/ui/bits/src/bits.userGamesDownload.ts index 5596dd7c014c0..4b457f66ba720 100644 --- a/ui/bits/src/bits.userGamesDownload.ts +++ b/ui/bits/src/bits.userGamesDownload.ts @@ -14,11 +14,11 @@ function generateSearchParams(): string { const minTimestamp = 1356998400070; // 01/01/2013, 01:00:00 const date = ($(`#dl-date-${name}`).val() as string).replace(/-/g, '/'); // for Safari https://stackoverflow.com/a/4310986/11955835 const time = $(`#dl-time-${name}`).val() as string; - if (date.length == 10) { + if (date.length === 10) { // the 00:00:00 is necessary for the time to be interpreted in the local timezone - const datetime = new Date(`${date} ${time.length == 8 ? time : '00:00:00'}`); + const datetime = new Date(`${date} ${time.length === 8 ? time : '00:00:00'}`); // Include all games played on date-until if no time is specified - if (time.length != 8 && name === 'until') datetime.setDate(datetime.getDate() + 1); + if (time.length !== 8 && name === 'until') datetime.setDate(datetime.getDate() + 1); searchParams.append(name, Math.max(datetime.getTime(), minTimestamp).toString()); } }); diff --git a/ui/ceval/src/engines/engines.ts b/ui/ceval/src/engines/engines.ts index 982382d5776a7..d058ad69859b5 100644 --- a/ui/ceval/src/engines/engines.ts +++ b/ui/ceval/src/engines/engines.ts @@ -39,7 +39,7 @@ export class Engines { const variantMap = (v: VariantKey): string => (v === 'threeCheck' ? '3check' : v.toLowerCase()); const makeVariant = ([key, nnue]: Variant): WithMake => ({ info: { - id: `__fsfnnue-${key == 'kingOfTheHill' ? 'koth' : variantMap(key)}`, + id: `__fsfnnue-${key === 'kingOfTheHill' ? 'koth' : variantMap(key)}`, name: 'Fairy Stockfish 14+ NNUE', short: 'FSF 14+', tech: 'NNUE', diff --git a/ui/ceval/src/view/main.ts b/ui/ceval/src/view/main.ts index 5b4ddaa049bbc..49285aa684aa4 100644 --- a/ui/ceval/src/view/main.ts +++ b/ui/ceval/src/view/main.ts @@ -28,8 +28,8 @@ function localEvalNodes(ctrl: ParentCtrl, evs: NodeEvals): Array state = ceval.state; if (!evs.client) { if (!ceval.analysable) return ['Engine cannot analyze this position']; - if (state == CevalState.Failed) return [i18n.site.engineFailed]; - const localEvalText = state == CevalState.Loading ? loadingText(ctrl) : i18n.site.calculatingMoves; + if (state === CevalState.Failed) return [i18n.site.engineFailed]; + const localEvalText = state === CevalState.Loading ? loadingText(ctrl) : i18n.site.calculatingMoves; return [evs.server && ctrl.nextNodeBest() ? i18n.site.usingServerAnalysis : localEvalText]; } @@ -330,7 +330,7 @@ export function renderPvs(ctrl: ParentCtrl): VNode | undefined { else pvs = []; if (threat) { setup.turn = opposite(setup.turn); - if (setup.turn == 'white') setup.fullmoves += 1; + if (setup.turn === 'white') setup.fullmoves += 1; } const pos = setupPosition(lichessRules(ceval.opts.variant.key), setup); diff --git a/ui/challenge/src/view.ts b/ui/challenge/src/view.ts index ddae0641edf04..e5ebfadf44fd1 100644 --- a/ui/challenge/src/view.ts +++ b/ui/challenge/src/view.ts @@ -35,9 +35,9 @@ const allChallenges = (ctrl: ChallengeCtrl, d: ChallengeData, nb: number): VNode function challenge(ctrl: ChallengeCtrl, dir: ChallengeDirection) { return (c: Challenge) => { - const fromPosition = c.variant.key == 'fromPosition'; - const origColor = c.color == 'random' ? (fromPosition ? c.finalColor : 'random') : c.finalColor; - const myColor = dir == 'out' ? origColor : origColor == 'random' ? 'random' : opposite(origColor); + const fromPosition = c.variant.key === 'fromPosition'; + const origColor = c.color === 'random' ? (fromPosition ? c.finalColor : 'random') : c.finalColor; + const myColor = dir === 'out' ? origColor : origColor === 'random' ? 'random' : opposite(origColor); const opponent = dir === 'in' ? c.challenger : c.destUser; return h( `div.challenge.${dir}.c-${c.id}`, @@ -106,7 +106,7 @@ function inButtons(ctrl: ChallengeCtrl, c: Challenge): VNode[] { }, }, Object.entries(ctrl.reasons).map(([key, name]) => - h('option', { attrs: { value: key } }, key == 'generic' ? '' : name), + h('option', { attrs: { value: key } }, key === 'generic' ? '' : name), ), ), ]; diff --git a/ui/chart/src/acpl.ts b/ui/chart/src/acpl.ts index aaa338ed7e2c9..bc97f76e19326 100644 --- a/ui/chart/src/acpl.ts +++ b/ui/chart/src/acpl.ts @@ -63,7 +63,7 @@ export default async function ( const blurs = [toBlurArray(d.player), toBlurArray(d.opponent)]; if (d.player.color === 'white') blurs.reverse(); mainline.slice(1).map(node => { - const isWhite = (node.ply & 1) == 1; + const isWhite = (node.ply & 1) === 1; let cp: number | undefined = node.eval && 0; if (node.eval && node.eval.mate) cp = node.eval.mate > 0 ? Infinity : -Infinity; else if (node.san?.includes('#')) cp = isWhite ? Infinity : -Infinity; @@ -146,7 +146,7 @@ export default async function ( bodyFont: fontFamily(13), caretPadding: 10, displayColors: false, - filter: item => item.datasetIndex == 0, + filter: item => item.datasetIndex === 0, callbacks: { label: item => { const ev = mainline[item.dataIndex + 1]?.eval; @@ -169,7 +169,7 @@ export default async function ( }, }, onClick(_event, elements, _chart) { - const data = elements[elements.findIndex(element => element.datasetIndex == 0)]; + const data = elements[elements.findIndex(element => element.datasetIndex === 0)]; if (data) pubsub.emit('analysis.chart.click', data.index); }, }, @@ -192,9 +192,9 @@ export default async function ( type Advice = 'blunder' | 'mistake' | 'inaccuracy'; const glyphProperties = (node: Tree.Node): { advice?: Advice; color?: string } => { - if (node.glyphs?.some(g => g.id == 4)) return { advice: 'blunder', color: '#db3031' }; - else if (node.glyphs?.some(g => g.id == 2)) return { advice: 'mistake', color: '#e69d00' }; - else if (node.glyphs?.some(g => g.id == 6)) return { advice: 'inaccuracy', color: '#4da3d5' }; + if (node.glyphs?.some(g => g.id === 4)) return { advice: 'blunder', color: '#db3031' }; + else if (node.glyphs?.some(g => g.id === 2)) return { advice: 'mistake', color: '#e69d00' }; + else if (node.glyphs?.some(g => g.id === 6)) return { advice: 'inaccuracy', color: '#4da3d5' }; else return { advice: undefined, color: undefined }; }; @@ -203,14 +203,14 @@ const toBlurArray = (player: Player) => player.blurs?.bits?.split('') ?? []; function christmasTree(chart: AcplChart, mainline: Tree.Node[], hoverColors: string[]) { $('div.advice-summary').on('mouseenter', 'div.symbol', function (this: HTMLElement) { const symbol = this.getAttribute('data-symbol'); - const playerColorBit = this.getAttribute('data-color') == 'white' ? 1 : 0; + const playerColorBit = this.getAttribute('data-color') === 'white' ? 1 : 0; const acplDataset = chart.data.datasets[0]; - if (symbol == '??' || symbol == '?!' || symbol == '?') { + if (symbol === '??' || symbol === '?!' || symbol === '?') { acplDataset.pointHoverBackgroundColor = hoverColors; acplDataset.pointBorderColor = hoverColors; const points = mainline .filter( - node => node.glyphs?.some(glyph => glyph.symbol == symbol) && (node.ply & 1) == playerColorBit, + node => node.glyphs?.some(glyph => glyph.symbol === symbol) && (node.ply & 1) === playerColorBit, ) .map(node => ({ datasetIndex: 0, index: node.ply - mainline[0].ply - 1 })); chart.setActiveElements(points); diff --git a/ui/chart/src/chart.lag.ts b/ui/chart/src/chart.lag.ts index 06442ca2db286..c033fd9884837 100644 --- a/ui/chart/src/chart.lag.ts +++ b/ui/chart/src/chart.lag.ts @@ -100,7 +100,7 @@ export async function initModule(): Promise { ], }; const chart = new Chart(this, config); - if (index == 0) + if (index === 0) pubsub.on('socket.in.mlat', (d: number) => { v.server = d; if (v.server <= 0) return; diff --git a/ui/chart/src/chart.ratingDistribution.ts b/ui/chart/src/chart.ratingDistribution.ts index 7400753220ae5..607e937888a7f 100644 --- a/ui/chart/src/chart.ratingDistribution.ts +++ b/ui/chart/src/chart.ratingDistribution.ts @@ -80,7 +80,7 @@ export async function initModule(data: DistributionData): Promise { align: 'top', offset: 0, display: 'auto', - formatter: (value: Point) => (value.y == 0 ? '' : label), + formatter: (value: Point) => (value.y === 0 ? '' : label), color: color, }, }); diff --git a/ui/chart/src/chart.ratingHistory.ts b/ui/chart/src/chart.ratingHistory.ts index 989a7eb59de39..bf7d3325369e4 100644 --- a/ui/chart/src/chart.ratingHistory.ts +++ b/ui/chart/src/chart.ratingHistory.ts @@ -184,7 +184,7 @@ export function initModule({ data, singlePerfName }: Opts): void { borderWidth: 1, yAlign: 'center', caretPadding: 10, - rtl: document.dir == 'rtl', + rtl: document.dir === 'rtl', callbacks: { title: items => dateFormat()(dayjs.utc(items[0].parsed.x).valueOf()), }, @@ -196,9 +196,9 @@ export function initModule({ data, singlePerfName }: Opts): void { const handlesSlider = $('#time-range-slider')[0]; let yearPips = []; for (let i = startDate; i.isBefore(endDate); i = i.add(1, 'd')) { - if (i.date() == 1 && i.month() == 0) yearPips.push(i); + if (i.date() === 1 && i.month() === 0) yearPips.push(i); } - if (yearPips.length >= 7) yearPips = yearPips.filter((_, i) => i % 2 == 0); + if (yearPips.length >= 7) yearPips = yearPips.filter((_, i) => i % 2 === 0); const opts: Options = { start: [initial.valueOf(), endDate.valueOf()], connect: true, @@ -213,7 +213,7 @@ export function initModule({ data, singlePerfName }: Opts): void { pips: { mode: PipsMode.Values, values: yearPips.map(y => y.valueOf()), - filter: (val, tpe) => (tpe == 1 ? val : -1), + filter: (val, tpe) => (tpe === 1 ? val : -1), format: { to: val => dayjs.utc(val).format('YYYY'), }, @@ -259,7 +259,7 @@ export function initModule({ data, singlePerfName }: Opts): void { ]; $('.time-selector-buttons').html( buttons - .filter(b => startDate.isBefore(endDate.subtract(b.duration)) || b.t == 'all') + .filter(b => startDate.isBefore(endDate.subtract(b.duration)) || b.t === 'all') .map(b => timeBtn(b)) .join(''), ); @@ -299,7 +299,7 @@ function makeDatasets(step: number, { data, singlePerfName }: Opts, singlePerfIn borderColor: perfStyle.color, hoverBorderColor: hoverBorderColor, backgroundColor: perfStyle.color, - pointRadius: data.length == 1 ? 3 : 0, + pointRadius: data.length === 1 ? 3 : 0, pointHoverRadius: 6, data: data, pointStyle: perfStyle.symbol, diff --git a/ui/chart/src/chart.relayStats.ts b/ui/chart/src/chart.relayStats.ts index da91f23b68aa7..57dd5d9fddbc5 100644 --- a/ui/chart/src/chart.relayStats.ts +++ b/ui/chart/src/chart.relayStats.ts @@ -81,7 +81,7 @@ const makeDataset = (data: RoundStats, el: HTMLCanvasElement): chart.ChartDatase align: 'top', offset: -5, display: 'auto', - formatter: (value: chart.Point) => (value.y == 0 ? '' : 'Round Start'), + formatter: (value: chart.Point) => (value.y === 0 ? '' : 'Round Start'), color: pink, }, pointRadius: 0, @@ -158,7 +158,7 @@ const makeChart = ($el: Cash, data: RoundStats) => { }, plugins: { tooltip: { - filter: i => i.datasetIndex == 0, + filter: i => i.datasetIndex === 0, backgroundColor: tooltipBgColor, bodyColor: fontColor, titleColor: fontColor, diff --git a/ui/chart/src/common.ts b/ui/chart/src/common.ts index 7f5b739c11c63..d071ddee2bae6 100644 --- a/ui/chart/src/common.ts +++ b/ui/chart/src/common.ts @@ -10,7 +10,7 @@ export interface MovePoint { export const chartYMax = 1.05; export const chartYMin: number = -chartYMax; -const lightTheme = currentTheme() == 'light'; +const lightTheme = currentTheme() === 'light'; export const orangeAccent = '#d85000'; export const whiteFill: string = lightTheme ? 'rgba(255,255,255,0.7)' : 'rgba(255,255,255,0.3)'; export const blackFill: string = lightTheme ? 'rgba(0,0,0,0.2)' : 'rgba(0,0,0,1)'; @@ -35,7 +35,7 @@ export const axisOpts = (xmin: number, xmax: number): ChartOptions<'line'>['scal border: { display: false }, ticks: { display: false }, grid: { - color: ctx => (ctx.tick.value == 0 ? zeroLineColor : undefined), + color: ctx => (ctx.tick.value === 0 ? zeroLineColor : undefined), }, }, }); @@ -85,7 +85,7 @@ export function plyLine(ply: number, mainline = true): ChartDataset<'line'> { } export function selectPly(this: Chart, ply: number, onMainline: boolean): void { - const index = this.data.datasets.findIndex(dataset => dataset.label == 'ply'); + const index = this.data.datasets.findIndex(dataset => dataset.label === 'ply'); const line = plyLine(ply, onMainline); this.data.datasets[index] = line; this.update('none'); @@ -99,7 +99,7 @@ export function animation(duration: number): ChartOptions<'line'>['animations'] easing: 'easeOutQuad', duration: duration, from: NaN, // the point is initially skipped - delay: ctx => (ctx.mode == 'resize' ? 0 : ctx.dataIndex * duration), + delay: ctx => (ctx.mode === 'resize' ? 0 : ctx.dataIndex * duration), }, y: { type: 'number', @@ -109,7 +109,7 @@ export function animation(duration: number): ChartOptions<'line'>['animations'] !ctx.dataIndex ? ctx.chart.scales.y.getPixelForValue(100) : ctx.chart.getDatasetMeta(ctx.datasetIndex).data[ctx.dataIndex - 1].getProps(['y'], true).y, - delay: ctx => (ctx.mode == 'resize' ? 0 : ctx.dataIndex * duration), + delay: ctx => (ctx.mode === 'resize' ? 0 : ctx.dataIndex * duration), }, }; } diff --git a/ui/chart/src/movetime.ts b/ui/chart/src/movetime.ts index 1374515c49576..ab10d4a442324 100644 --- a/ui/chart/src/movetime.ts +++ b/ui/chart/src/movetime.ts @@ -111,12 +111,11 @@ export default async function ( } if (clock) { label += '\n' + formatClock(clock); - } - if (clock) totalSeries[colorName].push({ x: node ? node.ply : tree[x].ply + 1, y: color ? clock : -clock, }); + } labels.push(label); }); @@ -133,7 +132,7 @@ export default async function ( y: point.y / (moveSeries ? moveSeriesMax : totalSeriesMax), })), backgroundColor: color, - borderColor: moveSeries && showTotal ? (color == 'white' ? '#838383' : '#3d3d3d') : blueLineColor, + borderColor: moveSeries && showTotal ? (color === 'white' ? '#838383' : '#3d3d3d') : blueLineColor, borderWidth: moveSeries && showTotal ? 1 : 1.5, pointHitRadius: moveSeries && showTotal ? 0 : 200, pointHoverBorderColor: moveSeries && !showTotal ? orangeAccent : blueLineColor, @@ -158,7 +157,7 @@ export default async function ( categoryPercentage: 2, barPercentage: 1, order: 2, - borderColor: color == 'white' ? '#838383' : '#616161', + borderColor: color === 'white' ? '#838383' : '#616161', borderWidth: 1, datalabels: { display: false }, })) @@ -197,7 +196,7 @@ export default async function ( displayColors: false, callbacks: { title: items => - labels[items[0].dataset.label == 'bar' ? items[0].parsed.x * 2 : items[0].parsed.x], + labels[items[0].dataset.label === 'bar' ? items[0].parsed.x * 2 : items[0].parsed.x], label: () => '', }, }, diff --git a/ui/chat/src/ctrl.ts b/ui/chat/src/ctrl.ts index dae8b51caf116..b763c8d21ce6c 100644 --- a/ui/chat/src/ctrl.ts +++ b/ui/chat/src/ctrl.ts @@ -97,7 +97,7 @@ export default class ChatCtrl { post = (text: string): boolean => { text = text.trim(); if (!text) return false; - if (text == 'You too!' && !this.data.lines.some(l => l.u != this.data.userId)) return false; + if (text === 'You too!' && !this.data.lines.some(l => l.u != this.data.userId)) return false; if (text.length > 140) { alert('Max length: 140 chars. ' + text.length + ' chars used.'); return false; @@ -111,7 +111,7 @@ export default class ChatCtrl { private onTimeout = (userId: string): void => { let change = false; this.data.lines.forEach(l => { - if (l.u && l.u.toLowerCase() == userId) { + if (l.u && l.u.toLowerCase() === userId) { l.d = true; change = true; } diff --git a/ui/chat/src/discussion.ts b/ui/chat/src/discussion.ts index 9b2c47a700ab9..c9281d48fcee1 100644 --- a/ui/chat/src/discussion.ts +++ b/ui/chat/src/discussion.ts @@ -203,7 +203,7 @@ function renderLine(ctrl: ChatCtrl, line: Line): VNode { !!myUserId && !!line.t .match(enhance.userPattern) - ?.find(mention => mention.trim().toLowerCase() == `@${ctrl.data.userId}`); + ?.find(mention => mention.trim().toLowerCase() === `@${ctrl.data.userId}`); return h( 'li', diff --git a/ui/chat/src/spam.ts b/ui/chat/src/spam.ts index e9a51c2b380a5..472516f089d67 100644 --- a/ui/chat/src/spam.ts +++ b/ui/chat/src/spam.ts @@ -10,7 +10,7 @@ export const selfReport = (txt: string): void => { if (hasSuspLink || followMe(txt)) storage.set('chat-spam', '1'); }; -const isKnownSpammer = () => storage.get('chat-spam') == '1'; +const isKnownSpammer = () => storage.get('chat-spam') === '1'; const spamRegex = new RegExp( [ diff --git a/ui/chess/src/promotion.ts b/ui/chess/src/promotion.ts index a9dad531a2c43..45fdb0700c791 100644 --- a/ui/chess/src/promotion.ts +++ b/ui/chess/src/promotion.ts @@ -21,7 +21,7 @@ const PROMOTABLE_ROLES: Role[] = ['queen', 'knight', 'rook', 'bishop']; export function promote(g: CgApi, key: Key, role: Role): void { const piece = g.state.pieces.get(key); - if (piece && piece.role == 'pawn') { + if (piece && piece.role === 'pawn') { g.setPieces(new Map([[key, { color: piece.color, role, promoted: true }]])); } } @@ -42,8 +42,9 @@ export class PromotionCtrl { const premovePiece = g.state.pieces.get(orig); const piece = premovePiece || g.state.pieces.get(dest); if ( - piece?.role == 'pawn' && - ((dest[1] == '8' && g.state.turnColor == 'black') || (dest[1] == '1' && g.state.turnColor == 'white')) + piece?.role === 'pawn' && + ((dest[1] === '8' && g.state.turnColor === 'black') || + (dest[1] === '1' && g.state.turnColor === 'white')) ) { if (this.prePromotionRole && meta?.premove) { this.doPromote({ orig, dest, hooks }, this.prePromotionRole); diff --git a/ui/chess/src/sanWriter.ts b/ui/chess/src/sanWriter.ts index 8deabcd8b9f69..2694b625b64bd 100644 --- a/ui/chess/src/sanWriter.ts +++ b/ui/chess/src/sanWriter.ts @@ -40,7 +40,7 @@ export function readFen(fen: string): Board { .forEach((row, y) => { let x = 0; row.split('').forEach(v => { - if (v == '~') return; + if (v === '~') return; const nb = parseInt(v, 10); if (nb) x += nb; else { @@ -104,7 +104,7 @@ export function sanOf(board: Board, uci: string): San { } // castling - if (pt == 'k' && ((d && isBlack(p) === isBlack(d)) || squareDist(from, to) > 1)) { + if (pt === 'k' && ((d && isBlack(p) === isBlack(d)) || squareDist(from, to) > 1)) { if (to < from) return 'O-O-O'; else return 'O-O'; } @@ -113,11 +113,11 @@ export function sanOf(board: Board, uci: string): San { // disambiguate normal moves let candidates: number[] = []; - if (pt == 'k') candidates = kingMovesTo(to); - else if (pt == 'n') candidates = knightMovesTo(to); - else if (pt == 'r') candidates = slidingMovesTo(to, ROOK_DELTAS, board); - else if (pt == 'b') candidates = slidingMovesTo(to, BISHOP_DELTAS, board); - else if (pt == 'q') candidates = slidingMovesTo(to, QUEEN_DELTAS, board); + if (pt === 'k') candidates = kingMovesTo(to); + else if (pt === 'n') candidates = knightMovesTo(to); + else if (pt === 'r') candidates = slidingMovesTo(to, ROOK_DELTAS, board); + else if (pt === 'b') candidates = slidingMovesTo(to, BISHOP_DELTAS, board); + else if (pt === 'q') candidates = slidingMovesTo(to, QUEEN_DELTAS, board); let rank = false, file = false; @@ -165,11 +165,11 @@ export function speakable(san?: San): string { : san .split('') .map(c => { - if (c == 'x') return 'takes'; - if (c == '+') return 'check'; - if (c == '#') return 'checkmate'; - if (c == '=') return 'promotes to'; - if (c == '@') return 'at'; + if (c === 'x') return 'takes'; + if (c === '+') return 'check'; + if (c === '#') return 'checkmate'; + if (c === '=') return 'promotes to'; + if (c === '@') return 'at'; const code = c.charCodeAt(0); if (code > 48 && code < 58) return c; // 1-8 if (code > 96 && code < 105) return c.toUpperCase(); diff --git a/ui/cli/src/cli.ts b/ui/cli/src/cli.ts index 6efa138d6fe88..e54c70740d958 100644 --- a/ui/cli/src/cli.ts +++ b/ui/cli/src/cli.ts @@ -11,7 +11,7 @@ export function initModule({ input }: { input: HTMLInputElement }) { onSelect: r => execute(r.name), }); $(input).on('keydown', (e: KeyboardEvent) => { - if (e.key == 'Enter') { + if (e.key === 'Enter') { execute(input.value); input.blur(); } @@ -20,7 +20,7 @@ export function initModule({ input }: { input: HTMLInputElement }) { function execute(q: string) { if (!q) return; - if (q[0] == '/') return command(q.replace(/\//g, '')); + if (q[0] === '/') return command(q.replace(/\//g, '')); // 5kr1/p1p2p2/2b2Q2/3q2r1/2p4p/2P4P/P2P1PP1/1R1K3R b - - 1 23 if (q.match(/^([1-8pnbrqk]+\/){7}.*/i)) return (location.href = '/analysis/standard/' + q.replace(/ /g, '_')); diff --git a/ui/common/src/clock.ts b/ui/common/src/clock.ts index e54536e0deb16..182fea1bc0ff5 100644 --- a/ui/common/src/clock.ts +++ b/ui/common/src/clock.ts @@ -11,7 +11,7 @@ export const formatMs = (msTime: number): string => { export const otbClockIsRunning = (fen: string): boolean => !fen.includes('PPPPPPPP/RNBQKBNR'); export const lichessClockIsRunning = (fen: string, color: Color): boolean => - color == 'white' ? !fen.includes('PPPPPPPP/RNBQKBNR') : !fen.startsWith('rnbqkbnr/pppppppp'); + color === 'white' ? !fen.includes('PPPPPPPP/RNBQKBNR') : !fen.startsWith('rnbqkbnr/pppppppp'); export function setClockWidget(el: HTMLElement, opts: Opts): void { const instance = data.get(el, 'clock') as ClockWidget; diff --git a/ui/common/src/complete.ts b/ui/common/src/complete.ts index d982118f8e1e7..739d1e91330a7 100644 --- a/ui/common/src/complete.ts +++ b/ui/common/src/complete.ts @@ -35,7 +35,7 @@ export function complete(opts: CompleteOpts): void { }, moveSelection = (offset: number) => { const nb = renderedResults.length; - selectedIndex = (selectedIndex === null ? (offset == 1 ? 0 : -1) : selectedIndex + offset) % nb; + selectedIndex = (selectedIndex === null ? (offset === 1 ? 0 : -1) : selectedIndex + offset) % nb; if (selectedIndex < 0) selectedIndex += nb; renderSelection(); const result = selectedResult(); @@ -70,15 +70,15 @@ export function complete(opts: CompleteOpts): void { }, keydown(e: KeyboardEvent) { if ($container.hasClass('none')) return; - if (e.code == 'ArrowDown') { + if (e.code === 'ArrowDown') { moveSelection(1); return false; } - if (e.code == 'ArrowUp') { + if (e.code === 'ArrowUp') { moveSelection(-1); return false; } - if (e.code == 'Enter') { + if (e.code === 'Enter') { $container.addClass('none'); const result = selectedResult() || diff --git a/ui/common/src/controls.ts b/ui/common/src/controls.ts index 5c44023670f06..6052ebd79716a 100644 --- a/ui/common/src/controls.ts +++ b/ui/common/src/controls.ts @@ -38,7 +38,7 @@ export function toggleBoxInit(): void { .addClass('toggle-box--ready') .children('legend') .on('click', toggle) - .on('keypress', e => e.key == 'Enter' && toggle()); + .on('keypress', e => e.key === 'Enter' && toggle()); }); } diff --git a/ui/keyboardMove/src/keyboardChecker.ts b/ui/keyboardMove/src/keyboardChecker.ts index 487c3ed8d0333..41c5b3eaa795b 100644 --- a/ui/keyboardMove/src/keyboardChecker.ts +++ b/ui/keyboardMove/src/keyboardChecker.ts @@ -8,17 +8,17 @@ export default class KeyboardChecker { press = (e: KeyboardEvent): void => { const v = (e.target as HTMLInputElement).value; - if (v == this.prev) return; + if (v === this.prev) return; this.prev = v; - if (e.key.length == 1) this.keys.push(e.key); + if (e.key.length === 1) this.keys.push(e.key); else { - if (v == '') this.clear(); - else if (e.key == 'Enter') { + if (v === '') this.clear(); + else if (e.key === 'Enter') { if (v.length > 1) { if (v.split('').every(c => this.keys.includes(c))) this.oks++; else { this.kos++; - if (this.kos == 9 && this.kos > this.oks) pubsub.emit('ab.rep', 'kbc'); + if (this.kos === 9 && this.kos > this.oks) pubsub.emit('ab.rep', 'kbc'); } } } diff --git a/ui/keyboardMove/src/keyboardMove.ts b/ui/keyboardMove/src/keyboardMove.ts index 1018a611b928d..59b998c62a195 100644 --- a/ui/keyboardMove/src/keyboardMove.ts +++ b/ui/keyboardMove/src/keyboardMove.ts @@ -52,11 +52,11 @@ function makeBindings(opts: Opts, submit: Submit, clear: () => void) { if (v.includes('/')) { focusChat(); clear(); - } else if (v == '' && e.key == 'Enter') opts.ctrl.confirmMove(); + } else if (v === '' && e.key === 'Enter') opts.ctrl.confirmMove(); else { opts.ctrl.checker?.press(e); submit(v, { - force: e.key == 'Enter', + force: e.key === 'Enter', isTrusted: true, }); } diff --git a/ui/puz/src/view/chessground.ts b/ui/puz/src/view/chessground.ts index 0a5589ca0c110..456affcc81f4a 100644 --- a/ui/puz/src/view/chessground.ts +++ b/ui/puz/src/view/chessground.ts @@ -31,7 +31,7 @@ export function makeConfig(opts: CgConfig, pref: PuzPrefs, userMove: UserMove): events: { move: userMove, insert(elements) { - resizeHandle(elements, ShowResizeHandle.OnlyAtStart, 0, p => p == 0); + resizeHandle(elements, ShowResizeHandle.OnlyAtStart, 0, p => p === 0); }, }, premovable: { diff --git a/ui/racer/src/ctrl.ts b/ui/racer/src/ctrl.ts index 638ee646b7041..6de046606d14b 100644 --- a/ui/racer/src/ctrl.ts +++ b/ui/racer/src/ctrl.ts @@ -170,7 +170,7 @@ export default class RacerCtrl implements PuzCtrl { }; playUserMove = (orig: Key, dest: Key, promotion?: Role): void => - this.playUci(`${orig}${dest}${promotion ? (promotion == 'knight' ? 'n' : promotion[0]) : ''}`); + this.playUci(`${orig}${dest}${promotion ? (promotion === 'knight' ? 'n' : promotion[0]) : ''}`); playUci = (uci: Uci): void => { const now = getNow(); @@ -181,7 +181,7 @@ export default class RacerCtrl implements PuzCtrl { this.promotion.cancel(); const pos = puzzle.position(); pos.play(parseUci(uci)!); - if (pos.isCheckmate() || uci == puzzle.expectedMove()) { + if (pos.isCheckmate() || uci === puzzle.expectedMove()) { puzzle.moveIndex++; this.localScore++; this.run.combo.inc(); diff --git a/ui/storm/src/ctrl.ts b/ui/storm/src/ctrl.ts index 5fea78b673b84..2713e04c9bb01 100644 --- a/ui/storm/src/ctrl.ts +++ b/ui/storm/src/ctrl.ts @@ -105,10 +105,10 @@ export default class StormCtrl implements PuzCtrl { this.run.clock.start(); this.run.moves++; this.promotion.cancel(); - const uci = `${orig}${dest}${promotion ? (promotion == 'knight' ? 'n' : promotion[0]) : ''}`; + const uci = `${orig}${dest}${promotion ? (promotion === 'knight' ? 'n' : promotion[0]) : ''}`; const pos = puzzle.position(); pos.play(parseUci(uci)!); - const correct = pos.isCheckmate() || uci == puzzle.expectedMove(); + const correct = pos.isCheckmate() || uci === puzzle.expectedMove(); if (correct) { puzzle.moveIndex++; this.run.combo.inc(); @@ -200,7 +200,7 @@ export default class StormCtrl implements PuzCtrl { const dupTabMsg = storage.make('storm.tab'); dupTabMsg.fire(this.data.puzzles[0].id); dupTabMsg.listen(ev => { - if (!this.run.clock.startAt && ev.value == this.data.puzzles[0].id) { + if (!this.run.clock.startAt && ev.value === this.data.puzzles[0].id) { this.vm.dupTab = true; this.redraw(); }