Improve code quality

Fix lint warnings
This commit is contained in:
Przemek Więch
2026-05-10 21:56:51 +02:00
parent ea82bc4c98
commit 8202c9cd05
29 changed files with 315 additions and 221 deletions

View File

@@ -33,9 +33,9 @@ export interface EmbeddedSourceSpec {
/** GEDCOM file received from outside of the iframe. */
export class EmbeddedDataSource implements DataSource<EmbeddedSourceSpec> {
isNewData(
newSource: SourceSelection<EmbeddedSourceSpec>,
oldSource: SourceSelection<EmbeddedSourceSpec>,
data?: TopolaData,
_newSource: SourceSelection<EmbeddedSourceSpec>,
_oldSource: SourceSelection<EmbeddedSourceSpec>,
_data?: TopolaData,
): boolean {
// Never reload data.
return false;
@@ -44,7 +44,7 @@ export class EmbeddedDataSource implements DataSource<EmbeddedSourceSpec> {
private async onMessage(
message: EmbeddedMessage,
resolve: (value: TopolaData) => void,
reject: (reason: any) => void,
reject: (reason: unknown) => void,
) {
if (message.message === EmbeddedMessageType.PARENT_READY) {
// Parent didn't receive the first 'ready' message, so we need to send it again.
@@ -69,7 +69,7 @@ export class EmbeddedDataSource implements DataSource<EmbeddedSourceSpec> {
}
async loadData(
source: SourceSelection<EmbeddedSourceSpec>,
_source: SourceSelection<EmbeddedSourceSpec>,
): Promise<TopolaData> {
// Notify the parent window that we are ready.
return new Promise<TopolaData>((resolve, reject) => {

View File

@@ -27,7 +27,8 @@ const MONTHS = new Map<number, string>([
]);
function dateToGedcom(date: Date): string {
return [date.qualifier, date.day, MONTHS.get(date.month!), date.year]
const month = (date.month && MONTHS.get(date.month)) || undefined;
return [date.qualifier, date.day, month, date.year]
.filter((x) => x !== undefined)
.join(' ');
}

View File

@@ -151,13 +151,18 @@ export interface UploadSourceSpec {
images?: Map<string, string>;
}
export interface UploadLocationState {
data: string;
images: Map<string, string>;
}
/** Files opened from the local computer. */
export class UploadedDataSource implements DataSource<UploadSourceSpec> {
// isNewData(args: Arguments, state: State): boolean {
isNewData(
newSource: SourceSelection<UploadSourceSpec>,
oldSource: SourceSelection<UploadSourceSpec>,
data?: TopolaData,
_data?: TopolaData,
): boolean {
return newSource.spec.hash !== oldSource.spec.hash;
}
@@ -196,7 +201,7 @@ export class GedcomUrlDataSource implements DataSource<UrlSourceSpec> {
isNewData(
newSource: SourceSelection<UrlSourceSpec>,
oldSource: SourceSelection<UrlSourceSpec>,
data?: TopolaData,
_data?: TopolaData,
): boolean {
return newSource.spec.url !== oldSource.spec.url;
}

View File

@@ -42,6 +42,7 @@ export async function loadWikiTree(
.filter((person) => person.PhotoData?.path)
.map((person) => [
person.Name,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
`https://www.wikitree.com${person.PhotoData!.path}`,
]),
);

View File

@@ -1,5 +1,12 @@
import {IntlShape} from 'react-intl';
import {DateOrRange, JsonEvent, JsonFam, JsonImage, JsonIndi} from 'topola';
import {
Date,
DateOrRange,
JsonEvent,
JsonFam,
JsonImage,
JsonIndi,
} from 'topola';
import {StringUtils} from 'turbocommons-ts';
import {Person} from 'wikitree-js';
import {PRIVATE_ID_PREFIX} from './wikitree_api';
@@ -274,7 +281,7 @@ function parseDate(date: string, dataStatus?: string): DateOrRange | undefined {
if (!matchedDate) {
return {date: {text: date}};
}
const parsedDate: any = {};
const parsedDate: Date = {};
if (matchedDate[1] !== '0000') {
parsedDate.year = ~~matchedDate[1];
}