Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
70 changes: 70 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
node: true,
es6: true,
},
plugins: ["@typescript-eslint", "react", "react-hooks", "unused-imports"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier",
],
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["warn"],
"unused-imports/no-unused-imports": "error",
"@typescript-eslint/no-floating-promises": "warn",
"no-extra-boolean-cast": "warn",
"react/prop-types": "off",

// Currently this repo uses "any" and is generally loose
// on typing, so turning off some rules that might be
// best practice in the long run.
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",

// Added css module declartion if we want to move away
// from using require when importing css class names
// but turning this off for now
"@typescript-eslint/no-require-imports": "off",
},
settings: {
react: {
version: "detect",
},
},
ignorePatterns: ["node_modules/", "public/", ".cache/"],
// TODO: opted to override linting for the preview templates
// as its too much to handle during the initial migration
// They are typed very generally and loosely
overrides: [
{
files: ["src/cms/preview-templates/**/*.tsx"],
rules: {
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
],
};
31 changes: 31 additions & 0 deletions .github/workflows/lint-and-typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint and Typecheck

on:
push:
branches: [main, production]
pull_request:
branches: [main, production]

jobs:
lint-and-typecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run ESLint
run: npm run lint

- name: Run TypeScript typecheck
run: npm run typecheck
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint && npm run typecheck || exit 1
2 changes: 1 addition & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
// DEV_SSR: true,
// },
plugins: [
"gatsby-plugin-react-helmet",
"gatsby-plugin-react-helmet-async",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like for SSR the async version of react-helmet is preferred, and is also more maintained. I have yet to confirm what it does, and what this has changed. I just made the linter happy.

The Helmet is an example of something where I am unclear if we are intentionally implementing it or it is a legacy from the template used to start the repo.

"gatsby-plugin-fix-fouc",
"gatsby-remark-line-breaks",
{
Expand Down
159 changes: 88 additions & 71 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,90 @@
{
"name": "gatsby-starter-decap-cms",
"description": "Example Gatsby, and Netlify CMS project",
"version": "1.2.2",
"author": "Austin Green",
"dependencies": {
"@ant-design/icons": "^5.5.1",
"@reach/router": "^1.3.4",
"antd": "^5.21.2",
"decap-cms-app": "^3.0.12",
"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.13.1",
"gatsby-plugin-netlify": "^5.0.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-remark-copy-linked-files": "^6.13.1",
"gatsby-remark-external-links": "^0.0.4",
"gatsby-remark-images": "^7.13.1",
"gatsby-remark-line-breaks": "^1.0.0",
"gatsby-remark-relative-images": "^2.0.2",
"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",
"prop-types": "^15.6.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-helmet": "^6.0.0",
"sass": "^1.43.2",
"uuid": "^8.0.0"
},
"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 --trailing-comma es5 --no-semi --single-quote --write --tab-width 4 \"{gatsby-*.js,src/**/*.js}\"",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "npx concurrently \"npx netlify-cms-proxy-server\" \"npm start -- --progress\""
},
"devDependencies": {
"@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",
"gatsby-plugin-postcss": "^6.13.1",
"netlify-cli": "^17.15.7",
"postcss": "^8.4.35",
"prettier": "^2.0.5",
"typescript": "^5.3.3",
"typescript-plugin-css-modules": "^5.1.0"
},
"engines": {
"node": ">= 18.15.0"
}
"name": "gatsby-starter-decap-cms",
"description": "Example Gatsby, and Netlify CMS project",
"version": "1.2.2",
"author": "Austin Green",
"dependencies": {
"@ant-design/icons": "^5.5.1",
"@reach/router": "^1.3.4",
"antd": "^5.21.2",
"decap-cms-app": "^3.0.12",
"decap-cms-media-library-cloudinary": "^3.0.1",
"decap-cms-media-library-uploadcare": "^3.0.0",
"gatsby": "^5.14.0-next.3",
"gatsby-plugin-image": "^3.13.1",
"gatsby-plugin-react-helmet-async": "^1.2.3",
"lodash": "^4.17.15",
"prop-types": "^15.6.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-helmet-async": "^2.0.5",
"sass": "^1.43.2",
"uuid": "^8.0.0"
},
"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 --trailing-comma es5 --no-semi --single-quote --write --tab-width 4 \"{gatsby-*.js,src/**/*.js}\"",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "npx concurrently \"npx netlify-cms-proxy-server\" \"npm start -- --progress\"",
"lint": "eslint src --ext .ts,.tsx",
"typecheck": "tsc --noEmit",
"prepare": "husky"
},
"devDependencies": {
"@types/antd": "^1.0.0",
"@types/minimatch": "^6.0.0",
"@types/node": "^20.11.20",
"@types/react": "^18.2.59",
"@types/react-dom": "^18.2.19",
"@types/react-helmet": "^6.1.11",
"@typescript-eslint/eslint-plugin": "8.34.0",
"@typescript-eslint/parser": "8.34.0",
"concurrently": "^9.1.2",
"eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-unused-imports": "^4.1.4",
"gatsby-plugin-decap-cms": "^4.0.3",
"gatsby-plugin-fix-fouc": "^1.0.5",
"gatsby-plugin-netlify": "^5.0.0",
"gatsby-plugin-postcss": "^6.13.1",
"gatsby-plugin-purgecss": "^6.0.0",
"gatsby-plugin-react-svg": "^3.3.0",
"gatsby-plugin-sass": "^6.13.1",
"gatsby-plugin-sharp": "^5.13.1",
"gatsby-remark-copy-linked-files": "^6.13.1",
"gatsby-remark-external-links": "^0.0.4",
"gatsby-remark-images": "^7.13.1",
"gatsby-remark-line-breaks": "^1.0.0",
"gatsby-remark-relative-images": "^2.0.2",
"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",
"husky": "^9.1.7",
"lodash-webpack-plugin": "^0.11.4",
"netlify-cli": "^17.15.7",
"postcss": "^8.4.35",
"prettier": "^2.0.5",
"typescript": "^5.3.3",
"typescript-plugin-css-modules": "^5.1.0"
},
"engines": {
"node": ">= 18.15.0"
},
"resolutions": {
"cheerio": "1.0.0-rc.12",
"minimatch": "9.0.1",
"glob/minimatch": "9.0.1"
}
}
2 changes: 1 addition & 1 deletion src/cms/hooks/useDisableWheel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect } from "react";

