mirror of
https://github.com/williamsjack/pairwise-glicko-ranking.git
synced 2026-07-22 06:44:09 +00:00
Apply stricter linting
This commit is contained in:
parent
48528ad3c3
commit
a428607a8c
22 changed files with 98 additions and 77 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { App, OpenViewState, TFile, WorkspaceLeaf } from 'obsidian';
|
||||
import type { App, OpenViewState, WorkspaceLeaf } from 'obsidian';
|
||||
import { TFile } from 'obsidian';
|
||||
|
||||
const TIMEOUT_MS = 5_000;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { App, TFile, parseYaml } from 'obsidian';
|
||||
import type { App, TFile} from 'obsidian';
|
||||
import { parseYaml } from 'obsidian';
|
||||
|
||||
export type BaseViewInfo = {
|
||||
name: string;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { App, TFile } from 'obsidian';
|
||||
import type { App, TFile } from 'obsidian';
|
||||
|
||||
import { PluginDataStore } from '../../storage/PluginDataStore';
|
||||
import type { PluginDataStore } from '../../storage/PluginDataStore';
|
||||
import { getEloId } from '../../utils/NoteIds';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { App, TAbstractFile, TFile, TFolder } from 'obsidian';
|
||||
import { CohortDefinition, CohortKind, CohortParamsMap, CohortSpec } from '../../types';
|
||||
import type { App, TAbstractFile} from 'obsidian';
|
||||
import { TFile, TFolder } from 'obsidian';
|
||||
|
||||
import type { CohortDefinition, CohortKind, CohortParamsMap, CohortSpec } from '../../types';
|
||||
import { normaliseTag } from '../../utils/tags';
|
||||
import { resolveFilesFromBaseView } from '../bases/BasesCohortResolver';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { EloHeuristicsSettings as EloHeuristics } from '../../settings';
|
||||
import { MatchResult } from '../../types';
|
||||
import type { MatchResult } from '../../types';
|
||||
|
||||
export function expectedScore(rA: number, rB: number): number {
|
||||
return 1 / (1 + Math.pow(10, (rB - rA) / 400));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import type { MatchmakingSettings } from '../../settings';
|
||||
import type { TFile } from 'obsidian';
|
||||
|
||||
import type { MatchmakingSettings } from '../../settings';
|
||||
import { pairSig as mkPairSig } from '../../utils/pair';
|
||||
|
||||
export type RatingStats = { rating: number; matches: number };
|
||||
|
|
|
|||
22
src/main.ts
22
src/main.ts
|
|
@ -1,16 +1,18 @@
|
|||
import { EloSettings, effectiveFrontmatterProperties } from './settings';
|
||||
import { Notice, Plugin, TAbstractFile, TFile } from 'obsidian';
|
||||
import { computeRankMap, updateCohortFrontmatter } from './utils/FrontmatterStats';
|
||||
import type { TAbstractFile} from 'obsidian';
|
||||
import { Notice, Plugin, TFile } from 'obsidian';
|
||||
|
||||
import ArenaSession from './ui/ArenaSession';
|
||||
import { CohortDefinition } from './types';
|
||||
import { CohortPicker } from './ui/CohortPicker';
|
||||
import EloSettingsTab from './settings/SettingsTab';
|
||||
import { PluginDataStore } from './storage/PluginDataStore';
|
||||
import { ensureBaseCohortTarget } from './utils/EnsureBaseCohort';
|
||||
import { ensureFolderCohortPath } from './utils/EnsureFolderCohort';
|
||||
import { reconcileCohortPlayersWithFiles } from './domain/cohort/CohortIntegrity';
|
||||
import { resolveFilesForCohort } from './domain/cohort/CohortResolver';
|
||||
import type { EloSettings} from './settings';
|
||||
import { effectiveFrontmatterProperties } from './settings';
|
||||
import EloSettingsTab from './settings/SettingsTab';
|
||||
import { PluginDataStore } from './storage/PluginDataStore';
|
||||
import type { CohortDefinition } from './types';
|
||||
import ArenaSession from './ui/ArenaSession';
|
||||
import { CohortPicker } from './ui/CohortPicker';
|
||||
import { ensureBaseCohortTarget } from './utils/EnsureBaseCohort';
|
||||
import { ensureFolderCohortPath } from './utils/EnsureFolderCohort';
|
||||
import { computeRankMap, updateCohortFrontmatter } from './utils/FrontmatterStats';
|
||||
|
||||
export default class EloPlugin extends Plugin {
|
||||
dataStore: PluginDataStore;
|
||||
|
|
|
|||
|
|
@ -1,22 +1,24 @@
|
|||
import { App, Notice, PluginSettingTab, Setting, SliderComponent, setIcon } from 'obsidian';
|
||||
import {
|
||||
DEFAULT_SETTINGS,
|
||||
FrontmatterPropertiesSettings,
|
||||
SessionLayoutMode,
|
||||
effectiveFrontmatterProperties,
|
||||
} from './settings';
|
||||
import type { App, SliderComponent} from 'obsidian';
|
||||
import { Notice, PluginSettingTab, setIcon,Setting } from 'obsidian';
|
||||
|
||||
import { prettyCohortDefinition, resolveFilesForCohort } from '../domain/cohort/CohortResolver';
|
||||
import type EloPlugin from '../main';
|
||||
import type { CohortData } from '../types';
|
||||
import { CohortOptionsModal } from '../ui/CohortOptionsModal';
|
||||
import { FM_PROP_KEYS, renderStandardFmPropertyRow } from '../ui/FrontmatterPropertyRow';
|
||||
import { BasePromiseModal } from '../ui/PromiseModal';
|
||||
import {
|
||||
computeRankMap,
|
||||
previewCohortFrontmatterPropertyUpdates,
|
||||
updateCohortFrontmatter,
|
||||
} from '../utils/FrontmatterStats';
|
||||
import { prettyCohortDefinition, resolveFilesForCohort } from '../domain/cohort/CohortResolver';
|
||||
|
||||
import { BasePromiseModal } from '../ui/PromiseModal';
|
||||
import type { CohortData } from '../types';
|
||||
import { CohortOptionsModal } from '../ui/CohortOptionsModal';
|
||||
import type EloPlugin from '../main';
|
||||
import type {
|
||||
FrontmatterPropertiesSettings,
|
||||
SessionLayoutMode} from './settings';
|
||||
import {
|
||||
DEFAULT_SETTINGS,
|
||||
effectiveFrontmatterProperties,
|
||||
} from './settings';
|
||||
|
||||
type PropKey = keyof FrontmatterPropertiesSettings;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
import {
|
||||
import type { Plugin } from 'obsidian';
|
||||
|
||||
import { updateElo } from '../domain/elo/EloEngine';
|
||||
import type { EloSettings, SessionLayoutMode } from '../settings';
|
||||
import { DEFAULT_SETTINGS } from '../settings';
|
||||
import type {
|
||||
CohortData,
|
||||
CohortDefinition,
|
||||
EloStore,
|
||||
|
|
@ -6,10 +11,6 @@ import {
|
|||
PlayerSnapshot,
|
||||
UndoFrame,
|
||||
} from '../types';
|
||||
import { DEFAULT_SETTINGS, EloSettings, SessionLayoutMode } from '../settings';
|
||||
|
||||
import { Plugin } from 'obsidian';
|
||||
import { updateElo } from '../domain/elo/EloEngine';
|
||||
|
||||
interface PersistedData {
|
||||
version: number;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import { App, MarkdownView, Notice, TFile, WorkspaceLeaf } from 'obsidian';
|
||||
import { ArenaLayoutHandle, ArenaLayoutManager } from './LayoutManager';
|
||||
import { MatchResult, ScrollStartMode, UndoFrame } from '../types';
|
||||
import { attempt, attemptAsync } from '../utils/safe';
|
||||
import { ensureEloId, getEloId } from '../utils/NoteIds';
|
||||
import type { App, WorkspaceLeaf } from 'obsidian';
|
||||
import { MarkdownView, Notice, TFile } from 'obsidian';
|
||||
|
||||
import { pickNextPairIndices } from '../domain/matchmaking/Matchmaker';
|
||||
import type EloPlugin from '../main';
|
||||
import type { FrontmatterPropertiesSettings } from '../settings';
|
||||
import { effectiveFrontmatterProperties } from '../settings';
|
||||
import { pairSig } from '../utils/pair';
|
||||
import { pickNextPairIndices } from '../domain/matchmaking/Matchmaker';
|
||||
import type { MatchResult, ScrollStartMode, UndoFrame } from '../types';
|
||||
import { writeFrontmatterStatsForPair } from '../utils/FrontmatterStats';
|
||||
import { ensureEloId, getEloId } from '../utils/NoteIds';
|
||||
import { pairSig } from '../utils/pair';
|
||||
import { attempt, attemptAsync } from '../utils/safe';
|
||||
import type { ArenaLayoutHandle} from './LayoutManager';
|
||||
import { ArenaLayoutManager } from './LayoutManager';
|
||||
|
||||
export default class ArenaSession {
|
||||
private app: App;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { App, Setting } from 'obsidian';
|
||||
import { FM_PROP_KEYS, renderStandardFmPropertyRow } from './FrontmatterPropertyRow';
|
||||
import type { FrontmatterPropertiesSettings, FrontmatterPropertyConfig } from '../settings';
|
||||
import type { App} from 'obsidian';
|
||||
import { Setting } from 'obsidian';
|
||||
|
||||
import { BasePromiseModal } from './PromiseModal';
|
||||
import type EloPlugin from '../main';
|
||||
import type { FrontmatterPropertiesSettings, FrontmatterPropertyConfig } from '../settings';
|
||||
import type { ScrollStartMode } from '../types';
|
||||
import { FM_PROP_KEYS, renderStandardFmPropertyRow } from './FrontmatterPropertyRow';
|
||||
import { BasePromiseModal } from './PromiseModal';
|
||||
|
||||
type Mode = 'create' | 'edit';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,21 @@
|
|||
import { App, ButtonComponent, FuzzySuggestModal, Notice, Setting, TFile } from 'obsidian';
|
||||
import { BasePromiseFuzzyModal, BasePromiseModal } from './PromiseModal';
|
||||
import type { App, ButtonComponent, TFile } from 'obsidian';
|
||||
import { FuzzySuggestModal, Notice, Setting } from 'obsidian';
|
||||
|
||||
import { listBaseFiles, readBaseViews } from '../domain/bases/BasesDiscovery';
|
||||
import {
|
||||
createDefinition,
|
||||
getFileTags,
|
||||
parseCohortKey,
|
||||
prettyCohortDefinition,
|
||||
} from '../domain/cohort/CohortResolver';
|
||||
import { listBaseFiles, readBaseViews } from '../domain/bases/BasesDiscovery';
|
||||
|
||||
import { CohortDefinition } from '../types';
|
||||
import { CohortOptionsModal } from './CohortOptionsModal';
|
||||
import type EloPlugin from '../main';
|
||||
import { FolderSelectModal } from './FolderPicker';
|
||||
import type { FrontmatterPropertiesSettings } from '../settings';
|
||||
import type { CohortDefinition } from '../types';
|
||||
import type { ScrollStartMode } from '../types';
|
||||
import { normaliseTag } from '../utils/tags';
|
||||
import { CohortOptionsModal } from './CohortOptionsModal';
|
||||
import { FolderSelectModal } from './FolderPicker';
|
||||
import { BasePromiseFuzzyModal, BasePromiseModal } from './PromiseModal';
|
||||
|
||||
type Action = 'vault-all' | 'active-folder' | 'pick-folder' | 'tag-dialog' | 'base-dialog';
|
||||
type Choice =
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { App, TFolder } from 'obsidian';
|
||||
import type { App, TFolder } from 'obsidian';
|
||||
|
||||
import { BasePromiseFuzzyModal } from './PromiseModal';
|
||||
import { allFolderChoices } from '../domain/cohort/CohortResolver';
|
||||
import { BasePromiseFuzzyModal } from './PromiseModal';
|
||||
|
||||
export class FolderSelectModal extends BasePromiseFuzzyModal<TFolder> {
|
||||
private folders: TFolder[];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { Setting, TextComponent, ToggleComponent } from 'obsidian';
|
||||
import type { TextComponent, ToggleComponent } from 'obsidian';
|
||||
import { Setting } from 'obsidian';
|
||||
|
||||
export type FmPropKey = 'rating' | 'rank' | 'matches' | 'wins';
|
||||
export const FM_PROP_KEYS: readonly FmPropKey[] = ['rating', 'rank', 'matches', 'wins'] as const;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { App, Notice, ViewState, WorkspaceLeaf } from 'obsidian';
|
||||
import { attempt, attemptAsync } from '../utils/safe';
|
||||
import type { App, ViewState, WorkspaceLeaf } from 'obsidian';
|
||||
import { Notice } from 'obsidian';
|
||||
|
||||
import type { SessionLayoutMode } from '../settings';
|
||||
import { attempt, attemptAsync } from '../utils/safe';
|
||||
|
||||
export type ArenaLayoutHandle = {
|
||||
leftLeaf: WorkspaceLeaf;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { App, FuzzySuggestModal, Modal } from 'obsidian';
|
||||
import type { App} from 'obsidian';
|
||||
import { FuzzySuggestModal, Modal } from 'obsidian';
|
||||
|
||||
// Base for standard Modals that return a value via a Promise.
|
||||
export class BasePromiseModal<T> extends Modal {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { App, Notice, Setting, TFile } from 'obsidian';
|
||||
import type { App} from 'obsidian';
|
||||
import { Notice, Setting, TFile } from 'obsidian';
|
||||
|
||||
import { listBaseFiles, readBaseViews, type BaseViewInfo } from '../domain/bases/BasesDiscovery';
|
||||
import { type BaseViewInfo,listBaseFiles, readBaseViews } from '../domain/bases/BasesDiscovery';
|
||||
import { BasePromiseFuzzyModal, BasePromiseModal } from './PromiseModal';
|
||||
|
||||
type BaseViewChoice = { view: string; label: string };
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { App, Setting } from 'obsidian';
|
||||
import type { App} from 'obsidian';
|
||||
import { Setting } from 'obsidian';
|
||||
|
||||
import { BasePromiseModal } from './PromiseModal';
|
||||
import { FolderSelectModal } from './FolderPicker';
|
||||
import { getEloId } from '../utils/NoteIds';
|
||||
import { FolderSelectModal } from './FolderPicker';
|
||||
import { BasePromiseModal } from './PromiseModal';
|
||||
|
||||
type Suggestion = {
|
||||
path: string;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { App, Notice, TFile } from 'obsidian';
|
||||
import type { App} from 'obsidian';
|
||||
import { Notice, TFile } from 'obsidian';
|
||||
|
||||
import type { CohortDefinition } from '../types';
|
||||
import { PluginDataStore } from '../storage/PluginDataStore';
|
||||
import { ResolveMissingBaseModal } from '../ui/ResolveMissingBaseModal';
|
||||
import { makeCohortKey } from '../domain/cohort/CohortResolver';
|
||||
import { readBaseViews } from '../domain/bases/BasesDiscovery';
|
||||
import { makeCohortKey } from '../domain/cohort/CohortResolver';
|
||||
import type { PluginDataStore } from '../storage/PluginDataStore';
|
||||
import type { CohortDefinition } from '../types';
|
||||
import { ResolveMissingBaseModal } from '../ui/ResolveMissingBaseModal';
|
||||
|
||||
function getBaseFile(app: App, basePath: string): TFile | undefined {
|
||||
const af = app.vault.getAbstractFileByPath(basePath);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { App, Notice, TFolder } from 'obsidian';
|
||||
import type { App} from 'obsidian';
|
||||
import { Notice, TFolder } from 'obsidian';
|
||||
|
||||
import { CohortDefinition } from '../types';
|
||||
import { PluginDataStore } from '../storage/PluginDataStore';
|
||||
import { ResolveMissingFolderModal } from '../ui/ResolveMissingFolderModal';
|
||||
import { makeCohortKey } from '../domain/cohort/CohortResolver';
|
||||
import type { PluginDataStore } from '../storage/PluginDataStore';
|
||||
import type { CohortDefinition } from '../types';
|
||||
import { ResolveMissingFolderModal } from '../ui/ResolveMissingFolderModal';
|
||||
|
||||
export async function ensureFolderCohortPath(
|
||||
app: App,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { App, Notice, TFile } from 'obsidian';
|
||||
import type { App, TFile } from 'obsidian';
|
||||
import { Notice } from 'obsidian';
|
||||
|
||||
import { CohortData } from '../types';
|
||||
import type { FrontmatterPropertiesSettings } from '../settings';
|
||||
import type { CohortData } from '../types';
|
||||
import { getEloId } from './NoteIds';
|
||||
|
||||
type PlayerStats = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { App, TFile } from 'obsidian';
|
||||
import type { App, TFile } from 'obsidian';
|
||||
|
||||
// Matches HTML comments like: <!-- eloId: 123e4567-e89b-12d3-a456-426614174000 -->
|
||||
const ELO_ID_COMMENT_BASE = /<!--\s*eloId\s*:\s*([0-9A-Za-z][0-9A-Za-z._-]*)\s*-->/;
|
||||
|
|
|
|||
Loading…
Reference in a new issue