Skip to content

Commit 77d2f8f

Browse files
authored
Merge pull request #279 from commonknowledge/fix/lint
fix: lint issues (mostly just ignored) after upgrading React
2 parents ad2b7f5 + 502129b commit 77d2f8f

File tree

17 files changed

+96
-87
lines changed

17 files changed

+96
-87
lines changed

eslint.config.mjs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
import { dirname } from "path";
2-
import { fileURLToPath } from "url";
3-
import { FlatCompat } from "@eslint/eslintrc";
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
import nextVitals from "eslint-config-next/core-web-vitals";
3+
import nextTypeScript from "eslint-config-next/typescript";
44
import unusedImports from "eslint-plugin-unused-imports";
55
import tseslint from "typescript-eslint";
66

7-
const __filename = fileURLToPath(import.meta.url);
8-
const __dirname = dirname(__filename);
9-
10-
const compat = new FlatCompat({
11-
baseDirectory: __dirname,
12-
});
13-
14-
const eslintConfig = [
15-
{
16-
ignores: [".next", ".sanity", "next-env.d.ts"],
17-
},
18-
...compat.extends("next/core-web-vitals", "next/typescript"),
7+
const eslintConfig = defineConfig([
8+
...nextVitals,
9+
...nextTypeScript,
1910
...tseslint.configs.strict,
2011
...tseslint.configs.stylistic,
2112
{
@@ -24,7 +15,6 @@ const eslintConfig = [
2415
},
2516
rules: {
2617
"@typescript-eslint/consistent-type-imports": "error",
27-
"unused-imports/no-unused-imports": "error",
2818
"import/order": [
2919
"error",
3020
{
@@ -44,20 +34,18 @@ const eslintConfig = [
4434
],
4535
},
4636
],
47-
// Disable resolve checking as this is handled by typescript
4837
"import/no-unresolved": "off",
49-
// Import sorting is handled by the import/order rule.
50-
// However, sort-imports also sorts symbols inside a multi-import
51-
// e.g. import { a, b, c } from "d"
52-
// Setting `ignoreDeclarationSort: true` restricts it to only this behavior.
38+
"react-hooks/set-state-in-effect": "off",
5339
"sort-imports": [
5440
"error",
5541
{
5642
ignoreDeclarationSort: true,
5743
},
5844
],
45+
"unused-imports/no-unused-imports": "error",
5946
},
6047
},
61-
];
48+
globalIgnores([".next/**", ".sanity/**", "next-env.d.ts"]),
49+
]);
6250

6351
export default eslintConfig;

