Skip to content

Commit

Permalink
Merge pull request #81 from anyone-oslo/update-eslint
Browse files Browse the repository at this point in the history
Update eslint
  • Loading branch information
elektronaut authored Aug 27, 2024
2 parents e921a5d + bc696ff commit e2876d4
Show file tree
Hide file tree
Showing 31 changed files with 2,612 additions and 2,883 deletions.
35 changes: 0 additions & 35 deletions .eslintrc.js

This file was deleted.

894 changes: 0 additions & 894 deletions .yarn/releases/yarn-4.3.0.cjs

This file was deleted.

925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.4.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.3.0.cjs
yarnPath: .yarn/releases/yarn-4.4.0.cjs
2 changes: 1 addition & 1 deletion app/assets/builds/pages_core/admin-dist.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions app/assets/builds/pages_core/admin-dist.js.map

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions app/javascript/components/DateRangeSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useCallback, useEffect, useState } from "react";

import DateTimeSelect from "./DateTimeSelect";

Expand Down Expand Up @@ -50,13 +50,16 @@ export default function DateRangeSelect(props: Props) {
const endsAt = parseDate(props.setEndsAt ? props.endsAt : uncontrolledEndsAt);
const setEndsAt = props.setEndsAt || setUncontrolledEndsAt;

const setDates = (start: Date, end: Date) => {
if (end < start) {
end = start;
}
setStartsAt(start);
setEndsAt(end);
};
const setDates = useCallback(
(start: Date, end: Date) => {
if (end < start) {
end = start;
}
setStartsAt(start);
setEndsAt(end);
},
[setStartsAt, setEndsAt]
);

const changeStartsAt = (newDate: Date) => {
setDates(
Expand All @@ -73,7 +76,7 @@ export default function DateRangeSelect(props: Props) {
if (!startsAt || !endsAt) {
setDates(startsAt || defaultDate(), endsAt || defaultDate(60));
}
}, [startsAt, endsAt]);
}, [startsAt, endsAt, setDates]);

return (
<div className="date-range-select">
Expand Down
18 changes: 9 additions & 9 deletions app/javascript/components/ImageCropper/useCrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,19 @@ export default function useCrop(

const [croppedImage, setCroppedImage] = useState<string | null>(null);

async function updateCroppedImage() {
const img: HTMLImageElement = new Image();
img.src = state.image.uncropped_url;
await img.decode();
const [canvas, ctx] = croppedImageCanvas(img, cropSize(state));
setCroppedImage(imageDataUrl(canvas, ctx));
}

useEffect(() => {
async function updateCroppedImage() {
const img: HTMLImageElement = new Image();
img.src = state.image.uncropped_url;
await img.decode();
const [canvas, ctx] = croppedImageCanvas(img, cropSize(state));
setCroppedImage(imageDataUrl(canvas, ctx));
}

if (!state.cropping) {
void updateCroppedImage();
}
}, [state.cropping]);
}, [state]);

return [state, dispatch, croppedImage];
}
2 changes: 1 addition & 1 deletion app/javascript/components/ImageGrid/GridImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function GridImage(props: Props) {
reader.onload = () => setSrc(reader.result as string);
reader.readAsDataURL(record.file);
}
}, []);
}, [record]);

const copyEmbed = (evt: MouseEvent) => {
evt.preventDefault();
Expand Down
29 changes: 16 additions & 13 deletions app/javascript/components/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import React, { MouseEvent, useEffect } from "react";
import React, { useCallback, MouseEvent, useEffect } from "react";

import useModalStore from "../stores/useModalStore";

export default function Modal() {
const component = useModalStore((state) => state.component);
const close = useModalStore((state) => state.close);

const handleClose = (evt: KeyboardEvent | MouseEvent) => {
evt.stopPropagation();
evt.preventDefault();
close();
};

const handleKeypress = (evt: KeyboardEvent) => {
if (component && (evt.key == "Escape" || evt.keyCode === 27)) {
handleClose(evt);
}
};
const handleClose = useCallback(
(evt: KeyboardEvent | MouseEvent) => {
evt.stopPropagation();
evt.preventDefault();
close();
},
[close]
);

useEffect(() => {
if (component) {
Expand All @@ -27,11 +24,17 @@ export default function Modal() {
}, [component]);

useEffect(() => {
const handleKeypress = (evt: KeyboardEvent) => {
if (component && (evt.key == "Escape" || evt.keyCode === 27)) {
handleClose(evt);
}
};

window.addEventListener("keypress", handleKeypress);
return () => {
window.removeEventListener("keypress", handleKeypress);
};
}, []);
}, [component, handleClose]);

if (component) {
return (
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/components/PageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function PageForm(props: Props) {
if (history) {
history.replaceState(null, "", pageUrl);
}
}, [page.id, locale, tab]);
}, [page.id, page.parent_page_id, locale, tab]);

const handlePreview = (evt: React.MouseEvent) => {
evt.preventDefault();
Expand Down
Loading

0 comments on commit e2876d4

Please sign in to comment.