diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 00000000..9c2cbaad --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,21 @@ +output: + - summary + - failure +pre-commit: + parallel: true + jobs: + - name: format + glob: "**/*.{ts,tsx,json}" + run: yarn --silent format:files {staged_files} + stage_fixed: true + + - name: lint + glob: "**/*.{ts,tsx}" + run: yarn --silent lint:files {staged_files} + stage_fixed: true + + - name: typecheck + run: yarn --silent typeCheck --pretty false + + - name: test + run: yarn --silent test diff --git a/package.json b/package.json index 10789c71..b6f95f5f 100644 --- a/package.json +++ b/package.json @@ -1,87 +1,91 @@ { - "name": "cell-catalog", - "description": "Cell catalog for Allen Institute for Cell Science", - "version": "1.3.2", - "author": "Megan Riel-Mehan", - "dependencies": { - "@ant-design/icons": "^5.5.1", - "@reach/router": "^1.3.4", - "@svgr/webpack": "^8.1.0", - "antd": "^5.21.2", - "decap-cms-app": "^3.6.3", - "decap-cms-media-library-cloudinary": "^3.0.1", - "decap-cms-media-library-uploadcare": "^3.0.0", - "gatsby": "^5.14.0-next.3", - "gatsby-plugin-decap-cms": "^4.0.3", - "gatsby-plugin-fix-fouc": "^1.0.5", - "gatsby-plugin-image": "^3.14.0", - "gatsby-plugin-netlify": "^5.1.1", - "gatsby-plugin-nprogress": "^5.15.0", - "gatsby-plugin-purgecss": "^6.0.0", - "gatsby-plugin-react-helmet": "^6.13.1", - "gatsby-plugin-react-svg": "^3.3.0", - "gatsby-plugin-sass": "^6.13.1", - "gatsby-plugin-sharp": "^5.13.1", - "gatsby-plugin-svgr-svgo": "^2.0.0", - "gatsby-remark-copy-linked-files": "^6.13.1", - "gatsby-remark-external-links": "^0.0.4", - "gatsby-remark-images": "^7.14.0", - "gatsby-remark-line-breaks": "^1.0.0", - "gatsby-remark-relative-images": "^2.0.5", - "gatsby-source-filesystem": "^5.13.1", - "gatsby-transformer-remark": "^6.13.1", - "gatsby-transformer-remark-frontmatter": "^1.1.0", - "gatsby-transformer-sharp": "^5.13.1", - "lodash": "^4.17.15", - "lodash-webpack-plugin": "^0.11.4", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "react-helmet": "^6.0.0", - "sass": "^1.43.2", - "uuid": "^8.0.0", - "vitest": "^4.0.17" - }, - "keywords": [ - "gatsby" - ], - "license": "MIT", - "main": "n/a", - "scripts": { - "clean": "gatsby clean", - "start": "npm run develop", - "build": "npm run clean && gatsby build", - "develop": "npm run clean && gatsby develop", - "serve": "gatsby serve", - "format": "prettier \"src/**/*{.tsx, .ts}\" --write", - "formatCheck": "prettier \"src/**/*{.tsx, .ts}\" --check", - "lint": "eslint \"src/**/*{.tsx, .ts}\" --quiet --fix", - "test": "vitest run", - "dev": "npx concurrently \"npx netlify-cms-proxy-server\" \"npm start -- --progress\"", - "typeCheck": "npx tsc -noEmit" - }, - "devDependencies": { - "@eslint/js": "^9.38.0", - "@trivago/prettier-plugin-sort-imports": "^5.2.2", - "@types/antd": "^1.0.0", - "@types/node": "^20.11.20", - "@types/react": "^18.2.59", - "@types/react-dom": "^18.2.19", - "@types/react-helmet": "^6.1.11", - "concurrently": "^9.1.2", - "eslint": "^9.38.0", - "eslint-plugin-react": "^7.37.5", - "eslint-plugin-sort-destructure-keys": "^2.0.0", - "gatsby-plugin-postcss": "^6.13.1", - "globals": "^16.4.0", - "jiti": "^2.6.1", - "netlify-cli": "^17.15.7", - "postcss": "^8.4.35", - "prettier": "^3.6.2", - "typescript": "^5.9.3", - "typescript-eslint": "^8.46.2", - "typescript-plugin-css-modules": "^5.1.0" - }, - "engines": { - "node": ">= 22.16.0" - } + "name": "cell-catalog", + "description": "Cell catalog for Allen Institute for Cell Science", + "version": "1.3.1", + "author": "Megan Riel-Mehan", + "license": "MIT", + "main": "n/a", + "dependencies": { + "@ant-design/icons": "^5.5.1", + "@reach/router": "^1.3.4", + "@svgr/webpack": "^8.1.0", + "antd": "^5.21.2", + "decap-cms-app": "^3.6.3", + "decap-cms-media-library-cloudinary": "^3.0.1", + "decap-cms-media-library-uploadcare": "^3.0.0", + "gatsby": "^5.14.0-next.3", + "gatsby-plugin-decap-cms": "^4.0.3", + "gatsby-plugin-fix-fouc": "^1.0.5", + "gatsby-plugin-image": "^3.14.0", + "gatsby-plugin-netlify": "^5.1.1", + "gatsby-plugin-nprogress": "^5.15.0", + "gatsby-plugin-purgecss": "^6.0.0", + "gatsby-plugin-react-helmet": "^6.13.1", + "gatsby-plugin-react-svg": "^3.3.0", + "gatsby-plugin-sass": "^6.13.1", + "gatsby-plugin-sharp": "^5.13.1", + "gatsby-plugin-svgr-svgo": "^2.0.0", + "gatsby-remark-copy-linked-files": "^6.13.1", + "gatsby-remark-external-links": "^0.0.4", + "gatsby-remark-images": "^7.14.0", + "gatsby-remark-line-breaks": "^1.0.0", + "gatsby-remark-relative-images": "^2.0.5", + "gatsby-source-filesystem": "^5.13.1", + "gatsby-transformer-remark": "^6.13.1", + "gatsby-transformer-remark-frontmatter": "^1.1.0", + "gatsby-transformer-sharp": "^5.13.1", + "lodash": "^4.17.15", + "lodash-webpack-plugin": "^0.11.4", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-helmet": "^6.0.0", + "sass": "^1.43.2", + "uuid": "^8.0.0", + "vitest": "^4.0.17" + }, + "keywords": [ + "gatsby" + ], + "scripts": { + "clean": "gatsby clean", + "start": "npm run develop", + "build": "npm run clean && gatsby build", + "develop": "npm run clean && gatsby develop", + "serve": "gatsby serve", + "format": "prettier \"src/**/*{.tsx, .ts}\" package.json --write", + "format:files": "prettier --write", + "formatCheck": "prettier \"src/**/*{.tsx, .ts}\" package.json --check", + "lint": "eslint \"src/**/*{.tsx, .ts}\" --quiet --fix", + "lint:files": "eslint --quiet --fix", + "test": "vitest run", + "dev": "npx concurrently \"npx netlify-cms-proxy-server\" \"npm start -- --progress\"", + "typeCheck": "tsc --noEmit", + "prepare": "lefthook install" + }, + "devDependencies": { + "@eslint/js": "^9.38.0", + "@trivago/prettier-plugin-sort-imports": "^5.2.2", + "@types/antd": "^1.0.0", + "@types/node": "^20.11.20", + "@types/react": "^18.2.59", + "@types/react-dom": "^18.2.19", + "@types/react-helmet": "^6.1.11", + "concurrently": "^9.1.2", + "eslint": "^9.38.0", + "eslint-plugin-react": "^7.37.5", + "eslint-plugin-sort-destructure-keys": "^2.0.0", + "gatsby-plugin-postcss": "^6.13.1", + "globals": "^16.4.0", + "jiti": "^2.6.1", + "lefthook": "^2.0.15", + "netlify-cli": "^17.15.7", + "postcss": "^8.4.35", + "prettier": "^3.6.2", + "typescript": "^5.9.3", + "typescript-eslint": "^8.46.2", + "typescript-plugin-css-modules": "^5.1.0" + }, + "engines": { + "node": ">= 22.16.0" + } } diff --git a/src/component-queries/convert-data.ts b/src/component-queries/convert-data.ts index 12eba3b5..0fd1b580 100644 --- a/src/component-queries/convert-data.ts +++ b/src/component-queries/convert-data.ts @@ -1,20 +1,20 @@ +import { formatCellLineId } from "../utils"; +import { getThumbnail } from "../utils/mediaUtils"; import { DiseaseCellLineNode, + GeneFrontmatter, + GeneticModification, + LookupGroup, NormalCellLineNode, + SearchAndFilterGroup, + SearchLookup, UnpackedDiseaseCellLine, UnpackedGene, UnpackedNormalCellLine, - GeneticModification, - SearchLookup, - SearchAndFilterGroup, - GeneFrontmatter, - LookupGroup, } from "./types"; -import { getThumbnail } from "../utils/mediaUtils"; -import { formatCellLineId } from "../utils"; export const extractGeneticModifications = ( - modifications?: GeneticModification[] + modifications?: GeneticModification[], ): { taggedGenes: UnpackedGene[]; alleleCounts: string[]; @@ -45,7 +45,7 @@ export const extractGeneticModifications = ( }; export const convertFrontmatterToDiseaseCellLine = ( - cellLineNode: DiseaseCellLineNode + cellLineNode: DiseaseCellLineNode, ): UnpackedDiseaseCellLine => { const diseaseData = cellLineNode.frontmatter.disease.frontmatter; const mutatedGenes = diseaseData.gene @@ -59,7 +59,7 @@ export const convertFrontmatterToDiseaseCellLine = ( const { alleleCounts, fluorescentTags, taggedGenes, tagLocations } = extractGeneticModifications( cellLineNode.frontmatter.parental_line.frontmatter - .genetic_modifications + .genetic_modifications, ); return { @@ -75,7 +75,8 @@ export const convertFrontmatterToDiseaseCellLine = ( path: cellLineNode.fields.slug, parentalLine: { thumbnailImage: getThumbnail( - cellLineNode.frontmatter.parental_line.frontmatter.images_and_videos + cellLineNode.frontmatter.parental_line.frontmatter + .images_and_videos, ), cellLineId: cellLineNode.frontmatter.parental_line.frontmatter.cell_line_id, @@ -97,7 +98,7 @@ export const convertFrontmatterToNormalCellLines = ({ }): UnpackedNormalCellLine => { const { alleleCounts, fluorescentTags, taggedGenes, tagLocations } = extractGeneticModifications( - cellLineNode.frontmatter.genetic_modifications + cellLineNode.frontmatter.genetic_modifications, ); const proteins = taggedGenes .map((gene) => gene.protein) @@ -125,21 +126,21 @@ export const convertFrontmatterToNormalCellLines = ({ orderLink: cellLineNode.frontmatter.order_link, orderPlasmid: cellLineNode.frontmatter.donor_plasmid, thumbnailImage: getThumbnail( - cellLineNode.frontmatter.images_and_videos + cellLineNode.frontmatter.images_and_videos, ), imagesAndVideos: cellLineNode.frontmatter.images_and_videos, - categoryLabels: cellLineNode.frontmatter.category_labels + categoryLabels: cellLineNode.frontmatter.category_labels, }; }; export const createLookupMappings = ( - data: SearchAndFilterGroup[] + data: SearchAndFilterGroup[], ): SearchLookup => { const geneSymToCellIds = new Map(); const structureAndNameToGene = new Map(); const categoryToIds = new Map(); const allSearchableTerms: Set = new Set(); - data.forEach((group:SearchAndFilterGroup) => { + data.forEach((group: SearchAndFilterGroup) => { const symbol = group.fieldValue; allSearchableTerms.add(symbol); const cellLines: number[] = []; @@ -161,7 +162,7 @@ export const createLookupMappings = ( }); } const genes = edge.node.frontmatter.genetic_modifications || []; - genes.forEach((obj: {gene: {frontmatter: GeneFrontmatter}}) => { + genes.forEach((obj: { gene: { frontmatter: GeneFrontmatter } }) => { const gene = obj.gene; const geneSymbol = gene.frontmatter.symbol; const geneName = gene.frontmatter.name; @@ -187,7 +188,6 @@ export const createLookupMappings = ( geneSymToCellIds, structureAndNameToGene, allSearchableTerms, - categoryToIds + categoryToIds, }; }; - \ No newline at end of file diff --git a/src/component-queries/types.ts b/src/component-queries/types.ts index bf4f7416..c69da063 100644 --- a/src/component-queries/types.ts +++ b/src/component-queries/types.ts @@ -109,14 +109,14 @@ export interface GenomicCharacterizationFrontmatter { clone: number; fp_ratio: number; plasmid: number; - }[] + }[]; ddpcr_caption: string; cr_rna_off_targets: { clones_analyzed: number; off_targets_sequenced_per_clone: number; total_sites_sequenced: number; mutations_identified: number; - }[] + }[]; off_targets_caption: string; } @@ -146,7 +146,7 @@ export interface NormalCellLineFrontmatter { stem_cell_characteristics: StemCellCharacteristicsFrontmatter; images_and_videos?: MediaFrontmatter; category_labels: CategoryLabel[]; -}; +} export interface NormalCellLineNode { id: string; @@ -290,16 +290,17 @@ export interface UnpackedNormalCellLine extends UnpackedCellLineMainInfo { categoryLabels: CategoryLabel[]; } -export type ParentLine = Pick +export type ParentLine = Pick< + UnpackedNormalCellLine, + | "thumbnailImage" + | "cellLineId" + | "cloneNumber" + | "taggedGenes" + | "alleleCounts" + | "tagLocations" + | "fluorescentTags" + | "geneticModifications" +>; export interface UnpackedDiseaseCellLine extends UnpackedCellLineMainInfo { diseaseStatus: string; @@ -339,7 +340,7 @@ export interface SearchLookup { // (so many words map to the same gene symbol) // used for getting a unique identifier for the geneSymToCellIds map structureAndNameToGene: Map; - categoryToIds: Map + categoryToIds: Map; allSearchableTerms: Set; } @@ -355,7 +356,7 @@ export enum CategoryLabel { export enum NavBarAnchorType { Internal = "internal", Download = "download", - External = "external" + External = "external", } export interface NavBarDropdownItem { @@ -367,4 +368,4 @@ export interface NavBarDropdownItem { export interface NavBarDropdownItemGroup { label: string; options: NavBarDropdownItem[]; -} \ No newline at end of file +} diff --git a/src/components/SubPage/convert-data.ts b/src/components/SubPage/convert-data.ts index e01e1ada..1506b13d 100644 --- a/src/components/SubPage/convert-data.ts +++ b/src/components/SubPage/convert-data.ts @@ -259,19 +259,19 @@ export const unpackNormalStemCellCharacteristics = ( caption: scc.cardiomyocyte_differentiation_caption, data: scc.cardiomyocyte_differentiation ? [ - { - troponinPercentPositive: - scc.cardiomyocyte_differentiation - .troponin_percent_positive, - dayOfBeatingPercent: - scc.cardiomyocyte_differentiation - .day_of_beating_percent, - dayOfBeatingRange: - scc.cardiomyocyte_differentiation - .day_of_beating_range, - key: "0", - }, - ] + { + troponinPercentPositive: + scc.cardiomyocyte_differentiation + .troponin_percent_positive, + dayOfBeatingPercent: + scc.cardiomyocyte_differentiation + .day_of_beating_percent, + dayOfBeatingRange: + scc.cardiomyocyte_differentiation + .day_of_beating_range, + key: "0", + }, + ] : [], }; diff --git a/src/hooks/useWidthBreakpoint.ts b/src/hooks/useWidthBreakpoint.ts index a61ba72d..23da516c 100644 --- a/src/hooks/useWidthBreakpoint.ts +++ b/src/hooks/useWidthBreakpoint.ts @@ -1,14 +1,14 @@ import { PHONE_BREAKPOINT, TABLET_BREAKPOINT } from "../constants"; import useWindowWidth from "./useWindowWidth"; -export const useMaxWidthBreakpoint = ( - breakpoint: number -): boolean => { +export const useMaxWidthBreakpoint = (breakpoint: number): boolean => { const windowWidth = useWindowWidth(); - return windowWidth < breakpoint + return windowWidth < breakpoint; }; -export const useMobileBreakpoint = () => useMaxWidthBreakpoint(PHONE_BREAKPOINT); -export const useTabletBreakpoint = () => useMaxWidthBreakpoint(TABLET_BREAKPOINT); +export const useMobileBreakpoint = () => + useMaxWidthBreakpoint(PHONE_BREAKPOINT); +export const useTabletBreakpoint = () => + useMaxWidthBreakpoint(TABLET_BREAKPOINT); export default useMaxWidthBreakpoint; diff --git a/yarn.lock b/yarn.lock index 80847af1..bf6eed55 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13415,6 +13415,72 @@ lazystream@^1.0.0: dependencies: readable-stream "^2.0.5" +lefthook-darwin-arm64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-darwin-arm64/-/lefthook-darwin-arm64-2.0.15.tgz#21c2aac653e9ad4dbd928c95bc1622825673d69e" + integrity sha512-ygAqG/NzOgY9bEiqeQtiOmCRTtp9AmOd3eyrpEaSrRB9V9f3RHRgWDrWbde9BiHSsCzcbeY9/X2NuKZ69eUsNA== + +lefthook-darwin-x64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-darwin-x64/-/lefthook-darwin-x64-2.0.15.tgz#24d18d5062fb7de19c7f11e531060089d9826e75" + integrity sha512-3wA30CzdSL5MFKD6dk7v8BMq7ScWQivpLbmIn3Pv67AaBavN57N/hcdGqOFnDDFI5WazVwDY7UqDfMIk5HZjEA== + +lefthook-freebsd-arm64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-freebsd-arm64/-/lefthook-freebsd-arm64-2.0.15.tgz#c3e53d484c58641c84fd010a164b7560a5d8fc66" + integrity sha512-FbYBBLVbX8BjdO+icN1t/pC3TOW3FAvTKv/zggBKNihv6jHNn/3s/0j2xIS0k0Pw9oOE7MVmEni3qp2j5vqHrQ== + +lefthook-freebsd-x64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-freebsd-x64/-/lefthook-freebsd-x64-2.0.15.tgz#0fa903beb0d340c99d5eb400e2090d3b6da1e63b" + integrity sha512-udHMjh1E8TfC0Z7Y249XZMATJOyj1Jxlj9JoEinkoBvAsePFKDEQg5teuXuTGhjsHYpqVekfSvLNNfHKUUbbjw== + +lefthook-linux-arm64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-linux-arm64/-/lefthook-linux-arm64-2.0.15.tgz#9da1bbc60ef07034e69c715acedf8d48bfc6768e" + integrity sha512-1HAPmdYhfcOlubv63sTnWtW2rFuC+kT1MvC3JvdrS5V6zrOImbBSnYZMJX/Dd3w4pm0x2ZJb9T+uef8a0jUQkg== + +lefthook-linux-x64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-linux-x64/-/lefthook-linux-x64-2.0.15.tgz#b12aebd93fcf11f521dc5e40d9b7a2dece96b17a" + integrity sha512-Pho87mlNFH47zc4fPKzQSp8q9sWfIFW/KMMZfx/HZNmX25aUUTOqMyRwaXxtdAo/hNJ9FX4JeuZWq9Y3iyM5VA== + +lefthook-openbsd-arm64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-openbsd-arm64/-/lefthook-openbsd-arm64-2.0.15.tgz#412dedf52f9f5b7925abe7b4bafc807cabde577e" + integrity sha512-pet03Edlj1QeFUgxcIK1xu8CeZA+ejYplvPgdfe//69+vQFGSDaEx3H2mVx8RqzWfmMbijM2/WfkZXR2EVw3bw== + +lefthook-openbsd-x64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-openbsd-x64/-/lefthook-openbsd-x64-2.0.15.tgz#a98ea91d40517d1233dd417a0ea9b0fda9f8201d" + integrity sha512-i+a364CcSAeIO5wQzLMHsthHt/v6n3XwhKmRq/VBzPOUv9KutNeF55yCE/6lvuvzwxpdEfBjh6cXPERC0yp98w== + +lefthook-windows-arm64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-windows-arm64/-/lefthook-windows-arm64-2.0.15.tgz#3eab319ca7a7a96685056e37a74b106853e30a97" + integrity sha512-69u5GdVOT4QIxc2TK5ce0cTXLzwB55Pk9ZnnJNFf1XsyZTGcg9bUWYYTyD12CIIXbVTa0RVXIIrbU9UgP8O1AQ== + +lefthook-windows-x64@2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook-windows-x64/-/lefthook-windows-x64-2.0.15.tgz#e379f4266cc03b292873fb988ad9f922d47df430" + integrity sha512-/zYEndCUgj8XK+4wvLYLRk3AcfKU6zWf2GHx+tcZ4K2bLaQdej4m+OqmQsVpUlF8N2tN9hfwlj1D50uz75LUuQ== + +lefthook@^2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/lefthook/-/lefthook-2.0.15.tgz#e74d16135861dd8d852452fa43a469dfb474f3ea" + integrity sha512-sl5rePO6UUOLKp6Ci+MMKOc86zicBaPUCvSw2Cq4gCAgTmxpxhIjhz7LOu2ObYerVRPpTq3gvzPTjI71UotjnA== + optionalDependencies: + lefthook-darwin-arm64 "2.0.15" + lefthook-darwin-x64 "2.0.15" + lefthook-freebsd-arm64 "2.0.15" + lefthook-freebsd-x64 "2.0.15" + lefthook-linux-arm64 "2.0.15" + lefthook-linux-x64 "2.0.15" + lefthook-openbsd-arm64 "2.0.15" + lefthook-openbsd-x64 "2.0.15" + lefthook-windows-arm64 "2.0.15" + lefthook-windows-x64 "2.0.15" + lerc@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lerc/-/lerc-3.0.0.tgz#36f36fbd4ba46f0abf4833799fff2e7d6865f5cb"