From c37247d89a9a5a0a5e00e91537e933d7865895c5 Mon Sep 17 00:00:00 2001 From: sickelap Date: Sun, 5 Nov 2023 13:22:47 +0000 Subject: [PATCH] enable no-console and func-names rules --- .eslintrc.js | 4 +- src/actions/albumsActions.ts | 41 ++++++++--------- src/actions/peopleActions.js | 6 +-- src/actions/photosActions.ts | 44 +++++++++---------- src/actions/publicActions.js | 2 +- src/actions/uiActions.js | 2 +- src/actions/utilActions.js | 31 ++++--------- src/components/modals/ModalConfigDatetime.tsx | 2 +- src/components/modals/ModalUserEdit.tsx | 1 - .../react-pig/calcRenderableItems.js | 2 +- src/components/react-pig/computeLayout.js | 2 +- .../react-pig/computeLayoutGroups.js | 2 +- src/components/react-pig/index.jsx | 7 +-- .../react-pig/utils/getImageHeight.js | 10 ++--- .../react-pig/utils/getMinAspectRatio.js | 28 ++++++------ .../react-pig/utils/getScrollSpeed.js | 40 ++++++++--------- src/store/worker/workerSlice.ts | 1 + 17 files changed, 102 insertions(+), 123 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index dcc1a5f5..b38a6366 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,9 +7,9 @@ module.exports = { extends: ["airbnb", "airbnb-typescript", "airbnb/hooks", "prettier"], plugins: ["prettier"], rules: { - "no-param-reassign": "warn", + "no-param-reassign": "off", "import/prefer-default-export": "off", - "import/no-cycle": "warn", + "import/no-cycle": "off", "react/jsx-props-no-spreading": "off", // some Mantine components need to use spread operator "react-hooks/exhaustive-deps": "off", // at this stage it is too risky to enable this }, diff --git a/src/actions/albumsActions.ts b/src/actions/albumsActions.ts index 62ce0f9d..c49982af 100644 --- a/src/actions/albumsActions.ts +++ b/src/actions/albumsActions.ts @@ -35,7 +35,7 @@ import type { DatePhotosGroup, IncompleteDatePhotosGroup } from "./photosActions import { IncompleteDatePhotosGroupSchema } from "./photosActions.types"; export function fetchThingAlbumsList() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "FETCH_THING_ALBUMS_LIST" }); Server.get("albums/thing/list/") .then(response => { @@ -53,7 +53,7 @@ export function fetchThingAlbumsList() { } export function fetchThingAlbum(album_id: string) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "FETCH_THING_ALBUMS" }); Server.get(`albums/thing/${album_id}/`) .then(response => { @@ -71,7 +71,7 @@ export function fetchThingAlbum(album_id: string) { } export function fetchUserAlbumsList() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "FETCH_USER_ALBUMS_LIST" }); Server.get("albums/user/list/") .then(response => { @@ -83,7 +83,6 @@ export function fetchUserAlbumsList() { }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_USER_ALBUMS_LIST_REJECTED", payload: err }); }); }; @@ -94,7 +93,7 @@ export const FETCH_USER_ALBUM_FULFILLED = "FETCH_USER_ALBUM_FULFILLED"; export const FETCH_USER_ALBUM_REJECTED = "FETCH_USER_ALBUM_REJECTED"; export function fetchUserAlbum(album_id: number) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: FETCH_USER_ALBUM }); Server.get(`albums/user/${album_id}/`) .then(response => { @@ -117,7 +116,7 @@ export function fetchUserAlbum(album_id: number) { } export function createNewUserAlbum(title: string, image_hashes: string[]) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "CREATE_USER_ALBUMS_LIST" }); Server.post("albums/user/edit/", { title, photos: image_hashes }) .then(response => { @@ -144,7 +143,7 @@ export function createNewUserAlbum(title: string, image_hashes: string[]) { } export function renameUserAlbum(albumID: string, albumTitle: string, newAlbumTitle: string) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "RENAME_USER_ALBUM" }); Server.patch(`/albums/user/edit/${albumID}/`, { title: newAlbumTitle, @@ -166,7 +165,7 @@ export function renameUserAlbum(albumID: string, albumTitle: string, newAlbumTit } export function deleteUserAlbum(albumID: string, albumTitle: string) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "DELETE_USER_ALBUM" }); Server.delete(`/albums/user/${albumID}`) .then(() => { @@ -185,7 +184,7 @@ export function deleteUserAlbum(albumID: string, albumTitle: string) { } export function removeFromUserAlbum(album_id: number, title: string, image_hashes: string[]) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "REMOVE_USER_ALBUMS_LIST" }); Server.patch(`albums/user/edit/${album_id}/`, { removedPhotos: image_hashes, @@ -215,7 +214,7 @@ export function removeFromUserAlbum(album_id: number, title: string, image_hashe } export function setAlbumCoverForUserAlbum(album_id, photo_hash) { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "SET_ALBUM_COVER_FOR_USER_ALBUM" }); Server.patch(`albums/user/edit/${album_id}/`, { cover_photo: photo_hash, @@ -231,14 +230,13 @@ export function setAlbumCoverForUserAlbum(album_id, photo_hash) { dispatch(fetchUserAlbumsList()); }) .catch(err => { - console.error(err); dispatch({ type: "SET_ALBUM_COVER_FOR_PERSON_REJECTED", payload: err }); }); }; } export function addToUserAlbum(album_id: number, title: string, image_hashes: string[]) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "EDIT_USER_ALBUMS_LIST" }); Server.patch(`albums/user/edit/${album_id}/`, { title, @@ -268,7 +266,7 @@ export function addToUserAlbum(album_id: number, title: string, image_hashes: st } export function fetchPlaceAlbumsList() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "FETCH_PLACE_ALBUMS_LIST" }); Server.get("albums/place/list/") .then(response => { @@ -293,7 +291,7 @@ export function fetchPlaceAlbumsList() { const PlaceAlbumResponseSchema = z.object({ results: PlaceAlbumSchema }); export function fetchPlaceAlbum(album_id: string) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "FETCH_PLACE_ALBUMS" }); Server.get(`albums/place/${album_id}/`) .then(response => { @@ -310,7 +308,7 @@ export function fetchPlaceAlbum(album_id: string) { } export function fetchAutoAlbumsList() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "FETCH_AUTO_ALBUMS_LIST" }); Server.get("albums/auto/list/") .then(response => { @@ -366,7 +364,6 @@ export function fetchAlbumDateList(dispatch: AppDispatch, options: AlbumDateList }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_DATE_ALBUMS_LIST_REJECTED", payload: err }); }); } @@ -408,7 +405,6 @@ export function fetchAlbumDate(dispatch: AppDispatch, options: AlbumDateOption) }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_DATE_ALBUMS_RETRIEVE_REJECTED", payload: err }); }); } @@ -425,13 +421,12 @@ export function fetchAlbumsAutoGalleries(dispatch: AppDispatch, album_id: string }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_AUTO_ALBUMS_RETRIEVE_REJECTED", payload: err }); }); } export function deleteAutoAlbum(albumID: string, albumTitle: string) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "DELETE_AUTO_ALBUM" }); Server.delete(`/albums/auto/${albumID}`) .then(() => { @@ -450,7 +445,7 @@ export function deleteAutoAlbum(albumID: string, albumTitle: string) { } export function deleteAllAutoAlbum() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "DELETE_All_AUTO_ALBUM" }); Server.post(`/albums/auto/delete_all/`) .then(() => { @@ -470,7 +465,7 @@ export function deleteAllAutoAlbum() { // share user album export function setUserAlbumShared(album_id: number, target_user_id: string, val_shared: boolean) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "SET_ALBUM_USER_SHARED" }); Server.post("useralbum/share/", { shared: val_shared, album_id, target_user_id }) .then(response => { @@ -502,7 +497,7 @@ export function setUserAlbumShared(album_id: number, target_user_id: string, val } export function fetchUserAlbumsSharedToMe() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "FETCH_ALBUMS_SHARED_TO_ME" }); Server.get("/albums/user/shared/tome/") .then(response => { @@ -524,7 +519,7 @@ export function fetchUserAlbumsSharedToMe() { } export function fetchUserAlbumsSharedFromMe() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "FETCH_ALBUMS_SHARED_FROM_ME" }); Server.get("/albums/user/shared/fromme/") .then(response => { diff --git a/src/actions/peopleActions.js b/src/actions/peopleActions.js index c805dba3..a47bf879 100644 --- a/src/actions/peopleActions.js +++ b/src/actions/peopleActions.js @@ -28,7 +28,7 @@ export function fetchPeople(dispatch) { } export function renamePerson(personId, personName, newPersonName) { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "RENAME_PERSON" }); Server.patch(`persons/${personId}/`, { newPersonName }) .then(() => { @@ -48,7 +48,7 @@ export function renamePerson(personId, personName, newPersonName) { } export function deletePerson(person_id) { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "DELETE_PERSON" }); Server.delete(`persons/${person_id}/`) .then(() => { @@ -69,7 +69,7 @@ export function deletePerson(person_id) { } export function setAlbumCoverForPerson(person_id, photo_hash) { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "SET_ALBUM_COVER_FOR_PERSON" }); Server.patch(`persons/${person_id}/`, { cover_photo: photo_hash, diff --git a/src/actions/photosActions.ts b/src/actions/photosActions.ts index 5c91d05a..6480e89d 100644 --- a/src/actions/photosActions.ts +++ b/src/actions/photosActions.ts @@ -34,7 +34,7 @@ const fetchPhotosetRejected = (err: string) => ({ }); export function downloadPhotos(image_hashes: string[]) { - return function () { + return function cb() { Server.post( `photos/download`, { @@ -56,7 +56,7 @@ export function downloadPhotos(image_hashes: string[]) { } export function setPhotosShared(image_hashes: string[], val_shared: boolean, target_user: SimpleUser) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "SET_PHOTOS_SHARED" }); Server.post(`photosedit/share/`, { image_hashes, @@ -126,7 +126,7 @@ const PigPhotoListResponseSchema = z.object({ }); export function fetchPhotosSharedToMe() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: FETCH_PHOTOSET }); Server.get("photos/shared/tome/") .then(response => { @@ -155,7 +155,7 @@ const PhotosSharedFromMeResponseSchema = z.object({ }); export function fetchPhotosSharedFromMe() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: FETCH_PHOTOSET }); Server.get("photos/shared/fromme/") .then(response => { @@ -191,7 +191,7 @@ const PhotosUpdatedResponseSchema = z.object({ export const SET_PHOTOS_PUBLIC_FULFILLED = "SET_PHOTOS_PUBLIC_FULFILLED"; export function setPhotosPublic(image_hashes: string[], val_public: boolean) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "SET_PHOTOS_PUBLIC" }); Server.post(`photosedit/makepublic/`, { image_hashes, val_public }) .then(response => { @@ -231,7 +231,7 @@ export const SET_PHOTOS_FAVORITE_FULFILLED = "SET_PHOTOS_FAVORITE_FULFILLED"; export const SET_PHOTOS_FAVORITE_REJECTED = "SET_PHOTOS_FAVORITE_REJECTED"; export function setPhotosFavorite(image_hashes: string[], favorite: boolean) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: SET_PHOTOS_FAVORITE }); Server.post(`photosedit/favorite/`, { image_hashes, favorite }) .then(response => { @@ -269,7 +269,7 @@ export const PHOTOS_FINAL_DELETED_FULFILLED = "PHOTOS_FINAL_DELETED_FULFILLED"; export const PHOTOS_FINAL_DELETED_REJECTED = "PHOTOS_FINAL_DELETED_REJECTED"; export function finalPhotosDeleted(image_hashes: string[]) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: PHOTOS_FINAL_DELETED }); Server.delete(`photosedit/delete`, { data: { image_hashes }, @@ -297,7 +297,7 @@ export function finalPhotosDeleted(image_hashes: string[]) { } export function deleteDuplicateImage(image_hash: string, path: string) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: PHOTOS_FINAL_DELETED }); Server.delete(`/photosedit/duplicate/delete`, { data: { image_hash, path }, @@ -325,7 +325,7 @@ export const SET_PHOTOS_DELETED_FULFILLED = "SET_PHOTOS_DELETED_FULFILLED"; export const SET_PHOTOS_DELETED_REJECTED = "SET_PHOTOS_DELETED_REJECTED"; export function setPhotosDeleted(image_hashes: string[], deleted: boolean) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: SET_PHOTOS_DELETED }); Server.post(`photosedit/setdeleted/`, { image_hashes, deleted }) .then(response => { @@ -358,7 +358,7 @@ export function setPhotosDeleted(image_hashes: string[], deleted: boolean) { export const SET_PHOTOS_HIDDEN_FULFILLED = "SET_PHOTOS_HIDDEN_FULFILLED"; export function setPhotosHidden(image_hashes: string[], hidden: boolean) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "SET_PHOTOS_HIDDEN" }); Server.post(`photosedit/hide/`, { image_hashes, hidden }) .then(response => { @@ -412,25 +412,25 @@ function triggerScan(dispatch: Dispatch, url: string, i18nPrefix: string): } export function scanPhotos() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { triggerScan(dispatch, "scanphotos/", "scanphotos"); }; } export function scanUploadedPhotos() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { triggerScan(dispatch, "scanuploadedphotos/", "scanuploadedphotos"); }; } export function scanAllPhotos() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { triggerScan(dispatch, "fullscanphotos/", "fullscanphotos"); }; } export function scanNextcloudPhotos() { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { triggerScan(dispatch, "nextcloud/scanphotos/", "scannextcloudphotos"); }; } @@ -482,7 +482,6 @@ export function fetchNoTimestampPhotoPaginated(dispatch: AppDispatch, page: numb }); }) .catch(err => { - console.error(err); dispatch({ type: FETCH_NO_TIMESTAMP_PHOTOS_PAGINATED_REJECTED, payload: err, @@ -491,7 +490,7 @@ export function fetchNoTimestampPhotoPaginated(dispatch: AppDispatch, page: numb } export function generatePhotoIm2txtCaption(image_hash: string) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "GENERATE_PHOTO_CAPTION" }); Server.post("photosedit/generateim2txt", { image_hash }) .then(() => { @@ -500,14 +499,13 @@ export function generatePhotoIm2txtCaption(image_hash: string) { dispatch(photoDetailsApi.endpoints.fetchPhotoDetails.initiate(image_hash)).refetch(); }) .catch(error => { - dispatch({ type: "GENERATE_PHOTO_CAPTION_REJECTED" }); - console.error(error); + dispatch({ type: "GENERATE_PHOTO_CAPTION_REJECTED", payload: error }); }); }; } export function savePhotoCaption(image_hash: string, caption?: string | undefined) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { Server.post("photosedit/savecaption", { image_hash, caption }) .then(() => { dispatch({ type: "SAVE_PHOTO_CAPTION_FULFILLED" }); @@ -520,14 +518,13 @@ export function savePhotoCaption(image_hash: string, caption?: string | undefine }); }) .catch(error => { - dispatch({ type: "SAVE_PHOTO_CAPTION_REJECTED" }); - console.error(error); + dispatch({ type: "SAVE_PHOTO_CAPTION_REJECTED", payload: error }); }); }; } export function editPhoto(image_hash: string, photo_details: any) { - return function (dispatch: Dispatch) { + return function cb(dispatch: Dispatch) { dispatch({ type: "EDIT_PHOTO" }); Server.patch(`photos/edit/${image_hash}/`, photo_details) .then(() => { @@ -541,8 +538,7 @@ export function editPhoto(image_hash: string, photo_details: any) { dispatch(photoDetailsApi.endpoints.fetchPhotoDetails.initiate(image_hash)).refetch(); }) .catch(error => { - dispatch({ type: "EDIT_PHOTO_REJECTED" }); - console.error(error); + dispatch({ type: "EDIT_PHOTO_REJECTED", payload: error }); }); }; } diff --git a/src/actions/publicActions.js b/src/actions/publicActions.js index b4b4b15f..5f45714c 100644 --- a/src/actions/publicActions.js +++ b/src/actions/publicActions.js @@ -2,7 +2,7 @@ import { Server } from "../api_client/apiClient"; import { UserSchema } from "../store/user/user.zod"; export function fetchPublicUserList() { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "FETCH_PUBLIC_USER_LIST" }); Server.get("user/") .then(response => { diff --git a/src/actions/uiActions.js b/src/actions/uiActions.js index 74f88adc..242071ff 100644 --- a/src/actions/uiActions.js +++ b/src/actions/uiActions.js @@ -1,5 +1,5 @@ export function toggleSidebar() { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "TOGGLE_SIDEBAR" }); }; } diff --git a/src/actions/utilActions.js b/src/actions/utilActions.js index 58cff383..994f0f83 100644 --- a/src/actions/utilActions.js +++ b/src/actions/utilActions.js @@ -19,7 +19,7 @@ import { } from "./utilActions.types"; export function updateAvatar(user, form_data) { - return function (dispatch) { + return function cb(dispatch) { Server.patch(`user/${user.id}/`, form_data) .then(response => { const data = UserSchema.parse(response.data); @@ -34,7 +34,6 @@ export function updateAvatar(user, form_data) { }); }) .catch(error => { - console.error(error); dispatch({ type: "UPDATE_USER_REJECTED", payload: error }); }); }; @@ -55,13 +54,12 @@ export function updateUser(user, dispatch) { }); }) .catch(error => { - console.error(error); dispatch({ type: "UPDATE_USER_REJECTED", payload: error }); }); } export function updateUserAndScan(user) { - return function (dispatch) { + return function cb(dispatch) { Server.patch(`manage/user/${user.id}/`, user) .then(response => { ManageUser.parse(response.data); @@ -79,14 +77,13 @@ export function updateUserAndScan(user) { } }) .catch(error => { - console.error(error); dispatch({ type: "UPDATE_USER_REJECTED", payload: error }); }); }; } export function deleteMissingPhotos() { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "DELETE_MISSING_PHOTOS" }); dispatch({ type: "SET_WORKER_AVAILABILITY", payload: false }); dispatch({ @@ -108,14 +105,13 @@ export function deleteMissingPhotos() { }); }) .catch(err => { - console.error(err); dispatch({ type: "DELETE_MISSING_PHOTOS_REJECTED", payload: err }); }); }; } export function generateEventAlbums() { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "GENERATE_EVENT_ALBUMS" }); dispatch({ type: "SET_WORKER_AVAILABILITY", payload: false }); dispatch({ @@ -137,14 +133,13 @@ export function generateEventAlbums() { }); }) .catch(err => { - console.error(err); dispatch({ type: "GENERATE_EVENT_ALBUMS_REJECTED", payload: err }); }); }; } export function generateEventAlbumTitles() { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "GENERATE_EVENT_ALBUMS_TITLES" }); dispatch({ type: "SET_WORKER_AVAILABILITY", payload: false }); dispatch({ @@ -167,7 +162,6 @@ export function generateEventAlbumTitles() { }); }) .catch(err => { - console.error(err); dispatch({ type: "GENERATE_EVENT_ALBUMS_TITLES_REJECTED", payload: err, @@ -177,7 +171,7 @@ export function generateEventAlbumTitles() { } export function fetchExampleSearchTerms() { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "FETCH_EXAMPLE_SEARCH_TERMS" }); Server.get(`searchtermexamples/`) .then(response => { @@ -188,14 +182,13 @@ export function fetchExampleSearchTerms() { }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_EXAMPLE_SEARCH_TERMS_REJECTED", payload: err }); }); }; } export function fetchLocationSunburst() { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "FETCH_LOCATION_SUNBURST" }); Server.get(`locationsunburst/`) .then(response => { @@ -206,7 +199,6 @@ export function fetchLocationSunburst() { }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_LOCATION_SUNBURST_REJECTED", payload: err }); }); }; @@ -223,7 +215,6 @@ export function fetchLocationTimeline(dispatch) { }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_LOCATION_TIMELINE_REJECTED", payload: err }); }); } @@ -238,13 +229,12 @@ export function fetchTimezoneList(dispatch) { }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_TIMEZONE_LIST_REJECTED", payload: err }); }); } export function fetchCountStats() { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "FETCH_COUNT_STATS" }); Server.get(`stats/`) .then(response => { @@ -255,14 +245,13 @@ export function fetchCountStats() { }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_COUNT_STATS_REJECTED", payload: err }); }); }; } export function fetchLocationClusters() { - return function (dispatch) { + return function cb(dispatch) { dispatch({ type: "FETCH_LOCATION_CLUSTERS" }); Server.get(`locclust/`) .then(response => { @@ -290,7 +279,6 @@ export function fetchPhotoMonthCounts(dispatch) { }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_PHOTO_MONTH_COUNTS_REJECTED", payload: err }); }); } @@ -303,7 +291,6 @@ export function fetchWordCloud(dispatch) { dispatch({ type: "FETCH_WORDCLOUD_FULFILLED", payload: data }); }) .catch(err => { - console.error(err); dispatch({ type: "FETCH_WORDCLOUD_REJECTED", payload: err }); }); } diff --git a/src/components/modals/ModalConfigDatetime.tsx b/src/components/modals/ModalConfigDatetime.tsx index b88d2144..a49e31b4 100644 --- a/src/components/modals/ModalConfigDatetime.tsx +++ b/src/components/modals/ModalConfigDatetime.tsx @@ -15,7 +15,7 @@ type Props = { }; function searchRules(query: string) { - return function (rule: DateTimeRule) { + return function cb(rule: DateTimeRule) { return fuzzyMatch(query, rule.name) || fuzzyMatch(query, rule.rule_type); }; } diff --git a/src/components/modals/ModalUserEdit.tsx b/src/components/modals/ModalUserEdit.tsx index eda97604..d2e2c806 100644 --- a/src/components/modals/ModalUserEdit.tsx +++ b/src/components/modals/ModalUserEdit.tsx @@ -187,7 +187,6 @@ export function ModalUserEdit(props: Props) { } if (createNew) { - console.log("createNew", username, userPassword, email, firstName, lastName); if (userPassword && username) { signup({ username: username.toLowerCase(), diff --git a/src/components/react-pig/calcRenderableItems.js b/src/components/react-pig/calcRenderableItems.js index 4fe0a67f..d9a94078 100644 --- a/src/components/react-pig/calcRenderableItems.js +++ b/src/components/react-pig/calcRenderableItems.js @@ -1,4 +1,4 @@ -export default function ({ +export default function calcRenderableItems({ containerOffsetTop, scrollDirection, settings, diff --git a/src/components/react-pig/computeLayout.js b/src/components/react-pig/computeLayout.js index 8b86a36d..a91e77de 100644 --- a/src/components/react-pig/computeLayout.js +++ b/src/components/react-pig/computeLayout.js @@ -17,7 +17,7 @@ */ import getMinAspectRatio from "./utils/getMinAspectRatio"; -export default function ({ imageData, settings, totalHeight, wrapperWidth, scaleOfImages }) { +export default function computeLayout({ imageData, settings, totalHeight, wrapperWidth, scaleOfImages }) { // Compute the minimum aspect ratio that should be applied to the rows. const minAspectRatio = getMinAspectRatio(wrapperWidth, scaleOfImages); diff --git a/src/components/react-pig/computeLayoutGroups.js b/src/components/react-pig/computeLayoutGroups.js index 1dca6b46..c2f72c8b 100644 --- a/src/components/react-pig/computeLayoutGroups.js +++ b/src/components/react-pig/computeLayoutGroups.js @@ -1,7 +1,7 @@ // like computeLayout but specific for groups. Could combine them but it might get messy import getMinAspectRatio from "./utils/getMinAspectRatio"; -export default function ({ imageData, settings, totalHeight, wrapperWidth, scaleOfImages }) { +export default function computeLayoutGroups({ imageData, settings, totalHeight, wrapperWidth, scaleOfImages }) { // Compute the minimum aspect ratio that should be applied to the rows. const minAspectRatio = getMinAspectRatio(wrapperWidth, scaleOfImages); const groupTitleHeight = 50; // wrapperWidth < settings.breakpoint ? 50 : 50 diff --git a/src/components/react-pig/index.jsx b/src/components/react-pig/index.jsx index 34ceeba1..f8176c41 100644 --- a/src/components/react-pig/index.jsx +++ b/src/components/react-pig/index.jsx @@ -45,17 +45,19 @@ export default class Pig extends Component { this.imageData = props.imageData; this.numberOfItems = props.numberOfItems || this.imageData.length; this.scaleOfImages = props.scaleOfImages || 1; - this.updateGroups = props.updateGroups || function () {}; - this.updateItems = props.updateItems || function () {}; + this.updateGroups = props.updateGroups || function onUpdateGroups() {}; + this.updateItems = props.updateItems || function onUpdateItems() {}; // if sortFunc has been provided as a prop, use it if (props.sortFunc) this.imageData.sort(props.sortFunc); else if (props.sortByDate) this.imageData = sortByDate(this.imageData); // check grouping ability if (props.groupByDate && !this.imageData[0].items) { + // eslint-disable-next-line no-console console.error(`Data provided is not grouped yet. Please check the docs, you'll need to use groupify.js`); } if (!props.groupByDate && this.imageData[0].items) { + // eslint-disable-next-line no-console console.error(`Data provided is grouped, please include the groupByDate prop`); } @@ -208,7 +210,6 @@ export default class Pig extends Component { } defaultHandleSelection = item => { - console.log(item); let { newSelectedItems } = this.state; if (newSelectedItems.includes(item)) { newSelectedItems = newSelectedItems.filter(value => value !== item); diff --git a/src/components/react-pig/utils/getImageHeight.js b/src/components/react-pig/utils/getImageHeight.js index 2512c73c..050422cd 100644 --- a/src/components/react-pig/utils/getImageHeight.js +++ b/src/components/react-pig/utils/getImageHeight.js @@ -1,5 +1,5 @@ -export default function(containerWidth) { - if (containerWidth <= 640) return 300 - if (containerWidth <= 1920) return 400 - return 700 -} \ No newline at end of file +export default function getImageHeight(containerWidth) { + if (containerWidth <= 640) return 300; + if (containerWidth <= 1920) return 400; + return 700; +} diff --git a/src/components/react-pig/utils/getMinAspectRatio.js b/src/components/react-pig/utils/getMinAspectRatio.js index 887d191d..c49ce895 100644 --- a/src/components/react-pig/utils/getMinAspectRatio.js +++ b/src/components/react-pig/utils/getMinAspectRatio.js @@ -1,18 +1,18 @@ /** - * Get the minimum required aspect ratio for a valid row of images. The - * perfect rows are maintained by building up a row of images by adding - * together their aspect ratios (the aspect ratio when they are placed - * next to each other) until that aspect ratio exceeds the value returned - * by this function. Responsive reordering is achieved through changes - * to what this function returns at different values of the passed - * parameter `containerWidth`. - * - * @param {Number} containerWidth - The last computed width of the - * container - * @param {Number} scaleOfImages - The size of the images - * @returns {Number} The minimum aspect ratio at this window width. - */ -export default function(containerWidth, scaleOfImages) { + * Get the minimum required aspect ratio for a valid row of images. The + * perfect rows are maintained by building up a row of images by adding + * together their aspect ratios (the aspect ratio when they are placed + * next to each other) until that aspect ratio exceeds the value returned + * by this function. Responsive reordering is achieved through changes + * to what this function returns at different values of the passed + * parameter `containerWidth`. + * + * @param {Number} containerWidth - The last computed width of the + * container + * @param {Number} scaleOfImages - The size of the images + * @returns {Number} The minimum aspect ratio at this window width. + */ +export default function getMinAspectRatio(containerWidth, scaleOfImages) { if (containerWidth <= 800) return 1.5 * scaleOfImages; if (containerWidth <= 1280) return 3 * scaleOfImages; if (containerWidth <= 1920) return 4 * scaleOfImages; diff --git a/src/components/react-pig/utils/getScrollSpeed.js b/src/components/react-pig/utils/getScrollSpeed.js index 4d43599e..c03c5cc8 100644 --- a/src/components/react-pig/utils/getScrollSpeed.js +++ b/src/components/react-pig/utils/getScrollSpeed.js @@ -1,32 +1,32 @@ // https://stackoverflow.com/a/22599173/2255980 -let scrollSpeed = '' -let lastPos = 0 -let newPos = 0 -let delta = 0 -let timeout = null +let scrollSpeed = ""; +let lastPos = 0; +let newPos = 0; +let delta = 0; +let timeout = null; -export default function (latestYOffset, scrollThrottleMs, idleCallback) { - newPos = latestYOffset - - if (lastPos !== 0) delta = Math.abs(newPos - lastPos) +export default function getScrollSpeed(latestYOffset, scrollThrottleMs, idleCallback) { + newPos = latestYOffset; + + if (lastPos !== 0) delta = Math.abs(newPos - lastPos); + + lastPos = newPos; - lastPos = newPos - if (delta < 1000) { - scrollSpeed = 'slow' + scrollSpeed = "slow"; } else if (delta < 3000) { - scrollSpeed = 'medium' + scrollSpeed = "medium"; } else { - scrollSpeed = 'fast' // only really happens when user grabs the scrollbar + scrollSpeed = "fast"; // only really happens when user grabs the scrollbar } - // kind of like a reversed debounce, + // kind of like a reversed debounce, // if this function hasn't been called in a little while, fire the idleCallback function - clearTimeout(timeout) + clearTimeout(timeout); timeout = setTimeout(() => { - timeout = null - idleCallback('slow') - }, scrollThrottleMs * 2) + timeout = null; + idleCallback("slow"); + }, scrollThrottleMs * 2); - return scrollSpeed + return scrollSpeed; } diff --git a/src/store/worker/workerSlice.ts b/src/store/worker/workerSlice.ts index f7f7fc0f..087c4775 100644 --- a/src/store/worker/workerSlice.ts +++ b/src/store/worker/workerSlice.ts @@ -20,6 +20,7 @@ const workerSlice = createSlice({ const parsed = WorkerAvailabilityResponse.parse(payload); return { ...state, ...parsed }; } catch (e) { + // eslint-disable-next-line no-console console.error(e); return state; }