Skip to content

Commit 2c7b9f0

Browse files
committed
Fix lint for reducer
1 parent 1fa498a commit 2c7b9f0

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

web-vite/src/app/reducer/index.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ import { calculateStats, getFgbData } from "../map/utils.ts";
44
import tArea from "@turf/area";
55
import tBboxPolygon from "@turf/bbox-polygon";
66

7+
// TODO move to types.ts
8+
/* eslint-disable no-unused-vars */
79
export enum MapStatus {
810
IDLE = "IDLE",
911
LOADING = "LOADING",
1012
READY = "READY",
1113
}
1214

13-
export interface AppState {
14-
map: any;
15-
mapStatus: MapStatus;
16-
geojson?: any;
17-
currentTimestampGeojson?: any;
18-
}
19-
2015
export enum AppActionTypes {
2116
SET_MAP_REF = "SET_MAP_REF",
2217
SET_CURRENT_TIMESTAMP = "SET_CURRENT_TIMESTAMP",
@@ -26,6 +21,16 @@ export enum AppActionTypes {
2621
UPDATE_VIEW_ERROR = "UPDATE_VIEW_ERROR",
2722
}
2823

24+
export type AppReducer<State, Action> = (state: State, action: Action) => State;
25+
/* eslint-enable no-unused-vars */
26+
27+
export interface AppState {
28+
map: any;
29+
mapStatus: MapStatus;
30+
geojson?: any;
31+
currentTimestampGeojson?: any;
32+
}
33+
2934
export type AppAction =
3035
| {
3136
type: AppActionTypes.SET_MAP_REF;
@@ -62,13 +67,11 @@ export const appInitialState = {
6267
},
6368
};
6469

65-
export type AppReducer<State, Action> = (state: State, action: Action) => State;
66-
6770
function applyTimestampFilter(geojson: any, timestamp: string) {
6871
return {
6972
type: "FeatureCollection",
7073
features: geojson.features.filter(
71-
(f: any) => f.properties.timestamp === timestamp
74+
(f: any) => f.properties.timestamp === timestamp,
7275
),
7376
};
7477
}
@@ -91,17 +94,15 @@ function appReducer(state: AppState, action: AppAction) {
9194
const currentTimestamp = timestamps[timestamps.length - 1];
9295
const currentTimestampGeojson = applyTimestampFilter(
9396
geojson,
94-
currentTimestamp
97+
currentTimestamp,
9598
);
9699
const stats = calculateStats(currentTimestampGeojson);
97100

98101
const bounds = state.map.getBounds().toArray();
99102
const [[minX, minY], [maxX, maxY]] = bounds;
100103
const poly = tBboxPolygon([minX, minY, maxX, maxY]);
101104
const area = tArea(poly);
102-
const formattedArea = new Intl.NumberFormat().format(
103-
(area / 1e6).toFixed(2)
104-
);
105+
const formattedArea = new Intl.NumberFormat().format(area / 1e6);
105106

106107
return {
107108
...state,
@@ -118,7 +119,7 @@ function appReducer(state: AppState, action: AppAction) {
118119
const { currentTimestamp } = action.data;
119120
const currentTimestampGeojson = applyTimestampFilter(
120121
state.geojson,
121-
currentTimestamp
122+
currentTimestamp,
122123
);
123124
const stats = calculateStats(currentTimestampGeojson);
124125
return {
@@ -161,7 +162,7 @@ const asyncActionHandlers: any = {
161162
} catch (error) {
162163
console.log(error);
163164
alert(
164-
"Unexpected error while loading the map, please see console log."
165+
"Unexpected error while loading the map, please see console log.",
165166
);
166167
}
167168
},
@@ -171,6 +172,6 @@ export const useAppReducer = () => {
171172
return useReducerAsync(
172173
logReducer(appReducer),
173174
appInitialState,
174-
asyncActionHandlers
175+
asyncActionHandlers,
175176
);
176177
};

0 commit comments

Comments
 (0)