Skip to content

Commit

Permalink
chore(lint): Linting and error handling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nellh committed Oct 22, 2024
1 parent 34a07ca commit 508a1dc
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react"
export interface CommunityHeaderProps {
communityHeader: string
communityPrimary: string
communitySecondary: Record<string, any>
communitySecondary: Record<string, object>
}

export const CommunityHeader = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import "./search-page.scss"

export interface SearchResultsListProps {
items
profile?: Record<string, any>
profile?: Record<string, object>
datasetTypeSelected: string
hasEditPermissions: (permissions: any, userId: any) => boolean
hasEditPermissions: (permissions: object, userId: string) => boolean
}
export const SearchResultsList = ({
items,
Expand Down
3 changes: 2 additions & 1 deletion packages/openneuro-components/src/tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { FC } from "react"
import React from "react"
import type { FC } from "react"

export interface TooltipProps {
tooltip: string
Expand Down
1 change: 1 addition & 0 deletions packages/openneuro-indexer/src/indexDatasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default async function indexDatasets(
}
await aliasDatasetsIndex(elasticClient)
} catch (e) {
// eslint-disable-next-line no-console

Check warning on line 28 in packages/openneuro-indexer/src/indexDatasets.ts

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-indexer/src/indexDatasets.ts#L28

Added line #L28 was not covered by tests
console.error(e)
}
}
4 changes: 2 additions & 2 deletions packages/openneuro-server/src/cache/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const decompress = promisify(zlib.gunzip)
*/
export function cacheKey(
type: CacheType,
compositeKeys: Array<string>,
compositeKeys: string[],
): string {
return `${type.toString()}:${compositeKeys.join(":")}`
}
Expand All @@ -35,7 +35,7 @@ class CacheItem {
constructor(
redis: Redis,
type: CacheType,
compositeKeys?: Array<string>,
compositeKeys?: string[],
expiration?: number,
) {
this.redis = redis
Expand Down
6 changes: 5 additions & 1 deletion packages/openneuro-server/src/datalad/snapshots.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Get snapshots from datalad-service tags
*/
import * as Sentry from "@sentry/node"
import request from "superagent"
import { reindexDataset } from "../elasticsearch/reindex-dataset"
import { redis, redlock } from "../libs/redis"
Expand All @@ -16,7 +17,8 @@ import { getFiles } from "./files"
import { generateDataladCookie } from "../libs/authentication/jwt"
import notifications from "../libs/notifications"
import Dataset from "../models/dataset"
import Snapshot, { SnapshotDocument } from "../models/snapshot"
import Snapshot from "../models/snapshot"
import type { SnapshotDocument } from "../models/snapshot"
import { updateDatasetRevision } from "./draft"
import { getDatasetWorker } from "../libs/datalad-service"
import { join } from "path"
Expand Down Expand Up @@ -62,6 +64,8 @@ const createIfNotExistsDoi = async (
descriptionFieldUpdates["DatasetDOI"] = `doi:${snapshotDoi}`
}
} catch (err) {
Sentry.captureException(err)
// eslint-disable-next-line no-console

Check warning on line 68 in packages/openneuro-server/src/datalad/snapshots.ts

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-server/src/datalad/snapshots.ts#L67-L68

Added lines #L67 - L68 were not covered by tests
console.error(err)
throw new Error("DOI minting failed.")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import config from "../config"
import { indexDataset, indexingToken, queryForIndex } from "@openneuro/search"
import { elasticClient } from "./elastic-client"
import {
ApolloClient,
from,
InMemoryCache,
NormalizedCacheObject,
} from "@apollo/client"
import { ApolloClient, from, InMemoryCache } from "@apollo/client"
import type { NormalizedCacheObject } from "@apollo/client"
import { setContext } from "@apollo/client/link/context"
import { HttpLink } from "@apollo/client/link/http"

Expand Down
1 change: 1 addition & 0 deletions packages/openneuro-server/src/graphql/resolvers/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const deleteDataset = async (
await removeDatasetSearchDocument(id)
} catch (err) {
// This likely means this dataset had not yet been indexed
/* eslint-disable-next-line no-console */

Check warning on line 128 in packages/openneuro-server/src/graphql/resolvers/dataset.ts

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-server/src/graphql/resolvers/dataset.ts#L128

Added line #L128 was not covered by tests
console.error(err)
}
await new Deletion({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ export const derivativeObject = (
*/
export const derivatives = async (
dataset: DatasetOrSnapshot,
): Promise<Array<DatasetDerivatives>> => {
): Promise<DatasetDerivatives[]> => {

Check warning on line 79 in packages/openneuro-server/src/graphql/resolvers/derivatives.ts

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-server/src/graphql/resolvers/derivatives.ts#L79

Added line #L79 was not covered by tests
let datasetId
if ("tag" in dataset) {
datasetId = getDatasetFromSnapshotId(dataset.id)
} else {
datasetId = dataset.id
}
const available: Array<DatasetDerivatives> = []
const available: DatasetDerivatives[] = []

Check warning on line 86 in packages/openneuro-server/src/graphql/resolvers/derivatives.ts

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-server/src/graphql/resolvers/derivatives.ts#L86

Added line #L86 was not covered by tests
if (await githubDerivative(datasetId, "mriqc")) {
available.push(derivativeObject(datasetId, "mriqc"))
}
Expand Down
2 changes: 1 addition & 1 deletion packages/openneuro-server/src/graphql/resolvers/draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { summary } from "./summary"
import { issues } from "./issues.js"
import { description } from "./description.js"
import { readme } from "./readme.js"
import { getDraftRevision, updateDatasetRevision } from "../../datalad/draft.js"
import { getDraftRevision } from "../../datalad/draft.js"

Check warning on line 6 in packages/openneuro-server/src/graphql/resolvers/draft.ts

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-server/src/graphql/resolvers/draft.ts#L6

Added line #L6 was not covered by tests
import { checkDatasetWrite } from "../permissions.js"
import { getFiles } from "../../datalad/files"
import { filterRemovedAnnexObjects } from "../utils/file.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function deleteReviewer(
/**
* Resolver for dataset reviewers
*/
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
export function reviewers(obj, _, { user, userInfo }) {
/* eslint-disable-line @typescript-eslint/no-unused-vars */
return Reviewer.find({ datasetId: obj.id }).lean().exec()
}

0 comments on commit 508a1dc

Please sign in to comment.