diff --git a/.eslintrc.js b/.eslintrc.js index 6f2dcc0ac..6ba50896a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -70,8 +70,6 @@ module.exports = { ], "no-alert": 0, "no-underscore-dangle": 0, - // This gets around eslint problems when typing functions in TS - "no-unused-vars": 0, "no-void": 0, "prefer-destructuring": [2, { object: true, array: false }], quotes: [2, "double"], @@ -127,27 +125,23 @@ module.exports = { "no-undef": "error", "@typescript-eslint/no-unused-vars": [ - "warn", + "error", { vars: "all", args: "after-used", // Overriding airbnb to allow leading underscore to indicate unused var argsIgnorePattern: "^_", varsIgnorePattern: "^_", - ignoreRestSiblings: true + ignoreRestSiblings: true, + caughtErrors: "all", + // needed a special case for catch blocks that use _ to define an unused error + caughtErrorsIgnorePattern: "^_" } ], - // TODO: we should actually type these at some point ~amanda 041824 - "@typescript-eslint/no-shadow": "error", - "@typescript-eslint/ban-types": 0, - "@typescript-eslint/no-var-requires": 0, - "@typescript-eslint/no-wrapper-object-types": 0, - "@typescript-eslint/no-require-imports": 0, - "@typescript-eslint/no-unsafe-function-type": 0, - "@typescript-eslint/no-empty-object-types": 0, - "@typescript-eslint/no-empty-object-type": 0, - "@typescript-eslint/no-explicit-any": 1, - "@typescript-eslint/no-unused-expressions": 1 + "@typescript-eslint/no-require-imports": ["error", { + allow: ["\\.(png|jpg|jpeg|gif|svg)$"] + }], + "@typescript-eslint/no-unsafe-function-type": 1 }, // need this so jest doesn't show as undefined in jest.setup.js env: { @@ -161,5 +155,21 @@ module.exports = { extensions: [".js", ".jsx", ".ts", ".tsx"] } } - } + }, + overrides: [ + { + files: ["*.js", "*.jsx"], + rules: { + "@typescript-eslint/no-unsafe-function-type": "off", + "@typescript-eslint/no-wrapper-object-types": "off", + "@typescript-eslint/no-require-imports": "off" + } + }, + { + files: ["**/__mocks__/**/*", "**/*mock*", "**/*.mock.*"], + rules: { + "@typescript-eslint/no-require-imports": "off" + } + } + ] }; diff --git a/e2e/sharedFlows/dismissAnnouncements.js b/e2e/sharedFlows/dismissAnnouncements.js index 8bd8e49e1..5281b9527 100644 --- a/e2e/sharedFlows/dismissAnnouncements.js +++ b/e2e/sharedFlows/dismissAnnouncements.js @@ -13,6 +13,6 @@ export default async function dismissAnnouncements() { await element( by.id( "announcements-dismiss" ) ).tap(); } catch ( error ) { // if timeout occurs, the element isn't visible, so continue with test - console.log( "No announcement present, continuing with test" ); + console.log( "No announcement present, continuing with test", error ); } } diff --git a/scripts/add-example-model.js b/scripts/add-example-model.js index 95a11dc40..747f43515 100644 --- a/scripts/add-example-model.js +++ b/scripts/add-example-model.js @@ -118,7 +118,7 @@ const downloadIOS = async () => { console.log( "iOS done!" ); }; -// eslint-disable-next-line no-unused-expressions +// eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions yargs .usage( "Usage: $0 [args]" ) .option( "androidFlavor", { diff --git a/src/api/computerVision.ts b/src/api/computerVision.ts index ac42f434e..fa960f680 100644 --- a/src/api/computerVision.ts +++ b/src/api/computerVision.ts @@ -16,7 +16,7 @@ const PARAMS = { const scoreImage = async ( params = {}, opts = {} -): Promise => { +): Promise => { try { return inatjs.computervision.score_image( { ...PARAMS, ...params }, opts ); } catch ( e ) { diff --git a/src/api/log.ts b/src/api/log.ts index e8aea4c44..d1aa47679 100644 --- a/src/api/log.ts +++ b/src/api/log.ts @@ -31,7 +31,7 @@ const iNatLogstashTransport: transportFunctionType = async props => { let userToken; try { userToken = await getJWT(); - } catch ( getJWTError ) { + } catch ( _getJWTError ) { // We use logging to report errors, so this is one of the few cases where // we really do want to squelch all errors to avoid recursion console.error( "[ERROR log.ts] failed to retrieve user JWT while logging" ); diff --git a/src/api/messages.ts b/src/api/messages.ts index 082270f89..9274526d5 100644 --- a/src/api/messages.ts +++ b/src/api/messages.ts @@ -14,7 +14,7 @@ const PARAMS = { fields: MESSAGE_FIELDS }; -const searchMessages = async ( params: Object = {}, opts: Object = {} ): Promise => { +const searchMessages = async ( params: object = {}, opts: object = {} ): Promise => { try { const { results } = await inatjs.messages.search( { ...PARAMS, ...params }, opts ); return results; diff --git a/src/api/search.ts b/src/api/search.ts index dc6efe82c..aeb9cc816 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -42,7 +42,7 @@ const search = async ( try { response = await inatjs.search( { ...PARAMS, ...params }, opts ); } catch ( searchError ) { - handleError( searchError as Object ); + handleError( searchError as object ); // handleError should throw, so in theory this should never happen and // this is just to placate typescript return null; diff --git a/src/api/types.d.ts b/src/api/types.d.ts index ffa77e626..6eebe51cb 100644 --- a/src/api/types.d.ts +++ b/src/api/types.d.ts @@ -6,7 +6,7 @@ export interface ApiOpts { export interface ApiParams { per_page?: number; page?: number; - fields?: "all" | Object; + fields?: "all" | object; ttl?: number; } @@ -26,7 +26,7 @@ export interface ApiResponse { total_results: number; page: number; per_page: number; - results: Object[]; + results: object[]; } export interface ApiObservationsUpdatesParams extends ApiParams { diff --git a/src/components/Camera/CameraWithDevice.tsx b/src/components/Camera/CameraWithDevice.tsx index f8d98f2be..1b916d34f 100644 --- a/src/components/Camera/CameraWithDevice.tsx +++ b/src/components/Camera/CameraWithDevice.tsx @@ -13,15 +13,15 @@ const isTablet = DeviceInfo.isTablet( ); interface Props { cameraType: string, device: CameraDevice, - camera: Object, + camera: object, flipCamera: ( ) => void, handleCheckmarkPress: ( ) => void, toggleFlash: Function, takingPhoto: boolean, takePhotoAndStoreUri: Function, - newPhotoUris: Array, + newPhotoUris: Array, setNewPhotoUris: Function, - takePhotoOptions: Object, + takePhotoOptions: object, userLocation: UserLocation | null, hasLocationPermissions: boolean, requestLocationPermissions: () => void, diff --git a/src/components/Camera/FocusSquare.tsx b/src/components/Camera/FocusSquare.tsx index c9c78afe5..42bf0ee22 100644 --- a/src/components/Camera/FocusSquare.tsx +++ b/src/components/Camera/FocusSquare.tsx @@ -4,7 +4,7 @@ import React from "react"; import { Animated } from "react-native"; interface Props { - animatedStyle: Object + animatedStyle: object } const FocusSquare = ( { animatedStyle }: Props ) => { diff --git a/src/components/Camera/helpers/savePhotosToPhotoLibrary.ts b/src/components/Camera/helpers/savePhotosToPhotoLibrary.ts index ed022d00c..c08544872 100644 --- a/src/components/Camera/helpers/savePhotosToPhotoLibrary.ts +++ b/src/components/Camera/helpers/savePhotosToPhotoLibrary.ts @@ -24,7 +24,7 @@ const logger = log.extend( "savePhotosToPhotoLibrary" ); // $FlowIgnore export async function savePhotosToPhotoLibrary( uris: [string], - location: Object + location: object ) { const readWritePermissionResult = permissionResultFromMultiple( await checkMultiple( READ_WRITE_MEDIA_PERMISSIONS ) diff --git a/src/components/Camera/hooks/useZoom.ts b/src/components/Camera/hooks/useZoom.ts index fcc99625a..f9ee8c64b 100644 --- a/src/components/Camera/hooks/useZoom.ts +++ b/src/components/Camera/hooks/useZoom.ts @@ -24,7 +24,7 @@ const MAX_ZOOM_FACTOR = 20; // Used for calculating the final zoom by pinch gesture const SCALE_FULL_ZOOM = 3; -const useZoom = ( device: CameraDevice ): Object => { +const useZoom = ( device: CameraDevice ): object => { const initialZoomTextValue = "1"; const zoomButtonOptions = useMemo( () => { const options = [initialZoomTextValue]; diff --git a/src/components/FullPageWebView/FullPageWebViewHeader.tsx b/src/components/FullPageWebView/FullPageWebViewHeader.tsx index d8584e95e..a2e69d48d 100644 --- a/src/components/FullPageWebView/FullPageWebViewHeader.tsx +++ b/src/components/FullPageWebView/FullPageWebViewHeader.tsx @@ -15,7 +15,7 @@ type Props = { options: { title?: string | undefined; headerTitle?: HeaderTitle; - headerStyle?: Object; + headerStyle?: object; headerShadowVisible?: boolean; }; }; diff --git a/src/components/LoginSignUp/AuthenticationService.ts b/src/components/LoginSignUp/AuthenticationService.ts index b0f627b5c..624d353da 100644 --- a/src/components/LoginSignUp/AuthenticationService.ts +++ b/src/components/LoginSignUp/AuthenticationService.ts @@ -159,7 +159,7 @@ const signOut = async ( try { options.realm.deleteAll( ); options.realm.commitTransaction( ); - } catch ( realmError ) { + } catch ( _realmError ) { options.realm.cancelTransaction( ); // If we failed to wipe all the data in realm, delete the realm file. // Note that deleting the realm file *all* the time seems to cause @@ -198,7 +198,7 @@ const signOut = async ( * Encodes a JWT. Lifted from react-native-jwt-io * https://github.com/maxweb4u/react-native-jwt-io/blob/7f926da46ff536dbb531dd8ae7177ab4ff28c43f/src/jwt.js#L21 */ -const encodeJWT = ( payload: Object, key: string, algorithm?: string ) => { +const encodeJWT = ( payload: object, key: string, algorithm?: string ) => { algorithm = typeof algorithm !== "undefined" ? algorithm : "HS256"; diff --git a/src/components/MyObservations/SimpleTaxonGridItem.tsx b/src/components/MyObservations/SimpleTaxonGridItem.tsx index c066c3837..5f6b0cf9c 100644 --- a/src/components/MyObservations/SimpleTaxonGridItem.tsx +++ b/src/components/MyObservations/SimpleTaxonGridItem.tsx @@ -27,7 +27,7 @@ export interface Props { source: { uri: string }; - style?: Object; + style?: object; speciesCount: SpeciesCount; } diff --git a/src/components/MyObservations/hooks/useSyncObservations.ts b/src/components/MyObservations/hooks/useSyncObservations.ts index c14ab350e..892277080 100644 --- a/src/components/MyObservations/hooks/useSyncObservations.ts +++ b/src/components/MyObservations/hooks/useSyncObservations.ts @@ -44,7 +44,7 @@ const useSyncObservations = ( const realm = useRealm( ); const handleRemoteDeletion = useAuthenticatedMutation( - ( params: Object, optsWithAuth: Object ) => deleteRemoteObservation( params, optsWithAuth ), + ( params: object, optsWithAuth: object ) => deleteRemoteObservation( params, optsWithAuth ), { onSuccess: ( ) => { Observation @@ -75,7 +75,7 @@ const useSyncObservations = ( } else { try { await handleRemoteDeletion.mutateAsync( { uuid } ); - } catch ( error ) { + } catch ( _error ) { // In case of failure, clear the pending deletion flag after some time // to allow retrying later setTimeout( ( ) => { diff --git a/src/components/ObsDetails/DetailsTab/ObscurationExplanation.tsx b/src/components/ObsDetails/DetailsTab/ObscurationExplanation.tsx index fd907f0a2..969733d2c 100644 --- a/src/components/ObsDetails/DetailsTab/ObscurationExplanation.tsx +++ b/src/components/ObsDetails/DetailsTab/ObscurationExplanation.tsx @@ -6,7 +6,7 @@ import { useTranslation } from "sharedHooks"; interface Props { textClassName?: string; currentUser: { id: number }; - observation: Object; + observation: object; } const ObscurationExplanation = ( { textClassName, currentUser, observation }: Props ) => { diff --git a/src/components/ObsDetails/DetailsTab/ProjectSection.tsx b/src/components/ObsDetails/DetailsTab/ProjectSection.tsx index 2c90a2f29..bc647ec3e 100644 --- a/src/components/ObsDetails/DetailsTab/ProjectSection.tsx +++ b/src/components/ObsDetails/DetailsTab/ProjectSection.tsx @@ -15,10 +15,10 @@ const sectionClass = "mx-[15px] mb-[20px]"; interface Props { observation: { project_observations: Array<{ - project: Object; + project: object; }>; non_traditional_projects: Array<{ - project: Object; + project: object; }>; } } diff --git a/src/components/ObsDetailsDefaultMode/LocationSection/ObscurationExplanation.tsx b/src/components/ObsDetailsDefaultMode/LocationSection/ObscurationExplanation.tsx index fd907f0a2..969733d2c 100644 --- a/src/components/ObsDetailsDefaultMode/LocationSection/ObscurationExplanation.tsx +++ b/src/components/ObsDetailsDefaultMode/LocationSection/ObscurationExplanation.tsx @@ -6,7 +6,7 @@ import { useTranslation } from "sharedHooks"; interface Props { textClassName?: string; currentUser: { id: number }; - observation: Object; + observation: object; } const ObscurationExplanation = ( { textClassName, currentUser, observation }: Props ) => { diff --git a/src/components/ObsDetailsDefaultMode/MoreSection/ProjectButton.tsx b/src/components/ObsDetailsDefaultMode/MoreSection/ProjectButton.tsx index c68d09e7c..b1a1784bb 100644 --- a/src/components/ObsDetailsDefaultMode/MoreSection/ProjectButton.tsx +++ b/src/components/ObsDetailsDefaultMode/MoreSection/ProjectButton.tsx @@ -7,10 +7,10 @@ import React, { useMemo } from "react"; interface Props { observation: { project_observations: Array<{ - project: Object; + project: object; }>; non_traditional_projects: Array<{ - project: Object; + project: object; }>; } } diff --git a/src/components/ObsDetailsDefaultMode/ObsDetailsDefaultModeHeaderRight.tsx b/src/components/ObsDetailsDefaultMode/ObsDetailsDefaultModeHeaderRight.tsx index 7a0cd6f28..1f399eb29 100644 --- a/src/components/ObsDetailsDefaultMode/ObsDetailsDefaultModeHeaderRight.tsx +++ b/src/components/ObsDetailsDefaultMode/ObsDetailsDefaultModeHeaderRight.tsx @@ -18,7 +18,7 @@ interface Props { observationId: number, uuid: string, refetchSubscriptions: Function, - subscriptions: Object + subscriptions: object } const ObsDetailsDefaultModeHeaderRight = ( { diff --git a/src/components/ObsEdit/BottomButtonsContainer.tsx b/src/components/ObsEdit/BottomButtonsContainer.tsx index 865f781e2..d2d1efa09 100644 --- a/src/components/ObsEdit/BottomButtonsContainer.tsx +++ b/src/components/ObsEdit/BottomButtonsContainer.tsx @@ -22,7 +22,7 @@ const { useRealm } = RealmContext; type Props = { passesEvidenceTest: boolean, - observations: Array, + observations: Array, currentObservation: RealmObservation, currentObservationIndex: number, setCurrentObservationIndex: Function, diff --git a/src/components/ObservationsFlashList/ObsPressable.tsx b/src/components/ObservationsFlashList/ObsPressable.tsx index 2bf19bbc2..fb33ec806 100644 --- a/src/components/ObservationsFlashList/ObsPressable.tsx +++ b/src/components/ObservationsFlashList/ObsPressable.tsx @@ -7,7 +7,7 @@ import ObsGridItem from "./ObsGridItem"; import ObsListItem from "./ObsListItem"; type Props = { - currentUser: Object, + currentUser: object, queued: boolean, explore: boolean, hideMetadata?: boolean, @@ -17,7 +17,7 @@ type Props = { hideRGLabel?: boolean, onUploadButtonPress: ( ) => void, onItemPress: ( ) => void, - gridItemStyle: Object, + gridItemStyle: object, layout: "list" | "grid", observation: RealmObservation, uploadProgress: number, diff --git a/src/components/ProjectDetails/ProjectRuleItem.tsx b/src/components/ProjectDetails/ProjectRuleItem.tsx index fc1134c26..87e8528f8 100644 --- a/src/components/ProjectDetails/ProjectRuleItem.tsx +++ b/src/components/ProjectDetails/ProjectRuleItem.tsx @@ -6,7 +6,7 @@ import React, { useState } from "react"; import { useCurrentUser, useTranslation } from "sharedHooks"; interface Props { - rule: Object + rule: object } const ProjectRuleItem = ( { rule }: Props ) => { diff --git a/src/components/ProjectList/ProjectList.tsx b/src/components/ProjectList/ProjectList.tsx index f63c845a8..371722967 100644 --- a/src/components/ProjectList/ProjectList.tsx +++ b/src/components/ProjectList/ProjectList.tsx @@ -12,7 +12,7 @@ import { import ProjectListItem from "./ProjectListItem"; interface Props { - projects: Array + projects: Array ListEmptyComponent?: React.JSX.Element ListFooterComponent?: React.JSX.Element onEndReached?: ( ) => void diff --git a/src/components/Projects/Projects.tsx b/src/components/Projects/Projects.tsx index 8e69d3d70..1c8c76790 100644 --- a/src/components/Projects/Projects.tsx +++ b/src/components/Projects/Projects.tsx @@ -35,7 +35,7 @@ interface Props { isFetchingNextPage: boolean; isLoading: boolean; memberId?: number; - projects: Object[], + projects: object[], requestPermissions: () => void; searchInput: string; setSearchInput: ( _text: string ) => void; diff --git a/src/components/Projects/hooks/useInfiniteProjectsScroll.ts b/src/components/Projects/hooks/useInfiniteProjectsScroll.ts index 4360b6340..ef127a349 100644 --- a/src/components/Projects/hooks/useInfiniteProjectsScroll.ts +++ b/src/components/Projects/hooks/useInfiniteProjectsScroll.ts @@ -4,7 +4,7 @@ import { useAuthenticatedInfiniteQuery } from "sharedHooks"; -const useInfiniteProjectsScroll = ( { params: newInputParams, enabled }: Object ): Object => { +const useInfiniteProjectsScroll = ( { params: newInputParams, enabled }: object ): object => { const baseParams = { ...newInputParams, per_page: 50, diff --git a/src/components/SharedComponents/Carousel.tsx b/src/components/SharedComponents/Carousel.tsx index afdd85539..ad2e39758 100644 --- a/src/components/SharedComponents/Carousel.tsx +++ b/src/components/SharedComponents/Carousel.tsx @@ -11,7 +11,7 @@ import { I18nManager } from "react-native"; -interface Props extends FlatListProps { +interface Props extends FlatListProps { onSlideScroll: ( index: number ) => void; } diff --git a/src/components/SharedComponents/InlineUser/InlineUserBase.js b/src/components/SharedComponents/InlineUser/InlineUserBase.js index 38c582ebd..4e0f28461 100644 --- a/src/components/SharedComponents/InlineUser/InlineUserBase.js +++ b/src/components/SharedComponents/InlineUser/InlineUserBase.js @@ -20,7 +20,14 @@ type Props = { login: string }, isConnected: boolean, - TextComponent: any, + TextComponent: ( props: { + className?: string, + numberOfLines?: number, + ellipsizeMode?: string, + selectable?: boolean, + maxFontSizeMultiplier?: number, + children?: React$Node, // eslint-disable-line no-undef +} ) => React$Node, // eslint-disable-line no-undef testID: string, useBigIcon?: boolean }; diff --git a/src/components/SharedComponents/Map/Map.tsx b/src/components/SharedComponents/Map/Map.tsx index 415646d7a..a8a3048d2 100644 --- a/src/components/SharedComponents/Map/Map.tsx +++ b/src/components/SharedComponents/Map/Map.tsx @@ -76,7 +76,7 @@ interface Props { style?: ViewStyle; switchMapTypeButtonClassName?: string; testID?: string; - tileMapParams?: Object | null; + tileMapParams?: object | null; withObsTiles?: boolean; withPressableObsTiles?: boolean; zoomEnabled?: boolean; diff --git a/src/components/SharedComponents/TaxonGridItem.tsx b/src/components/SharedComponents/TaxonGridItem.tsx index ed17b33c4..2073c2c4d 100644 --- a/src/components/SharedComponents/TaxonGridItem.tsx +++ b/src/components/SharedComponents/TaxonGridItem.tsx @@ -12,7 +12,7 @@ import { useCurrentUser, useFontScale, useTranslation } from "sharedHooks"; export interface Props { headerText?: string; showSpeciesSeenCheckmark?: boolean; - style?: Object; + style?: object; taxon: ApiTaxon; upperRight?: React.ReactNode; } diff --git a/src/components/SharedComponents/TaxonResult.tsx b/src/components/SharedComponents/TaxonResult.tsx index 491c21095..fe63afa32 100644 --- a/src/components/SharedComponents/TaxonResult.tsx +++ b/src/components/SharedComponents/TaxonResult.tsx @@ -28,14 +28,14 @@ interface TaxonResultProps { fetchRemote?: boolean; first?: boolean; fromLocal?: boolean; - handleCheckmarkPress: ( taxon: Object ) => void; + handleCheckmarkPress: ( taxon: object ) => void; handleRemovePress?: () => void; handleTaxonOrEditPress?: ( _event?: GestureResponderEvent ) => void; hideInfoButton?: boolean; hideNavButtons?: boolean; checkmarkFocused?: boolean; lastScreen?: string | null; - onPressInfo?: ( taxon: Object ) => void; + onPressInfo?: ( taxon: object ) => void; showCheckmark?: boolean; showEditButton?: boolean; showRemoveButton?: boolean; diff --git a/src/components/SharedComponents/UserText.tsx b/src/components/SharedComponents/UserText.tsx index 938cefaaf..85723cecd 100644 --- a/src/components/SharedComponents/UserText.tsx +++ b/src/components/SharedComponents/UserText.tsx @@ -93,7 +93,7 @@ const LINKIFY_OPTIONS: Opts = { interface Props extends React.PropsWithChildren { text: string, - htmlStyle?: Object, + htmlStyle?: object, } const UserText = ( { diff --git a/src/components/Suggestions/hooks/useNavigateWithTaxonSelected.ts b/src/components/Suggestions/hooks/useNavigateWithTaxonSelected.ts index 60e8cb73b..eb38a446e 100644 --- a/src/components/Suggestions/hooks/useNavigateWithTaxonSelected.ts +++ b/src/components/Suggestions/hooks/useNavigateWithTaxonSelected.ts @@ -4,7 +4,7 @@ import useStore from "stores/useStore"; const useNavigateWithTaxonSelected = ( // Navigation happens when a taxon was selected - selectedTaxon: Object | null | undefined, + selectedTaxon: object | null | undefined, // After navigation we need to unselect the taxon so we don't have // mysterious background nonsense happening after this screen loses focus unselectTaxon: Function, diff --git a/src/components/UserList/UserList.tsx b/src/components/UserList/UserList.tsx index 5428a358d..a7c7ee185 100644 --- a/src/components/UserList/UserList.tsx +++ b/src/components/UserList/UserList.tsx @@ -18,7 +18,7 @@ interface Props { ListFooterComponent?: React.JSX.Element onEndReached?: ( ) => void refreshing?: boolean - users: Array + users: Array onPress?: ( ) => void accessibilityLabel?: string keyboardShouldPersistTaps?: string diff --git a/src/components/UserList/UserListItem.tsx b/src/components/UserList/UserListItem.tsx index e3d5c03eb..363d01584 100644 --- a/src/components/UserList/UserListItem.tsx +++ b/src/components/UserList/UserListItem.tsx @@ -9,7 +9,7 @@ import User from "realmModels/User.ts"; import { useTranslation } from "sharedHooks"; interface Props { - item: Object + item: object countText: string onPress?: Function accessibilityLabel?: string diff --git a/src/i18n/i18ncli.js b/src/i18n/i18ncli.js index 5f0da3960..9c408b9dc 100644 --- a/src/i18n/i18ncli.js +++ b/src/i18n/i18ncli.js @@ -44,7 +44,7 @@ const writeLoadTranslations = async ( ) => { out.write( "\n];\n" ); }; -// eslint-disable-next-line no-unused-expressions +// eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions yargs .usage( "Usage: $0 [args]" ) .option( "verbose", { diff --git a/src/i18n/i18ncli/fastlane.js b/src/i18n/i18ncli/fastlane.js index 5cc4eab9b..e56bfc424 100644 --- a/src/i18n/i18ncli/fastlane.js +++ b/src/i18n/i18ncli/fastlane.js @@ -211,7 +211,7 @@ async function renameDirectories( options = {} ) { if ( options.verbose ) { console.log( "Removed existing directory", newDirectoryPath ); } - } catch ( e ) { + } catch ( _e ) { // Directory did not exist } if ( options.verbose ) { @@ -242,7 +242,7 @@ async function renameDirectories( options = {} ) { if ( options.verbose ) { console.log( "Removed existing directory", newDirectoryPath ); } - } catch ( e ) { + } catch ( _e ) { // Directory did not exist } if ( options.verbose ) { diff --git a/src/navigation/CustomDrawerContent.tsx b/src/navigation/CustomDrawerContent.tsx index c6969a41b..4b509afae 100644 --- a/src/navigation/CustomDrawerContent.tsx +++ b/src/navigation/CustomDrawerContent.tsx @@ -44,9 +44,9 @@ const drawerScrollViewStyle = { } as const; interface Props { - state: Object; - navigation: Object; - descriptors: Object; + state: object; + navigation: object; + descriptors: object; } const feedbackLogger = log.extend( "feedback" ); diff --git a/src/providers/ExploreContext.tsx b/src/providers/ExploreContext.tsx index b7751d3af..47fc4532e 100644 --- a/src/providers/ExploreContext.tsx +++ b/src/providers/ExploreContext.tsx @@ -203,9 +203,9 @@ type State = { place_guess: string, placeMode: PLACE_MODE, place_id: number | null | undefined, - // TODO: technically this is not any Object but a "Project" + // TODO: technically this is not any object but a "Project" // and should be typed as such (e.g., in realm model) - project: Object | undefined | null, + project: object | undefined | null, project_id: number | undefined | null, radius?: number, researchGrade: boolean, @@ -214,26 +214,26 @@ type State = { sortBy: SORT_BY, swlat?: number, swlng?: number, - // TODO: technically this is not any Object but a "Taxon" + // TODO: technically this is not any object but a "Taxon" // and should be typed as such (e.g., in realm model) - taxon: Object | undefined | null, + taxon: object | undefined | null, taxon_id: number | undefined | null, - // TODO: technically this is not any Object but a "User" + // TODO: technically this is not any object but a "User" // and should be typed as such (e.g., in realm model) - user: Object | undefined | null, + user: object | undefined | null, user_id: number | undefined | null, - excludeUser: Object | undefined | null, + excludeUser: object | undefined | null, verifiable: boolean, wildStatus: WILD_STATUS } type Action = {type: EXPLORE_ACTION.RESET} | {type: EXPLORE_ACTION.DISCARD, snapshot: State} - | {type: EXPLORE_ACTION.SET_USER, user: Object | null, userId: number | null, storedState: State} + | {type: EXPLORE_ACTION.SET_USER, user: object | null, userId: number | null, storedState: State} | { type: EXPLORE_ACTION.EXCLUDE_USER, user: null, userId: null, - excludeUser: Object, + excludeUser: object, storedState: State } | { @@ -261,7 +261,7 @@ type Action = {type: EXPLORE_ACTION.RESET} | {type: EXPLORE_ACTION.SET_PLACE_MODE_PLACE} | { type: EXPLORE_ACTION.SET_PROJECT, - project: Object | null, + project: object | null, projectId: number | null, storedState: State } diff --git a/src/sharedHelpers/mail.ts b/src/sharedHelpers/mail.ts index 1dfc6ecfb..e321332e0 100644 --- a/src/sharedHelpers/mail.ts +++ b/src/sharedHelpers/mail.ts @@ -10,7 +10,7 @@ export async function openInbox() { let isSupported; try { isSupported = await Linking.canOpenURL( "message:0" ); - } catch ( canOpenURLError ) { + } catch ( _canOpenURLError ) { openInboxError(); return; } diff --git a/src/sharedHelpers/mlModel.ts b/src/sharedHelpers/mlModel.ts index 4333bee38..3d65b1a95 100644 --- a/src/sharedHelpers/mlModel.ts +++ b/src/sharedHelpers/mlModel.ts @@ -47,10 +47,10 @@ export const predictImage = ( uri: string, location: Location ) => { let url; try { url = new URL( uri ); - } catch ( urlError ) { + } catch ( _urlError ) { try { url = new URL( `file://${uri}` ); - } catch ( urlError2 ) { + } catch ( _urlError2 ) { // will handle when url is blank } } diff --git a/src/sharedHelpers/taxon.ts b/src/sharedHelpers/taxon.ts index bb0d7f9e0..86598c18f 100644 --- a/src/sharedHelpers/taxon.ts +++ b/src/sharedHelpers/taxon.ts @@ -161,7 +161,7 @@ interface User { export function accessibleTaxonName( taxon: Taxon, user: User | null, - t: ( key: string, options: {} ) => string + t: ( key: string, options: object ) => string ) { const { commonName, scientificName } = generateTaxonPieces( taxon ); if ( typeof ( user?.prefers_scientific_name_first ) === "boolean" ) { diff --git a/src/sharedHooks/useAuthenticatedInfiniteQuery.ts b/src/sharedHooks/useAuthenticatedInfiniteQuery.ts index 12a2fb7c9..fe671b8a3 100644 --- a/src/sharedHooks/useAuthenticatedInfiniteQuery.ts +++ b/src/sharedHooks/useAuthenticatedInfiniteQuery.ts @@ -10,8 +10,8 @@ import { useCurrentUser } from "sharedHooks"; const useAuthenticatedInfiniteQuery = ( queryKey: Array, queryFunction: Function, - queryOptions: Object = {} -): Object => { + queryOptions: object = {} +): object => { const route = useRoute( ); const currentUser = useCurrentUser( ); diff --git a/src/sharedHooks/useInfiniteUserScroll.ts b/src/sharedHooks/useInfiniteUserScroll.ts index 3a2d4cffa..eba51d6cb 100644 --- a/src/sharedHooks/useInfiniteUserScroll.ts +++ b/src/sharedHooks/useInfiniteUserScroll.ts @@ -4,12 +4,12 @@ import { useAuthenticatedInfiniteQuery } from "sharedHooks"; const useInfiniteUserScroll = ( queryKey: string, apiCall: Function, - ids: Array, - newInputParams: Object, + ids: Array, + newInputParams: object, options: { enabled: boolean } -): Object => { +): object => { const baseParams = { ...newInputParams, // TODO: can change this once API pagination is working diff --git a/src/sharedHooks/useQuery.ts b/src/sharedHooks/useQuery.ts index 034557769..646e6a3ee 100644 --- a/src/sharedHooks/useQuery.ts +++ b/src/sharedHooks/useQuery.ts @@ -6,8 +6,8 @@ import { useSafeRoute } from "sharedHooks"; const useNonAuthenticatedQuery = ( queryKey: Array, queryFunction: Function, - queryOptions: Object = {} -): Object => { + queryOptions: object = {} +): object => { const route = useSafeRoute( ); return useQuery( { diff --git a/src/sharedHooks/useSafeRoute.js b/src/sharedHooks/useSafeRoute.js index 7d2e34f1e..61f93b06f 100644 --- a/src/sharedHooks/useSafeRoute.js +++ b/src/sharedHooks/useSafeRoute.js @@ -18,7 +18,7 @@ const useSafeRoute = () => { routeParams: route.params }; } - } catch ( e ) { + } catch ( _e ) { // console.log( "Route not available from useSafeRoute" ); } diff --git a/src/sharedHooks/useSuggestions/useOnlineSuggestions.ts b/src/sharedHooks/useSuggestions/useOnlineSuggestions.ts index 8e5cd1624..3819b47a2 100644 --- a/src/sharedHooks/useSuggestions/useOnlineSuggestions.ts +++ b/src/sharedHooks/useSuggestions/useOnlineSuggestions.ts @@ -21,16 +21,16 @@ const { useRealm } = RealmContext; type OnlineSuggestionsResponse = { dataUpdatedAt: Date, - onlineSuggestions: Object, + onlineSuggestions: object, loadingOnlineSuggestions: boolean, timedOut: boolean, - error: Object, + error: object, resetTimeout: Function isRefetching: boolean } const useOnlineSuggestions = ( - options: Object + options: object ): OnlineSuggestionsResponse => { const realm = useRealm( ); const { diff --git a/src/stores/createRootExploreSlice.ts b/src/stores/createRootExploreSlice.ts index c78a82a21..b6a4c136e 100644 --- a/src/stores/createRootExploreSlice.ts +++ b/src/stores/createRootExploreSlice.ts @@ -6,8 +6,8 @@ const DEFAULT_STATE = { }; interface RootExploreSlice { - rootStoredParams: Object, - setRootStoredParams: ( _params: Object ) => void, + rootStoredParams: object, + setRootStoredParams: ( _params: object ) => void, rootExploreView: string, setRootExploreView: ( _view: string ) => void } diff --git a/src/stores/createUploadObservationsSlice.ts b/src/stores/createUploadObservationsSlice.ts index f250df8d6..69299c800 100644 --- a/src/stores/createUploadObservationsSlice.ts +++ b/src/stores/createUploadObservationsSlice.ts @@ -23,7 +23,7 @@ interface TotalUploadProgress { interface UploadObservationsSlice { abortController: AbortController | null, currentUpload: RealmObservation | null, - errorsByUuid: Object, + errorsByUuid: object, multiError: string | null, initialNumObservationsInQueue: number, numUnuploadedObservations: number, diff --git a/src/types/declarations.d.ts b/src/types/declarations.d.ts index 586cabca5..3aada69e2 100644 --- a/src/types/declarations.d.ts +++ b/src/types/declarations.d.ts @@ -12,7 +12,6 @@ declare module "*.svg" { declare global { namespace ReactNavigation { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface RootParamList extends RootStackParamList {} + type RootParamList = RootStackParamList } } diff --git a/src/uploaders/dataTransformation/prepareMediaForUpload.ts b/src/uploaders/dataTransformation/prepareMediaForUpload.ts index 683ab6144..7945057f1 100644 --- a/src/uploaders/dataTransformation/prepareMediaForUpload.ts +++ b/src/uploaders/dataTransformation/prepareMediaForUpload.ts @@ -2,11 +2,11 @@ import ObservationPhoto from "realmModels/ObservationPhoto"; import ObservationSound from "realmModels/ObservationSound"; function prepareMediaForUpload( - media: Object, + media: object, type: string, action: "upload" | "attach" | "update", observationId?: number | null -): Object { +): object { if ( type === "Photo" || type === "ObservationPhoto" ) { if ( action === "upload" ) { return ObservationPhoto.mapPhotoForUpload( observationId, media ); diff --git a/src/uploaders/dataTransformation/prepareObservationForUpload.ts b/src/uploaders/dataTransformation/prepareObservationForUpload.ts index bb6069bf6..0986d5332 100644 --- a/src/uploaders/dataTransformation/prepareObservationForUpload.ts +++ b/src/uploaders/dataTransformation/prepareObservationForUpload.ts @@ -1,6 +1,6 @@ import Observation from "realmModels/Observation"; -function prepareObservationForUpload( obs: Object ): Object { +function prepareObservationForUpload( obs: object ): object { const obsToUpload = Observation.mapObservationForUpload( obs ); // Remove all null values, b/c the API doesn't seem to like them for some diff --git a/src/uploaders/utils/realmSync.ts b/src/uploaders/utils/realmSync.ts index b8ded8866..bcc80b184 100644 --- a/src/uploaders/utils/realmSync.ts +++ b/src/uploaders/utils/realmSync.ts @@ -1,14 +1,14 @@ import safeRealmWrite from "sharedHelpers/safeRealmWrite"; function findRecordInRealm( - realm: Object, + realm: object, observationUUID: string, recordUUID: string | null, type: string, options?: { - record: Object + record: object } -): Object | null { +): object | null { if ( !realm || realm.isClosed ) return null; // Photos do not have UUIDs, so we pass the Photo itself as an option @@ -31,8 +31,8 @@ function findRecordInRealm( } function updateRecordWithServerId( - realm: Object, - record: Object, + realm: object, + record: object, serverId: number, type: string ): void { @@ -47,13 +47,13 @@ function updateRecordWithServerId( function handleRecordUpdateError( error: Error, - realm: Object, + realm: object, observationUUID: string, recordUUID: string | null, type: string, serverId: number, options?: { - record: Object + record: object } ): void { // Try it one more time in case it was invalidated but it's still in the @@ -86,9 +86,9 @@ const markRecordUploaded = ( response: { results: Array<{id: number}> }, - realm: Object, + realm: object, options?: { - record: Object + record: object } ) => { if ( !realm || realm.isClosed ) return;