Skip to content

Commit 947a749

Browse files
committed
More lint fixes...
1 parent 05e3410 commit 947a749

File tree

8 files changed

+42
-27
lines changed

8 files changed

+42
-27
lines changed
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
import type { ComponentChildren } from "preact";
2+
13
interface LayoutProps {
2-
children: any;
4+
children: ComponentChildren;
5+
}
6+
export function Layout(props: LayoutProps) {
7+
return <div class="layout">{props.children}</div>;
38
}
4-
export function Layout(props: LayoutProps){
5-
return (
6-
<div class="layout">
7-
{props.children}
8-
</div>
9-
)
10-
}

packages/web/src/app/map/index.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from "preact/hooks";
2-
import MapLibreGL from "maplibre-gl";
2+
import MapLibreGL, { MapMouseEvent } from "maplibre-gl";
33
import { AppActionTypes, AppDispatch, AppState } from "../reducer";
44

55
interface MapProps {
@@ -9,7 +9,7 @@ interface MapProps {
99

1010
const MAP_OPTIONS = {
1111
center: [-74, 40.6973],
12-
zoom: 8,
12+
zoom: 10,
1313
} as {
1414
center: [number, number];
1515
zoom: number;
@@ -162,16 +162,27 @@ export function Map(props: MapProps) {
162162
},
163163
});
164164

165-
function onClick(e: any) {
166-
const props = e.features[0].properties;
165+
function onClick(e: MapMouseEvent) {
166+
// @ts-expect-error - MapMouseEvent doesn't know about features
167+
const features = e.features as GeoJSON.Feature[];
168+
169+
if (!features || features.length === 0) {
170+
return;
171+
}
172+
const { properties } = features[0];
173+
174+
if (!properties) {
175+
return;
176+
}
177+
167178
let tags = "";
168-
const tagObject = JSON.parse(props.tags);
179+
const tagObject = JSON.parse(properties.tags);
169180
for (const [key, value] of Object.entries(tagObject)) {
170181
tags = tags + "<dt>" + key + "=" + value + "</dt>";
171182
}
172-
const html = `<dl><dt><b>action:</b> ${props.action}</dt>
173-
<dt><b>id:</b> ${props.id}</dt>
174-
<dt><b>user:</b> ${props.user}<dt>
183+
const html = `<dl><dt><b>action:</b> ${properties.action}</dt>
184+
<dt><b>id:</b> ${properties.id}</dt>
185+
<dt><b>user:</b> ${properties.user}<dt>
175186
<br />
176187
${tags}
177188
</dl>`;

packages/web/src/app/map/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface Stats {
1+
export interface Stats {
22
tags: Record<string, number>;
33
buildings: number;
44
buildingsAdded: number;

packages/web/src/app/panel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import type { ComponentChildren } from "preact";
12
import { useState } from "preact/hooks";
23

34
// TODO - Fix accessibility issues in this file and remove the following
45
/* eslint-disable jsx-a11y/no-static-element-interactions */
56
/* eslint-disable jsx-a11y/click-events-have-key-events */
67
interface PanelProps {
7-
children: any;
8+
children: ComponentChildren;
89
}
910
export function Panel(props: PanelProps) {
1011
const [openPanel, setOpenPanel] = useState(false);

packages/web/src/app/reducer/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { AsyncActionHandlers, useReducerAsync } from "use-reducer-async";
1+
import { useReducerAsync } from "use-reducer-async";
2+
// eslint-disable-next-line no-duplicate-imports
3+
import type { AsyncActionHandlers } from "use-reducer-async";
24
import logReducer from "./log.ts";
35
import { calculateStats } from "../map/utils.ts";
46
import tArea from "@turf/area";
57
import tBboxPolygon from "@turf/bbox-polygon";
68
import { getFgbData } from "../utils/get-fgb-data.ts";
79
import { Map } from "maplibre-gl";
8-
import { Dispatch, Reducer } from "preact/hooks";
10+
import type { Dispatch, Reducer } from "preact/hooks";
911

1012
const availableTimestamps = [
1113
`2024-05-19T05:00:00Z`,

packages/web/src/app/reducer/log.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import type { Reducer } from "preact/hooks";
12
import { AppAction, AppState } from ".";
23

3-
export default function logReducer(reducer: any) {
4+
export default function logReducer(reducer: Reducer<AppState, AppAction>) {
45
/* eslint-disable no-console */
56
return (state: AppState, action: AppAction) => {
67
const nextState = reducer(state, action);
@@ -13,7 +14,7 @@ export default function logReducer(reducer: any) {
1314
"%c%s",
1415
"color: green; font-weight: bold",
1516
"next state ",
16-
nextState
17+
nextState,
1718
);
1819
console.groupEnd();
1920

packages/web/src/app/stats.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { useState } from "preact/hooks";
2+
import type { Stats } from "./map/utils";
23

34
interface StatsProps {
4-
stats: any;
5+
stats: Stats;
56
loading: boolean;
67
currentTimestamp?: string;
78
}
@@ -108,8 +109,9 @@ export function Stats(props: StatsProps) {
108109
</article>
109110
);
110111
}
111-
const sortedUsers: any[] = [];
112-
const sortedTags: any[] = [];
112+
113+
const sortedUsers: [string, number][] = [];
114+
const sortedTags: [string, number][] = [];
113115
Object.keys(stats.users).forEach((user) => {
114116
sortedUsers.push([user, stats.users[user]]);
115117
});

packages/web/src/app/time-navigator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { addHours, addDays, subDays, subHours } from "date-fns";
22
import { AppActionTypes, AppDispatch, AppState } from "./reducer";
3-
import { ComponentChild } from "preact";
3+
import type { ComponentChildren } from "preact";
44

55
function LoadingSkeleton() {
66
return (
@@ -17,7 +17,7 @@ const TimeChangeButton = ({
1717
}: {
1818
dispatchAppState: AppDispatch;
1919
nextTimestamp: Date;
20-
children: ComponentChild;
20+
children: ComponentChildren;
2121
}) => (
2222
<button
2323
onClick={(e) => {

0 commit comments

Comments
 (0)