Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling fix/genome-page-linting into develop #676

Merged
merged 49 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3d49864
fix: eslint errors
ktun95 Mar 6, 2024
96de640
fix: eslint import/no-named-as-default errors
ktun95 Mar 6, 2024
18bbdc0
chore(mockOntologyData.ts): disable eslint rule sonarjs/no-duplicate-…
ktun95 Mar 6, 2024
565dc98
chore(BlastOptionsRow.tsx): update string formatting to use HTML enti…
ktun95 Mar 6, 2024
8a39caf
chore: refactor Loader components to use a more concise array creatio…
ktun95 Mar 6, 2024
f2ff72f
chore(next.config.mjs): add default export and disable eslint rule fo…
ktun95 Mar 6, 2024
5102beb
chore: update various components export default statements
ktun95 Mar 6, 2024
6ce64d3
chore(CommunityAnnotations): replace react-markdown mock file with Ty…
ktun95 Mar 7, 2024
b26a1a4
chore(jest.config.js): update moduleNameMapper for "react-markdown" t…
ktun95 Mar 7, 2024
670d756
refactor(withDataFilter): combine export statements for emptyArray an…
ktun95 Mar 7, 2024
bed258a
fix(OrthologsRow.tsx): rename component from PhenotypeRow to Ortholog…
ktun95 Mar 7, 2024
922cb3b
feat(proteininformation.tsx): add ProteinInformationPageWrapper compo…
ktun95 Mar 7, 2024
4881c59
fix(Login.test.tsx): fix import statement for Login component
ktun95 Mar 7, 2024
a3b5bbb
refactor(oauthConfig.ts): change import statement to import clientCon…
ktun95 Mar 7, 2024
13c71a5
fix(OauthSignHandler.test.tsx): import clientConfig as a named import…
ktun95 Mar 7, 2024
5fa766f
chore(GenomicCoordsTable.test.tsx): update import statement for Genom…
ktun95 Mar 7, 2024
84a1c36
chore(MockAuthProvider.tsx): remove eslint-disable comment to enforce…
ktun95 Mar 7, 2024
44883d9
chore(_app.tsx): refactor code to activate MSW and enable mock server…
ktun95 Mar 7, 2024
923b2ee
fix(BlastDatabaseRow.tsx): remove unused imports and variables, fix p…
ktun95 Mar 7, 2024
926f4fc
fix(mockAssociatedAda2.ts): change null values to undefined for genba…
ktun95 Mar 7, 2024
4f0d227
chore(package.json): add configuration for msw worker directory
ktun95 Mar 7, 2024
54b368d
refactor(panelGenerator.tsx): Remove redundant switch cases and add m…
ktun95 Mar 7, 2024
739b62b
refactor(panelGenerator.tsx): remove unused index variables in map fu…
ktun95 Mar 7, 2024
e92a11f
refactor(panelGenerator.tsx): reorganize panelGenerator
ktun95 Mar 7, 2024
dfdee22
refactor(panelGenerator.tsx): remove unused 'gene' parameter in retur…
ktun95 Mar 7, 2024
3f8f494
fix(panelGenerator.tsx): return an empty array instead of undefined w…
ktun95 Mar 7, 2024
64f7d02
chore(WikiLoader.tsx): disable eslint rule for array index key in the…
ktun95 Mar 7, 2024
6573d9a
fix(handlers.ts): add error response for cases where there is no mock…
ktun95 Mar 7, 2024
3b13e8a
fix(mockAssociatedData.ts): change genbank_mrna value from null to un…
ktun95 Mar 7, 2024
d6c34f1
refactor(mockReferencesData.ts, mockReferencesPiaA.ts): replace usage…
ktun95 Mar 7, 2024
712549c
chore: handle react/no-array-index-key errors
ktun95 Mar 7, 2024
eeaa569
chore(turbo.json): add globalEnv configuration for required environme…
ktun95 Mar 7, 2024
33b930a
chore(tests): add eslint-disable-next-line comments in test files
ktun95 Mar 7, 2024
c16fb9f
test(ReferencesContainer): refactor import of useRouter to use Jest's…
ktun95 Mar 8, 2024
70e3e19
feat: rename geneOrIDSection.ts to geneOrIdSection.ts
ktun95 Mar 8, 2024
80eb1ca
chore: various eslint fixes
ktun95 Mar 8, 2024
7dcc967
chore(genomepage): fix remaining eslint errors
ktun95 Mar 8, 2024
3e2163e
style(PanelWrapper.tsx): remove hover effect on link and change span …
ktun95 Mar 8, 2024
b4b5d14
refactor(Editor.tsx): comment out unused variable 'persistencePluginS…
ktun95 Mar 8, 2024
47f6ce5
chore: remove eslint-disable camelcase comments from multiple files
ktun95 Mar 8, 2024
82b1bd8
refactor(citation.ts): remove unused imports and unused variables to …
ktun95 Mar 8, 2024
a4ba092
refactor(ContentEditor.tsx): remove unused import and replace hardcod…
ktun95 Mar 8, 2024
d465ea5
chore(additional.d.ts): rename ProcessEnvironment interface to Proces…
ktun95 Mar 8, 2024
4e5f935
fix(useCreateApolloClient.tsx): remove unnecessary type casting for p…
ktun95 Mar 8, 2024
3965c69
chore(turbo.json): add NODE_ENV to the globalEnv array
ktun95 Mar 8, 2024
074fb9e
chore(publication): remove eslint-disable comment for turbo/no-undecl…
ktun95 Mar 8, 2024
db81f23
chore: remove unnecessary eslint-disable-next-line comment
ktun95 Mar 8, 2024
d5ebe45
chore(PanelWrapper.tsx): disable eslint rule for anchor elements in JSX
ktun95 Mar 8, 2024
5acd88a
chore(clientConfig): remove unused clientConfig file and consolidate …
ktun95 Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/dicty-frontpage/src/common/data/mockContent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable camelcase */
const CONTENT_STRING = `{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Annual International Dictyostelium Conference","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"International conferences dedicated to ","type":"text","version":1},{"detail":0,"format":2,"mode":"normal","style":"","text":"Dictyostelium","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":" started in 1977 with the meeting in Sardinia, and continued on a roughly 3-year cycle into the 1980's. However, as the field became more active, more local meetings sprang up to fill the gaps in the cycle. Notable amongst these was an annual series in the UK, which gradually became more international. By the late 1980's with the successive meetings at Amsterdam, Oxford, Airlie and Cambridge, the current pattern of annual meetings was established. Interestingly in the late 1990's as the field expanded further, local meetings were re-started in several countries. ","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"flex-layout","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`
const mockContent = [
{
Expand Down
1 change: 0 additions & 1 deletion apps/dicty-frontpage/src/common/data/superuser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable camelcase */
export const testPermission = {
id: "1",
level: "test",
Expand Down
9 changes: 0 additions & 9 deletions apps/dicty-frontpage/src/common/utils/citation.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
import { pipe } from "fp-ts/function"
import { getOrElse as OgetOrElse } from "fp-ts/Option"
import {
map as Amap,
last,
compact as Acompact,
intersperse as Aintersperse,
foldLeft as AfoldLeft,
foldMap as AfoldMap,
reduce as Areduce,
splitAt as AsplitAt,
updateAt as AupdateAt,
zero as Azero,
} from "fp-ts/Array"
import {
type NonEmptyArray,
splitAt as NEAsplitAt,
last as NEAlast,
init as NEAinit,
intersperse as NEAintersperse,
} from "fp-ts/NonEmptyArray"
import { bindTo as IbindTo, let as Ilet } from "fp-ts/Identity"
import { Do as ODo, bind as Obind, let as Olet } from "fp-ts/Option"
import { slice, trimRight } from "fp-ts/string"
import { match } from "ts-pattern"
import { type PublicationItem } from "../hooks/useFetchPublications"
Expand Down
1 change: 0 additions & 1 deletion apps/dicty-frontpage/src/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable camelcase */
import { BrowserLevel } from "browser-level"
import { mockContent } from "../common/data/mockContent"
import { mockSuperuser } from "../common/data/superuser"
Expand Down
3 changes: 0 additions & 3 deletions apps/genome-page/.eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions apps/genome-page/additional.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/// <reference types="next" />
import "typescript"

declare global {
namespace NodeJS {
// eslint-disable-next-line unicorn/prevent-abbreviations
interface ProcessEnv {
NEXT_PUBLIC_BASENAME: string
NEXT_PUBLIC_GA_TRACKING_ID: string
Expand Down
1 change: 1 addition & 0 deletions apps/genome-page/common/@types/dicty-components-login.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* eslint-disable unicorn/filename-case */
declare module "dicty-components-login"
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* eslint-disable unicorn/filename-case */
declare module "dicty-components-navbar"
30 changes: 17 additions & 13 deletions apps/genome-page/common/hooks/WikiDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
// group of functions that maps the markdown content/error to the corresponding react component
import * as E from "fp-ts/Either"
import * as F from "fp-ts-std/Function"
import WikiContainer from "../../components/features/CommunityAnnotations/WikiContainer"
import WikiLoader from "../../components/features/CommunityAnnotations/WikiLoader"

interface WikiContentProps {
import {
type Either,
isRight as EisRight,
isLeft as EisLeft,
} from "fp-ts/Either"
import { guard } from "fp-ts-std/Function"
import { WikiContainer } from "../../components/features/CommunityAnnotations/WikiContainer"
import { WikiLoader } from "../../components/features/CommunityAnnotations/WikiLoader"

interface WikiContentProperties {
markdown?: string
loading: boolean
}

// type for Either monad
export type WikiContentEither = E.Either<string, WikiContentProps>
export type WikiContentEither = Either<string, WikiContentProperties>

// predicate function that checks is the fetching is under process
const isLoading = (ma: WikiContentEither) => E.isRight(ma) && ma.right.loading
const isLoading = (ma: WikiContentEither) => EisRight(ma) && ma.right.loading

// predicate function to indicate if the fetching is completed
const isNotLoading = (ma: WikiContentEither) =>
E.isRight(ma) && !ma.right.loading
EisRight(ma) && !ma.right.loading

// react component for loading state
const loaderDisplay = () => <WikiLoader />

// react component for error display
const errDisplay = (ma: WikiContentEither) => E.isLeft(ma) && <WikiContainer />
const errorDisplay = (ma: WikiContentEither) => EisLeft(ma) && <WikiContainer />

// react component for display markdown content
const nameDisplay = (ma: WikiContentEither) =>
E.isRight(ma) && <WikiContainer markdown={ma.right.markdown as string} />
EisRight(ma) && <WikiContainer markdown={ma.right.markdown as string} />

// react component when something unexpected happened
const defaultDisplay = () => <h2>Not sure what happened</h2>

// this function maps three conditions, error,success or loading to a react component
export const toOutput = F.guard([
export const toOutput = guard([
[isLoading, loaderDisplay],
[E.isLeft, errDisplay],
[EisLeft, errorDisplay],
[isNotLoading, nameDisplay],
])(defaultDisplay)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import { isMutation, getGraphQLServer } from "./useCreateApolloClient"

describe("isMutation function", () => {
Expand Down
20 changes: 10 additions & 10 deletions apps/genome-page/common/hooks/useCreateApolloClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ import version from "dicty-graphql-schema/package.json"
const SCHEMA_VERSION_KEY = "gene-apollo-schema-version"
const GENE_CACHE_KEY = "gene-apollo-cache-persist"

const mutationList = ["Logout"]
const mutationList = new Set(["Logout"])

const isMutation = (value: string) => {
if (mutationList.includes(value)) {
return true
}
return false
}
const isMutation = (value: string) => mutationList.has(value)

const getGraphQLServer = (url: string, deployEnv: string, origin: string) => {
if (deployEnv === "staging" && origin === "https://dictycr.org") {
const getGraphQLServer = (
url: string,
deployEnvironment: string,
origin: string,
) => {
if (deployEnvironment === "staging" && origin === "https://dictycr.org") {
return process.env.NEXT_PUBLIC_ALT_GRAPHQL_SERVER
}
return url
Expand All @@ -42,6 +41,7 @@ const authLink = setContext((request, { headers }) => {
})

const createApolloLink = (server: string): ApolloLink =>
// eslint-disable-next-line unicorn/prefer-spread -- this .concat is not Array.concat
authLink.concat(
createHttpLink({
uri: `${server}/graphql`,
Expand Down Expand Up @@ -94,4 +94,4 @@ const useCreateApolloClient = () => {
}

export { isMutation, getGraphQLServer }
export default useCreateApolloClient
export { useCreateApolloClient }
58 changes: 30 additions & 28 deletions apps/genome-page/common/hooks/useGithubWiki.ts
Original file line number Diff line number Diff line change
@@ -1,71 +1,73 @@
// group of functions that receives an git url and provides a promise to resolve it to its
// markdown component
import { pipe, flow } from "fp-ts/lib/function"
import * as E from "fp-ts/lib/Either"
import * as TE from "fp-ts/lib/TaskEither"
import { toError } from "fp-ts/lib/Either"
import { of, tryCatch, chain, map, mapLeft } from "fp-ts/lib/TaskEither"
import { clone } from "isomorphic-git"
import * as S from "fp-ts/string"
import { Semigroup } from "fp-ts/string"
import { intercalate } from "fp-ts/Semigroup"
import http from "isomorphic-git/http/web"
import FS from "@isomorphic-git/lightning-fs"

export interface DirFileProps {
export interface DirectoryFileProperties {
dir: string
file: string
url: string
browserFS: FS
}

// The main wrapper function or hook
export function cloneGithubWiki(props: DirFileProps) {
const defaultCloneParams = {
http: http,
fs: props.browserFS,
export function cloneGithubWiki(properties: DirectoryFileProperties) {
const defaultCloneParameters = {
http,
fs: properties.browserFS,
corsProxy: "https://cors.isomorphic-git.org",
}
const defaultSep = "/"
const defaultSeparator = "/"

// function that converts the data to a monad that handle promise
const wrapper = (props: DirFileProps) => TE.of(props)
const wrapper = (properties_: DirectoryFileProperties) => of(properties_)

// function that runs the clone api and returns a promise, handles both the
// success and error conditons.
const executeCloneRepo = ({ dir, url, file }: DirFileProps) =>
TE.tryCatch(async () => {
await clone({ dir, url, ...defaultCloneParams })
return { dir, url, file } as DirFileProps
}, E.toError)
const executeCloneRepo = ({ dir, url, file }: DirectoryFileProperties) =>
tryCatch(async () => {
await clone({ dir, url, ...defaultCloneParameters })
return { dir, url, file } as DirectoryFileProperties
}, toError)
// const errLogger = TE.fromIOK(Console.error)
// const infoLogger = TE.fromIOK(Console.info)

// function that extract the error message from the Error object
const errMsgExtract = (err: Error) => err.message

// function that constructs the markdown file path inside the git repo
const addPath = ({ dir, file }: DirFileProps) => {
const pathDelimGroup = pipe(S.Semigroup, intercalate(defaultSep))
const addPath = ({ dir, file }: DirectoryFileProperties) => {
const pathDelimGroup = pipe(Semigroup, intercalate(defaultSeparator))
// eslint-disable-next-line unicorn/prefer-spread -- this .concat is not Array.concat
return pathDelimGroup.concat(dir, file)
}

// function that read the markdown file from the git repo. Also handles the error.
const readFileFromRepo = (path: string) =>
TE.tryCatch(async () => {
const buffer = await props.browserFS.promises.readFile(path, {
tryCatch(async () => {
const buffer = await properties.browserFS.promises.readFile(path, {
encoding: "utf8",
})
return buffer.toString()
}, E.toError)
}, toError)

// function that extract the error message from the Error object
// eslint-disable-next-line unicorn/consistent-function-scoping -- It's nice to keep this function here because these functions are defined in the order they are used in the flow below.
const errorMessageExtract = (error: Error) => error.message

// construct a pipeline from all the functions
const payload = flow(
wrapper,
TE.chain(executeCloneRepo),
chain(executeCloneRepo),
// TE.chainFirstIOK(infoLogger),
TE.map(addPath),
map(addPath),
// TE.chainFirstIOK(infoLogger),
TE.chain(readFileFromRepo),
chain(readFileFromRepo),
// TE.chainFirstIOK(infoLogger),
TE.mapLeft(errMsgExtract),
mapLeft(errorMessageExtract),
)
return payload(props)
return payload(properties)
}
13 changes: 7 additions & 6 deletions apps/genome-page/common/hooks/useGoogleAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const useGoogleAnalytics = () => {
const setGoogleAnalytics = async () => {
try {
const module = await import("react-ga")
const trackingID = process.env.NEXT_PUBLIC_GA_TRACKING_ID
const trackingID = process.env.NEXT_PUBLIC_GA_TRACKING_ID as string
const basename = process.env.NEXT_PUBLIC_BASENAME
const page = basename + router.pathname
let ReactGA = module.default
const ReactGA = module.default

ReactGA.initialize(trackingID)
ReactGA.set({ page: page, anonymizeIp: true })
ReactGA.set({ page, anonymizeIp: true })
ReactGA.pageview(page)

// also make sure to detect pageviews from bfcache
Expand All @@ -26,8 +26,9 @@ const useGoogleAnalytics = () => {
ReactGA.pageview(page)
}
})
} catch (e) {
console.error("could not load react-ga module", JSON.stringify(e))
} catch (error) {
// eslint-disable-next-line no-console
console.error("could not load react-ga module", JSON.stringify(error))
}
}

Expand All @@ -37,4 +38,4 @@ const useGoogleAnalytics = () => {
}, [router.pathname])
}

export default useGoogleAnalytics
export { useGoogleAnalytics }
8 changes: 0 additions & 8 deletions apps/genome-page/common/utils/clientConfig.sample.ts

This file was deleted.

Loading
Loading