-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/lint #274
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
Feature/lint #274
Changes from all commits
425e733
1dc83f6
ded53aa
3bb8d5b
a14e276
42d32a7
03363d9
e8512e3
2c9719d
3473f2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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", | ||
| }, | ||
| }, | ||
| ], | ||
| }; |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| npm run lint && npm run typecheck || exit 1 |
| 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" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { useEffect } from "react"; | |
|
|
||
| const useDisableWheel = () => { | ||
| useEffect(() => { | ||
| document.addEventListener("wheel", function (event) { | ||
| document.addEventListener("wheel", function () { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused |
||
| if ( | ||
| document.activeElement && | ||
| (document.activeElement as HTMLInputElement).type === "number" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed to pull hooks out of |
||
| 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}> | ||
|
|
||
There was a problem hiding this comment.
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.