Skip to content

Commit

Permalink
chore(lint): Remaining eslint refactor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nellh committed Oct 23, 2024
1 parent cf5956d commit eabf4dc
Show file tree
Hide file tree
Showing 62 changed files with 189 additions and 139 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jwtDecode from "jwt-decode"

interface OpenNeuroTokenProfile {
export interface OpenNeuroTokenProfile {
sub: string
email: string
provider: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ vi.mock("../../../uploader/uploader-view.jsx", () => ({
default: () => "mocked UploaderView",
}))
vi.mock("react-router-dom", async () => ({
// @ts-ignore-check
...(await vi.importActual("react-router-dom")),
useNavigate: () => navigate,
}))
Expand Down
4 changes: 2 additions & 2 deletions packages/openneuro-app/src/scripts/common/content/terms.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { ReactElement } from "react"
import React from "react"

/** Terms and conditions content. */
export function Terms(): ReactElement {
export function Terms(): React.ReactElement {
return (
<>
<p>
Expand Down
5 changes: 4 additions & 1 deletion packages/openneuro-app/src/scripts/components/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import {
flexRender,
getCoreRowModel,
getSortedRowModel,
SortingState,
useReactTable,
} from "@tanstack/react-table"
import type { SortingState } from "@tanstack/react-table"
import styled from "@emotion/styled"
import { format, isValid, parse } from "date-fns"

interface DataTableProps {
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
data: any[]
downloadFilename?: string
hideColumns?: string[]
Expand Down Expand Up @@ -55,6 +56,7 @@ export function extractDateString(dateString) {
return false
}

/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
function CellFormat(props): any {
const value = props.getValue()
let extractedDate
Expand Down Expand Up @@ -86,6 +88,7 @@ export function DataTable<T>({
Object.keys(data[0])
.filter((name) => !hideColumns.includes(name))
.map((name) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
columnHelper.accessor(name as any, {
header: name,
cell: CellFormat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CreateSnapshotMutation = ({ datasetId, tag, changes }) => {
interface SnapshotDatasetProps {
datasetId: string
tag: string
changes: Array<string>
changes: string[]

Check warning on line 36 in packages/openneuro-app/src/scripts/datalad/mutations/snapshot.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/datalad/mutations/snapshot.tsx#L36

Added line #L36 was not covered by tests
}

const SnapshotDataset = ({ datasetId, tag, changes }: SnapshotDatasetProps) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const CommentEditor = ({
)
const doAfterSubmit = () => {
setEditorState(EditorState.createEmpty())
done && done()
if (done) done()

Check warning on line 23 in packages/openneuro-app/src/scripts/dataset/comments/comment-editor.jsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/comments/comment-editor.jsx#L23

Added line #L23 was not covered by tests
}
const disabled = editorState.getUndoStack().size === 0
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import styled, { StyledComponent } from "@emotion/styled"
import styled from "@emotion/styled"
import type { StyledComponent } from "@emotion/styled"
import { Link } from "react-router-dom"
import { Tooltip } from "@openneuro/components/tooltip"
import { Icon } from "@openneuro/components/icon"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react"
import { DatasetToolButton } from "./DatasetToolButton"
import styled, { StyledComponent } from "@emotion/styled"
import styled from "@emotion/styled"
import type { StyledComponent } from "@emotion/styled"
import { useAgreement } from "../../components/agreement"

interface DatasetToolStyleProps {}

export const DatasetToolStyle: StyledComponent<DatasetToolStyleProps> = styled
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export const DatasetToolStyle: StyledComponent<{}> = styled
.span`
display: flex;
justify-content: flex-start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface FileTreeProps {
files: DatasetFile[]
editMode: boolean
defaultExpanded: boolean
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
datasetPermissions: any
toggleFileToDelete: ({ id, path, filename }) => void
isFileToBeDeleted: (id: string) => boolean
Expand Down
2 changes: 2 additions & 0 deletions packages/openneuro-app/src/scripts/dataset/files/files.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ interface FilesProps {
datasetName: string
files: DatasetFile[]
editMode: boolean
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
datasetPermissions: any
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
summary: any
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ const FileViewerNifti = ({
limitFrames4D: 5,
},
]
const nv = new Niivue({ dragAndDropEnabled: false })
const nv = new Niivue({
dragAndDropEnabled: false,
}) /* eslint-disable-next-line @typescript-eslint/no-explicit-any */

Check warning on line 22 in packages/openneuro-app/src/scripts/dataset/files/viewers/file-viewer-nifti.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/files/viewers/file-viewer-nifti.tsx#L20-L22

Added lines #L20 - L22 were not covered by tests
;(window as any).niivue = nv
nv.attachToCanvas(canvas.current)
nv.loadVolumes(volumeList) // press the "v" key to cycle through views (axial, coronal, sagittal, 3D, etc.)
nv.graph.autoSizeMultiplanar = true // use autosizing
nv.opts.multiplanarForceRender = true // ensure that we draw the time series graph in the tile usually reserved for the 3D render
nv.graph.normalizeValues = false // use raw data values on y-axis
nv.graph.opacity = 1.0 // show the graph
// Notes:
// Notes:

Check warning on line 30 in packages/openneuro-app/src/scripts/dataset/files/viewers/file-viewer-nifti.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/files/viewers/file-viewer-nifti.tsx#L30

Added line #L30 was not covered by tests
// 1. If an image only has one volume, the timeseries graph will not be visible.
// The 3D render will be placed in the graph tile instead.
// The 3D render will be placed in the graph tile instead.

Check warning on line 32 in packages/openneuro-app/src/scripts/dataset/files/viewers/file-viewer-nifti.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/files/viewers/file-viewer-nifti.tsx#L32

Added line #L32 was not covered by tests
// 2. Users can navigate volumes forward and backward in the series using the left and right arrow keys on desktop devices
// 3. On touch screens, users can tap on the timeseries graph to jump to a volume index
// 4. Users can load all volumes by clicking on the "..." displayed on the timeseries graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe("SelectInput", () => {
)
const event = {
preventDefault() {
null
},
target: { value: "false" },
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Sentry from "@sentry/react"
import React from "react"
import PropTypes from "prop-types"
import styled from "@emotion/styled"
Expand Down Expand Up @@ -44,12 +45,9 @@ function fallbackCopyTextToClipboard(text) {
textArea.select()

try {
const success = document.execCommand("copy")
console.log(
`Copying text command was ${success ? "successful!" : "unsuccessful."}`,
)
document.execCommand("copy")

Check warning on line 48 in packages/openneuro-app/src/scripts/dataset/fragments/copyable-tooltip.jsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/fragments/copyable-tooltip.jsx#L48

Added line #L48 was not covered by tests
} catch (err) {
console.error("Could not copy text: ", err)
Sentry.captureException(err)

Check warning on line 50 in packages/openneuro-app/src/scripts/dataset/fragments/copyable-tooltip.jsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/fragments/copyable-tooltip.jsx#L50

Added line #L50 was not covered by tests
}

document.body.removeChild(textArea)
Expand All @@ -59,8 +57,8 @@ function copyTextToClipboard(text) {
if (!navigator.clipboard) fallbackCopyTextToClipboard(text)
else {
navigator.clipboard.writeText(text).then(
() => console.log("Copying to clipboard was successful!"),
(err) => console.error("Could not copy text: ", err),
() => {},
(err) => Sentry.captureException(err),

Check warning on line 61 in packages/openneuro-app/src/scripts/dataset/fragments/copyable-tooltip.jsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/fragments/copyable-tooltip.jsx#L60-L61

Added lines #L60 - L61 were not covered by tests
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react"
import type { FC } from "react"

Check warning on line 2 in packages/openneuro-app/src/scripts/dataset/mutations/create-anonymous-reviewer.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/mutations/create-anonymous-reviewer.tsx#L2

Added line #L2 was not covered by tests
import { gql, useMutation } from "@apollo/client"
import { Link } from "react-router-dom"
import { Tooltip } from "@openneuro/components/tooltip"
import { Button } from "@openneuro/components/button"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ const DELETE_REVIEWER = gql`
}
`

// TODO - derive from GraphQL
interface ReviewerUser {
id: string
email: string
}

Check warning on line 21 in packages/openneuro-app/src/scripts/dataset/mutations/delete-anonymous-reviewer.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/mutations/delete-anonymous-reviewer.tsx#L16-L21

Added lines #L16 - L21 were not covered by tests
interface DeleteReviewerLinkProps {
datasetId: string
id: string
Expand All @@ -27,7 +33,7 @@ export const DeleteReviewerLink: FC<DeleteReviewerLinkProps> = ({
}) => {
const [DeleteReviewerLink] = useMutation(DELETE_REVIEWER, {
update(cache, { data: { deleteReviewer } }) {
const { reviewers } = cache.readFragment<{ reviewers: any[] }>({
const { reviewers } = cache.readFragment<{ reviewers: ReviewerUser[] }>({

Check warning on line 36 in packages/openneuro-app/src/scripts/dataset/mutations/delete-anonymous-reviewer.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/mutations/delete-anonymous-reviewer.tsx#L36

Added line #L36 was not covered by tests
id: `Dataset:${datasetId}`,
fragment: DATASET_REVIEWERS,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useState } from "react"
import React, { useState } from "react"
import { gql, useApolloClient, useMutation } from "@apollo/client"
import { Button } from "@openneuro/components/button"
import { createDataset } from "../../uploader/upload-mutation"
Expand All @@ -25,7 +25,7 @@ interface ImportDatasetMutationProps {
disabled?: boolean | null
}

export const ImportDatasetMutation: FC<ImportDatasetMutationProps> = ({
export const ImportDatasetMutation: React.FC<ImportDatasetMutationProps> = ({

Check warning on line 28 in packages/openneuro-app/src/scripts/dataset/mutations/import-dataset.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/mutations/import-dataset.tsx#L28

Added line #L28 was not covered by tests
url,
disabled,
affirmedDefaced,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const CREATE_SNAPSHOT = gql`
interface CreateSnapshotMutationProps {
datasetId: string
tag: string
changes: Array<string>
changes: string[]

Check warning on line 23 in packages/openneuro-app/src/scripts/dataset/mutations/snapshot.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/mutations/snapshot.tsx#L23

Added line #L23 was not covered by tests
disabled: boolean
}

Expand All @@ -47,8 +47,7 @@ const CreateSnapshotMutation = ({
onClick={(): void => {
void snapshotDataset({
variables: { datasetId, tag, changes },
}).then((data) => {
console.log(data)
}).then((_data) => {

Check warning on line 50 in packages/openneuro-app/src/scripts/dataset/mutations/snapshot.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/mutations/snapshot.tsx#L50

Added line #L50 was not covered by tests
navigate(`/datasets/${datasetId}/versions/${tag}`)
})
}}
Expand All @@ -62,7 +61,7 @@ const CreateSnapshotMutation = ({
interface SnapshotDatasetProps {
datasetId: string
tag: string
changes: Array<string>
changes: string[]

Check warning on line 64 in packages/openneuro-app/src/scripts/dataset/mutations/snapshot.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/mutations/snapshot.tsx#L64

Added line #L64 was not covered by tests
disabled: boolean
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const runValidations = (values) =>
.map((validation) => {
const relevantValues = validation.fields.map((key) => values[key])
// TODO - This doesn't seem necessary?
// @ts-expect-error
// @ts-expect-error this is a size 2 tuple but not checked due to jsx instead of tsx

Check warning on line 28 in packages/openneuro-app/src/scripts/dataset/routes/add-metadata.jsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/routes/add-metadata.jsx#L28

Added line #L28 was not covered by tests
const isValid = validation.check(relevantValues)
if (!isValid) return validation.errorMessage
})
Expand All @@ -52,7 +52,7 @@ const AddMetadata = ({ dataset }) => {
const errors = runValidations(newValues)
if (hasChanged(errors, validationErrors)) setValidationErrors(errors)
}
// @ts-ignore-next-line
// @ts-expect-error location.state is not fully typed

Check warning on line 55 in packages/openneuro-app/src/scripts/dataset/routes/add-metadata.jsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/routes/add-metadata.jsx#L55

Added line #L55 was not covered by tests
const submitPath = location.state && location.state.submitPath
const user = getProfile(cookies)
const hasEdit = (user && user.admin) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { HeaderRow3 } from "./styles/header-row"

interface DeletePageProps {
dataset: {
permissions: Record<string, any>
permissions: Record<string, object>

Check warning on line 14 in packages/openneuro-app/src/scripts/dataset/routes/delete-page.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/routes/delete-page.tsx#L14

Added line #L14 was not covered by tests
id: string
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from "react"
import semver, { ReleaseType } from "semver"
import semver from "semver"
import type { ReleaseType } from "semver"

Check warning on line 3 in packages/openneuro-app/src/scripts/dataset/routes/snapshot.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/routes/snapshot.tsx#L2-L3

Added lines #L2 - L3 were not covered by tests
import SnapshotDataset from "../mutations/snapshot"
import EditList from "../fragments/edit-list.jsx"
import { Button } from "@openneuro/components/button"
Expand Down
3 changes: 1 addition & 2 deletions packages/openneuro-app/src/scripts/errors/errorBoundary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ErrorBoundary.propTypes = {

// specific use case
// ignore error in apollo lib
// @ts-expect-error
// @ts-expect-error TODO - this is incorrectly extended but working
class ErrorBoundaryAssertionFailureException extends ErrorBoundary {
constructor(props) {
super(props)
Expand Down Expand Up @@ -104,7 +104,6 @@ class ErrorBoundaryDeletePageException extends ErrorBoundary {
const throwError = !/^\/datasets\/ds\d{6}\/delete$/.test(
window.location.pathname,
)
console.log(throwError)
return throwError
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React, { useContext } from "react"
import type { FC } from "react"
import { useNavigate } from "react-router-dom"
import { SearchParamsCtx } from "../search-params-ctx"
import { flattenedModalities, SearchParams } from "../initial-search-params"
import { flattenedModalities } from "../initial-search-params"
import type { SearchParams } from "../initial-search-params"
import { FacetSelect } from "@openneuro/components/facets"
import { AccordionTab, AccordionWrap } from "@openneuro/components/accordion"
import initialSearchParams from "../initial-search-params"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SearchParamsCtx } from "../search-params-ctx"
import { SearchSort } from "@openneuro/components/search-page"

interface SortBySelectProps {
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
variables: any
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Helmet from "react-helmet"
import AdminUser from "../authentication/admin-user.jsx"

export interface SearchContainerProps {
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
portalContent?: Record<string, any>
}

Expand All @@ -53,7 +54,9 @@ export interface SearchContainerProps {
*/
export const setDefaultSearch = (
modality: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
searchParams: Record<string, any>,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setSearchParams: (newParams: Record<string, any>) => void,
query: URLSearchParams,
): void => {
Expand Down
12 changes: 7 additions & 5 deletions packages/openneuro-app/src/scripts/search/search-params-ctx.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React, { createContext, FC, ReactNode, useContext } from "react"
import * as Sentry from "@sentry/react"
import React, { createContext, useContext } from "react"
import { useSearchParams } from "react-router-dom"
import initialSearchParams, { SearchParams } from "./initial-search-params"
import initialSearchParams from "./initial-search-params"
import type { SearchParams } from "./initial-search-params"

export const SearchParamsCtx = createContext(null)

interface SearchParamsProviderProps {
children: ReactNode
children: React.ReactNode
}

export const SearchParamsProvider: FC<SearchParamsProviderProps> = ({
export const SearchParamsProvider: React.FC<SearchParamsProviderProps> = ({
children,
}) => {
const [searchQuery, setSearch] = useSearchParams()
Expand All @@ -20,7 +22,7 @@ export const SearchParamsProvider: FC<SearchParamsProviderProps> = ({
searchParams = JSON.parse(query)
}
} catch (err) {
console.error(err)
Sentry.captureException(err)

Check warning on line 25 in packages/openneuro-app/src/scripts/search/search-params-ctx.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/search/search-params-ctx.tsx#L25

Added line #L25 was not covered by tests
}

const setSearchParams = (
Expand Down
1 change: 1 addition & 0 deletions packages/openneuro-app/src/scripts/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
export default null
declare const self: ServiceWorkerGlobalScope
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */

Check warning on line 8 in packages/openneuro-app/src/scripts/sw.ts

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/sw.ts#L8

Added line #L8 was not covered by tests
const globalAny: any = global // Workaround for serviceWorkerOption type missing
const CACHE_NAME = "openneuro"
const CACHE_PATHS = globalAny.serviceWorkerOption.assets
Expand Down
1 change: 0 additions & 1 deletion packages/openneuro-app/src/scripts/users/username.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { config } from "../config"
export const Username = ({ user }): JSX.Element => {
if (user.orcid) {
let orcidURL = "https://orcid.org/"
console.log(config.auth.orcid)
if (config.auth.orcid.ORCID_API_ENDPOINT.includes("sandbox")) {
orcidURL = "https://sandbox.orcid.org/"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/openneuro-app/src/scripts/utils/gtag.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*global globalThis*/
globalThis.dataLayer = globalThis.dataLayer || []

function gtag() {
globalThis.dataLayer.push(arguments)
function gtag(...args) {
globalThis.dataLayer.push(args)
}

gtag("js", new Date())
Expand Down
Loading

0 comments on commit eabf4dc

Please sign in to comment.