Fix lint warnings

This commit is contained in:
Przemek Więch
2026-05-12 00:29:35 +02:00
parent 05da5a5019
commit 20bddfaeb6
6 changed files with 47 additions and 30 deletions

View File

@@ -27,12 +27,13 @@ module.exports = {
],
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-explicit-any': 'error',
},
};

View File

@@ -437,6 +437,7 @@ export function App() {
setSelection(newSelection);
setDetailIndi(newSelection.id);
setState(AppState.SHOWING_CHART);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
setState(AppState.SHOWING_CHART);
displayErrorPopup(

View File

@@ -119,9 +119,9 @@ export function convertFams(people: Person[]): JsonFam[] {
if (husband) {
fam.husb = husband;
}
fam.children = Array.from(getSet(children, key)).map(
(child) => idToName.get(child)!,
);
fam.children = Array.from(getSet(children, key))
.map((child) => idToName.get(child))
.filter((x) => !!x) as string[];
if (
value.spouse &&
((value.spouse.marriage_date &&

View File

@@ -1,4 +1,12 @@
import f3 from 'family-chart';
import {
Datum,
Store,
TreeDatum,
createStore,
createSvg,
elements,
view,
} from 'family-chart';
import {useEffect, useRef} from 'react';
import {IntlShape, useIntl} from 'react-intl';
import {IndiInfo, JsonFam, JsonGedcomData} from 'topola';
@@ -15,7 +23,7 @@ function getOtherSpouse(fam: JsonFam, indi: string) {
return fam.husb === indi ? fam.wife : fam.husb;
}
function convertData(data: JsonGedcomData, intl: IntlShape) {
function convertData(data: JsonGedcomData, intl: IntlShape): Datum[] {
const famMap = new Map<string, JsonFam>();
data.fams.forEach((fam) => famMap.set(fam.id, fam));
return data.indis.map((indi) => {
@@ -25,6 +33,7 @@ function convertData(data: JsonGedcomData, intl: IntlShape) {
.filter((fam): fam is JsonFam => fam !== undefined);
const father = famc?.husb;
const mother = famc?.wife;
const parents = [father, mother].filter((x) => !!x);
const spouses = fams
.map((fam) => getOtherSpouse(fam, indi.id))
.filter((indi): indi is string => indi !== undefined);
@@ -40,40 +49,51 @@ function convertData(data: JsonGedcomData, intl: IntlShape) {
gender: indi.sex,
},
rels: {
father,
mother,
parents,
spouses,
children,
},
};
} as Datum;
});
}
class ChartWrapper {
private store?: any;
private store!: Store;
initializeChart(props: DonatsoChartProps, intl: IntlShape) {
const data = convertData(props.data, intl);
this.store = f3.createStore({
this.store = createStore({
data,
main_id: props.selection.id,
});
const svg = f3.createSvg(document.querySelector('#dotatsoSvgContainer'));
const card = f3.elements.Card({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const svg = createSvg(document.querySelector('#dotatsoSvgContainer')!);
const card = elements.CardSvg({
store: this.store,
svg,
card_display: [
(i: any) =>
(i: Datum) =>
`${i.data['first name'] || ''} ${i.data['last name'] || ''}`,
(i: any) => `${i.data.birthday || ''}`,
],
(i: Datum) => `${i.data.birthday || ''}`,
] as any, // eslint-disable-line @typescript-eslint/no-explicit-any
mini_tree: true,
link_break: false,
onCardClick: (e: any, d: any) =>
onCardClick: (e: MouseEvent, d: TreeDatum) =>
props.onSelection({id: d.data.id, generation: 0}),
card_dim: {
w: 220,
h: 70,
text_x: 75,
text_y: 15,
img_w: 60,
img_h: 60,
img_x: 5,
img_y: 5,
},
});
this.store.setOnUpdate((props: any) => {
f3.view(this.store.getTree(), svg, card, props || {});
this.store.setOnUpdate((props: unknown) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
view(this.store.getTree()!, svg, card, props || {});
});
this.store.updateTree({initial: true});
}

View File

@@ -1,8 +0,0 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// Data type definitions for the family-chart library.
declare module 'family-chart' {
export function createStore(args: any): any;
export function createSvg(args: any): any;
export function view(arg1: any, arg2: any, arg3: any, arg4: any): any;
export const elements: any;
}

View File

@@ -104,7 +104,7 @@ class LunrSearchIndex implements SearchIndex {
}
private initMultiLingualLunrWithoutTrimmer(
lunrInstance: any,
lunrInstance: lunr.Builder,
languages: string[],
): void {
const pipelineFunctions: PipelineFunction[] = [];
@@ -142,13 +142,16 @@ class LunrSearchIndex implements SearchIndex {
.filter((s) => !!s)
.map((s) => `${s} ${s}*`)
.join(' ');
const results = this.index!.search(query);
const results = this.index.search(query);
return results
.sort(compare)
.slice(0, MAX_RESULTS)
.map((result) => ({
id: result.ref,
indi: this.indiMap.get(result.ref)!,
indi: this.indiMap.get(result.ref) || {
id: result.ref,
firstName: 'INDI NOT FOUND',
},
}));
}
}