const useDisableWheel = () => {
useEffect(() => {
document.addEventListener("wheel", function (event) {
document.addEventListener("wheel", function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

if (
document.activeElement &&
(document.activeElement as HTMLInputElement).type === "number"
Expand Down
17 changes: 9 additions & 8 deletions src/cms/preview-templates/DiseaseCatalogPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React from 'react'
import { DiseaseCatalogTemplate } from '../../templates/disease-catalog'
import { TemplateProps } from './types';

const DiseaseCatalogPreview = ({ entry, widgetFor }: TemplateProps) => (
<DiseaseCatalogTemplate
title={entry.getIn(["data", "title"])}
content={widgetFor("body")}
footerText={entry.getIn(["data", "footer_text"])}
/>
);
const DiseaseCatalogPreview = ({ entry, widgetFor }: TemplateProps) => {
const props = {
title: entry.getIn(["data", "title"]),
content: widgetFor("body"),
footerText: entry.getIn(["data", "footer_text"]),
};

return <DiseaseCatalogTemplate {...(props as any)} />;
};

export default DiseaseCatalogPreview;
export default DiseaseCatalogPreview;
Comment on lines +5 to +15
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a punt, along with the override rules in the eslint config, the preview code is too much to deal with right now.

5 changes: 3 additions & 2 deletions src/cms/preview-templates/DiseaseCellLinePreview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from "react";
import React from "react";

import { TemplateProps } from "./types";
import InfoPanel from "../../components/shared/InfoPanel";
Expand Down Expand Up @@ -82,8 +82,9 @@ const DiseaseCellLinePreview = ({ entry, getAsset }: TemplateProps) => {
<InfoPanel data={data} />
<CloneTable dataSource={cloneData} />

{images.map((data: any) => (
{images.map((data: any, idx: number) => (
<div
key={idx}
style={{
display: "flex",
alignItems: "center",
Expand Down
2 changes: 1 addition & 1 deletion src/cms/preview-templates/GeneNamePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GeneNameTemplate } from "../../templates/gene-name";
import { TemplateProps } from "./types";
import { Isoform } from "../../component-queries/types";

const GeneNamePreview = ({ entry, widgetFor }: TemplateProps) => {
const GeneNamePreview = ({ entry }: TemplateProps) => {
const isoforms = [] as Isoform[];
const isoformData = entry.getIn(["data", "isoforms"]);
if (isoformData) {
Expand Down
2 changes: 1 addition & 1 deletion src/cms/preview-templates/ProgressPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Descriptions, Steps } from "antd";
import { Steps } from "antd";
import { CellLineStatus } from "../../component-queries/types";

interface ProgressPreviewProps {
Expand Down
8 changes: 4 additions & 4 deletions src/component-queries/DiseaseCellLines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ const DiseaseCellLinesTemplate = (props: DiseaseCellLinesTemplateProps) => {
const { edges: cellLines } = props.data.allMarkdownRemark;
const { diseases } = props;
const groupedCellLines = groupLines(diseases, cellLines);
const width = useWindowWidth();
const isPhone = width < PHONE_BREAKPOINT;

const suppressRowClickRef = useRef(false);
Comment on lines +54 to +57
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed to pull hooks out of map

return diseases.map((disease) => {
if (!groupedCellLines[disease.name].length) {
return null;
}
const inProgress = disease.status === TableStatus.ComingSoon;
const width = useWindowWidth();
const isPhone = width < PHONE_BREAKPOINT;

const suppressRowClickRef = useRef(false);

return (
<div key={disease.name}>
Expand Down
3 changes: 2 additions & 1 deletion src/component-queries/Diseases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { graphql, StaticQuery } from "gatsby";
import DiseaseCellLineQuery from "./DiseaseCellLines";
import { DiseaseFrontmatter } from "./types";
import { TableStatus } from "../components/CellLineTable/types";

export interface QueryResult {
data: {
Expand All @@ -23,7 +24,7 @@ export interface UnpackedDisease {
name: string;
geneSymbol: string;
geneName: string;
status: string;
status: TableStatus;
}

const DiseaseTemplate = (props: QueryResult) => {
Expand Down
Loading
Loading