package-lock.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/(auth)/invite/[token]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default function InvitePage() {
2828
const { mutate: confirmInvite, isPending } = useMutation(
2929
trpc.auth.confirmInvite.mutationOptions({
3030
onSuccess: () => {
31+
// eslint-disable-next-line react-hooks/immutability
3132
window.location.href = "/dashboard";
3233
},
3334
onError: (error) => {

src/app/(private)/data-sources/[id]/DataSourceDashboard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ export function DataSourceDashboard({
228228
const isImporting = (dataSource: RouterOutputs["dataSource"]["byId"]) => {
229229
return Boolean(
230230
dataSource?.importInfo?.status &&
231-
[JobStatus.Running, JobStatus.Pending].includes(
232-
dataSource.importInfo?.status,
233-
),
231+
[JobStatus.Running, JobStatus.Pending].includes(
232+
dataSource.importInfo?.status,
233+
),
234234
);
235235
};
236236

src/app/(private)/data-sources/[id]/DataSourceEnrichmentDashboard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ export function DataSourceEnrichmentDashboard({
185185
const isEnriching = (dataSource: RouterOutputs["dataSource"]["byId"]) => {
186186
return Boolean(
187187
dataSource?.enrichmentInfo?.status &&
188-
[JobStatus.Running, JobStatus.Pending].includes(
189-
dataSource.enrichmentInfo?.status,
190-
),
188+
[JobStatus.Running, JobStatus.Pending].includes(
189+
dataSource.enrichmentInfo?.status,
190+
),
191191
);
192192
};

src/app/map/[id]/components/Legend.tsx

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default function Legend() {
4040
const hasDataSource = Boolean(viewConfig.areaDataSourceId);
4141
const hasColumn = Boolean(
4242
viewConfig.areaDataColumn ||
43-
viewConfig.calculationType === CalculationType.Count,
43+
viewConfig.calculationType === CalculationType.Count,
4444
);
4545
const isBivariate =
4646
areaStats?.calculationType !== CalculationType.Count &&
@@ -244,30 +244,6 @@ export default function Legend() {
244244
}
245245
};
246246

247-
const VisibilityToggle = () => (
248-
<div className="opacity-0 group-hover:opacity-100 transition-opacity ml-2 shrink-0">
249-
<div
250-
role="button"
251-
tabIndex={0}
252-
className="p-2 rounded bg-neutral-100 hover:bg-neutral-200 cursor-pointer transition-colors"
253-
aria-label={isLayerVisible ? "Hide layer" : "Show layer"}
254-
onClick={(e) => {
255-
e.stopPropagation();
256-
toggleLayerVisibility();
257-
}}
258-
onKeyDown={(e) => {
259-
if (e.key === "Enter" || e.key === " ") {
260-
e.preventDefault();
261-
e.stopPropagation();
262-
toggleLayerVisibility();
263-
}
264-
}}
265-
>
266-
{isLayerVisible ? <Eye size={16} /> : <EyeOff size={16} />}
267-
</div>
268-
</div>
269-
);
270-
271247
return (
272248
<div className="group flex flex-col gap-1 rounded-sm overflow-auto bg-white border border-neutral-200 w-full">
273249
<div
@@ -291,7 +267,10 @@ export default function Legend() {
291267
<ChevronRight className="w-4 h-4" />
292268
<p className="flex items-center gap-0.5">{getColumnLabel()}</p>
293269
</div>
294-
<VisibilityToggle />
270+
<VisibilityToggle
271+
isLayerVisible={isLayerVisible}
272+
toggleLayerVisibility={toggleLayerVisibility}
273+
/>
295274
</div>
296275
{isLoading ? (
297276
<div className="flex items-center justify-center px-2 py-4">
@@ -309,3 +288,33 @@ export default function Legend() {
309288
</div>
310289
);
311290
}
291+
292+
const VisibilityToggle = ({
293+
isLayerVisible,
294+
toggleLayerVisibility,
295+
}: {
296+
isLayerVisible: boolean;
297+
toggleLayerVisibility: () => void;
298+
}) => (
299+
<div className="opacity-0 group-hover:opacity-100 transition-opacity ml-2 shrink-0">
300+
<div
301+
role="button"
302+
tabIndex={0}
303+
className="p-2 rounded bg-neutral-100 hover:bg-neutral-200 cursor-pointer transition-colors"
304+
aria-label={isLayerVisible ? "Hide layer" : "Show layer"}
305+
onClick={(e) => {
306+
e.stopPropagation();
307+
toggleLayerVisibility();
308+
}}
309+
onKeyDown={(e) => {
310+
if (e.key === "Enter" || e.key === " ") {
311+
e.preventDefault();
312+
e.stopPropagation();
313+
toggleLayerVisibility();
314+
}
315+
}}
316+
>
317+
{isLayerVisible ? <Eye size={16} /> : <EyeOff size={16} />}
318+
</div>
319+
</div>
320+
);

src/app/map/[id]/components/SearchBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export function SearchBox() {
1414

1515
return (
1616
<div className={styles["search-box"]}>
17-
{/* @ts-expect-error The MapBox SearchBox component fails React component typescript validation, but it does work */}
1817
<_SearchBox
1918
theme={{
2019
variables: {
@@ -27,6 +26,7 @@ export function SearchBox() {
2726
flip: true,
2827
}}
2928
accessToken={process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN || ""}
29+
// eslint-disable-next-line react-hooks/refs
3030
map={mapRef?.current?.getMap()}
3131
mapboxgl={mapboxgl}
3232
options={{ country: "GB" }}

src/app/map/[id]/components/ZoomControl.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function ZoomControl() {
88
const zoomIn = () => map?.zoomIn({ duration: 500 });
99
const zoomOut = () => map?.zoomOut({ duration: 500 });
1010

11+
// eslint-disable-next-line react-hooks/refs
1112
if (!map) {
1213
return <></>;
1314
}

src/app/map/[id]/components/controls/MarkersControl/MarkersControl.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ export default function MarkersControl() {
189189
setExpanded={setExpanded}
190190
enableVisibilityToggle={Boolean(
191191
placedMarkers.length > 0 ||
192-
markerDataSources.length > 0 ||
193-
membersDataSource,
192+
markerDataSources.length > 0 ||
193+
membersDataSource,
194194
)}
195195
>
196196
{loading && <LoaderPinwheel className="animate-spin" size={16} />}

src/app/map/[id]/components/inspector/BoundaryDataPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function BoundaryDataPanel({
5252
}
5353
});
5454
return filtered;
55-
}, [data?.json, columns]);
55+
}, [data, columns]);
5656

5757
return (
5858
<TogglePanel

0 commit comments

Comments
 (0)