From 01e2821132dda920102622893f83b192333edac8 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 15 Mar 2021 21:01:55 +0100 Subject: [PATCH] typing updates --- package-lock.json | 82 +++++++++---------- package.json | 6 +- src/components/molecules/Menu.tsx | 18 ++-- src/components/molecules/Pagination.tsx | 6 +- src/components/molecules/RelatedPosts.tsx | 4 +- .../molecules/Search/SearchButton.tsx | 9 +- src/components/molecules/Search/index.tsx | 2 +- .../molecules/Web3Donation/Alert.tsx | 7 +- src/components/organisms/Footer.tsx | 18 ++-- src/components/organisms/Header.tsx | 38 ++++----- 10 files changed, 96 insertions(+), 94 deletions(-) diff --git a/package-lock.json b/package-lock.json index df2a8938..d8c9c271 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3353,9 +3353,9 @@ } }, "@types/node": { - "version": "14.14.34", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.34.tgz", - "integrity": "sha512-dBPaxocOK6UVyvhbnpFIj2W+S+1cBTkHQbFQfeeJhoKFbzYcVUGHvddeWPSucKATb3F0+pgDq0i6ghEaZjsugA==" + "version": "14.14.35", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.35.tgz", + "integrity": "sha512-Lt+wj8NVPx0zUmUwumiVXapmaLUcAk3yPuHCFVXras9k5VT9TdhJqKqGVUQCD60OTMCl0qxJ57OiTL0Mic3Iag==" }, "@types/node-fetch": { "version": "2.5.8", @@ -3555,12 +3555,12 @@ "integrity": "sha512-HrCIVMLjE1MOozVoD86622S7aunluLb2PJdPfb3nYiEtohm8mIB/vyv0Fd37AdeMFrTUQXEunw78YloMA3Qilg==" }, "@typescript-eslint/eslint-plugin": { - "version": "4.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.17.0.tgz", - "integrity": "sha512-/fKFDcoHg8oNan39IKFOb5WmV7oWhQe1K6CDaAVfJaNWEhmfqlA24g+u1lqU5bMH7zuNasfMId4LaYWC5ijRLw==", + "version": "4.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.18.0.tgz", + "integrity": "sha512-Lzkc/2+7EoH7+NjIWLS2lVuKKqbEmJhtXe3rmfA8cyiKnZm3IfLf51irnBcmow8Q/AptVV0XBZmBJKuUJTe6cQ==", "requires": { - "@typescript-eslint/experimental-utils": "4.17.0", - "@typescript-eslint/scope-manager": "4.17.0", + "@typescript-eslint/experimental-utils": "4.18.0", + "@typescript-eslint/scope-manager": "4.18.0", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "lodash": "^4.17.15", @@ -3580,50 +3580,50 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "4.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.17.0.tgz", - "integrity": "sha512-ZR2NIUbnIBj+LGqCFGQ9yk2EBQrpVVFOh9/Kd0Lm6gLpSAcCuLLe5lUCibKGCqyH9HPwYC0GIJce2O1i8VYmWA==", + "version": "4.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.18.0.tgz", + "integrity": "sha512-92h723Kblt9JcT2RRY3QS2xefFKar4ZQFVs3GityOKWQYgtajxt/tuXIzL7sVCUlM1hgreiV5gkGYyBpdOwO6A==", "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.17.0", - "@typescript-eslint/types": "4.17.0", - "@typescript-eslint/typescript-estree": "4.17.0", + "@typescript-eslint/scope-manager": "4.18.0", + "@typescript-eslint/types": "4.18.0", + "@typescript-eslint/typescript-estree": "4.18.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "4.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.17.0.tgz", - "integrity": "sha512-KYdksiZQ0N1t+6qpnl6JeK9ycCFprS9xBAiIrw4gSphqONt8wydBw4BXJi3C11ywZmyHulvMaLjWsxDjUSDwAw==", + "version": "4.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.18.0.tgz", + "integrity": "sha512-W3z5S0ZbecwX3PhJEAnq4mnjK5JJXvXUDBYIYGoweCyWyuvAKfGHvzmpUzgB5L4cRBb+cTu9U/ro66dx7dIimA==", "requires": { - "@typescript-eslint/scope-manager": "4.17.0", - "@typescript-eslint/types": "4.17.0", - "@typescript-eslint/typescript-estree": "4.17.0", + "@typescript-eslint/scope-manager": "4.18.0", + "@typescript-eslint/types": "4.18.0", + "@typescript-eslint/typescript-estree": "4.18.0", "debug": "^4.1.1" } }, "@typescript-eslint/scope-manager": { - "version": "4.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.17.0.tgz", - "integrity": "sha512-OJ+CeTliuW+UZ9qgULrnGpPQ1bhrZNFpfT/Bc0pzNeyZwMik7/ykJ0JHnQ7krHanFN9wcnPK89pwn84cRUmYjw==", + "version": "4.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.18.0.tgz", + "integrity": "sha512-olX4yN6rvHR2eyFOcb6E4vmhDPsfdMyfQ3qR+oQNkAv8emKKlfxTWUXU5Mqxs2Fwe3Pf1BoPvrwZtwngxDzYzQ==", "requires": { - "@typescript-eslint/types": "4.17.0", - "@typescript-eslint/visitor-keys": "4.17.0" + "@typescript-eslint/types": "4.18.0", + "@typescript-eslint/visitor-keys": "4.18.0" } }, "@typescript-eslint/types": { - "version": "4.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.17.0.tgz", - "integrity": "sha512-RN5z8qYpJ+kXwnLlyzZkiJwfW2AY458Bf8WqllkondQIcN2ZxQowAToGSd9BlAUZDB5Ea8I6mqL2quGYCLT+2g==" + "version": "4.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.18.0.tgz", + "integrity": "sha512-/BRociARpj5E+9yQ7cwCF/SNOWwXJ3qhjurMuK2hIFUbr9vTuDeu476Zpu+ptxY2kSxUHDGLLKy+qGq2sOg37A==" }, "@typescript-eslint/typescript-estree": { - "version": "4.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.17.0.tgz", - "integrity": "sha512-lRhSFIZKUEPPWpWfwuZBH9trYIEJSI0vYsrxbvVvNyIUDoKWaklOAelsSkeh3E2VBSZiNe9BZ4E5tYBZbUczVQ==", + "version": "4.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.18.0.tgz", + "integrity": "sha512-wt4xvF6vvJI7epz+rEqxmoNQ4ZADArGQO9gDU+cM0U5fdVv7N+IAuVoVAoZSOZxzGHBfvE3XQMLdy+scsqFfeg==", "requires": { - "@typescript-eslint/types": "4.17.0", - "@typescript-eslint/visitor-keys": "4.17.0", + "@typescript-eslint/types": "4.18.0", + "@typescript-eslint/visitor-keys": "4.18.0", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", @@ -3642,11 +3642,11 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.17.0.tgz", - "integrity": "sha512-WfuMN8mm5SSqXuAr9NM+fItJ0SVVphobWYkWOwQ1odsfC014Vdxk/92t4JwS1Q6fCA/ABfCKpa3AVtpUKTNKGQ==", + "version": "4.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.18.0.tgz", + "integrity": "sha512-Q9t90JCvfYaN0OfFUgaLqByOfz8yPeTAdotn/XYNm5q9eHax90gzdb+RJ6E9T5s97Kv/UHWKERTmqA0jTKAEHw==", "requires": { - "@typescript-eslint/types": "4.17.0", + "@typescript-eslint/types": "4.18.0", "eslint-visitor-keys": "^2.0.0" } }, @@ -8826,8 +8826,8 @@ "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, "ethereum-blockies": { - "version": "git+ssh://git@github.com/MyEtherWallet/blockies.git#d36f87e50149aacafb34f099fe0bea1df76e010c", - "from": "ethereum-blockies@github:MyEtherWallet/blockies" + "version": "github:MyEtherWallet/blockies#d36f87e50149aacafb34f099fe0bea1df76e010c", + "from": "github:MyEtherWallet/blockies" }, "event-emitter": { "version": "0.3.5", @@ -17004,8 +17004,8 @@ "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=" }, "nord-visual-studio-code": { - "version": "git+ssh://git@github.com/arcticicestudio/nord-visual-studio-code.git#5186990b2c8ba8cec1251d4ff3739cdab246e691", - "from": "nord-visual-studio-code@github:arcticicestudio/nord-visual-studio-code" + "version": "github:arcticicestudio/nord-visual-studio-code#5186990b2c8ba8cec1251d4ff3739cdab246e691", + "from": "github:arcticicestudio/nord-visual-studio-code" }, "normalize-package-data": { "version": "2.5.0", diff --git a/package.json b/package.json index 76f0dbbe..3094447d 100644 --- a/package.json +++ b/package.json @@ -92,15 +92,15 @@ "@types/jest": "^26.0.20", "@types/loadable__component": "^5.13.3", "@types/lunr": "^2.3.3", - "@types/node": "^14.14.34", + "@types/node": "^14.14.35", "@types/node-fetch": "^2.5.8", "@types/react": "^17.0.3", "@types/react-dom": "^17.0.2", "@types/react-helmet": "^6.1.0", "@types/react-transition-group": "^4.4.0", "@types/shortid": "^0.0.29", - "@typescript-eslint/eslint-plugin": "^4.17.0", - "@typescript-eslint/parser": "^4.17.0", + "@typescript-eslint/eslint-plugin": "^4.18.0", + "@typescript-eslint/parser": "^4.18.0", "@welldone-software/why-did-you-render": "^6.1.1", "eslint": "^7.22.0", "eslint-config-prettier": "^8.1.0", diff --git a/src/components/molecules/Menu.tsx b/src/components/molecules/Menu.tsx index 09c402dd..c14fb767 100644 --- a/src/components/molecules/Menu.tsx +++ b/src/components/molecules/Menu.tsx @@ -10,17 +10,19 @@ export default function Menu(): ReactElement { const [menuOpen, setMenuOpen] = useState(false) const { menu } = useSiteMetadata() - const toggleMenu = () => { + function toggleMenu(): void { setMenuOpen(!menuOpen) } - const MenuItems = menu.map((item: MenuItem) => ( -
  • - - {item.title} - -
  • - )) + const MenuItems = menu.map( + (item: MenuItem): JSX.Element => ( +
  • + + {item.title} + +
  • + ) + ) return ( <> diff --git a/src/components/molecules/Pagination.tsx b/src/components/molecules/Pagination.tsx index a0b30812..9cd6a413 100644 --- a/src/components/molecules/Pagination.tsx +++ b/src/components/molecules/Pagination.tsx @@ -9,7 +9,7 @@ import { pagination } from './Pagination.module.css' -const PageNumber = ({ +function PageNumber({ i, slug, current @@ -17,7 +17,7 @@ const PageNumber = ({ i: number slug: string current?: boolean -}) => { +}): JSX.Element { const classes = current ? styleCurrent : styleNumber const link = i === 0 ? slug : `${slug}page/${i + 1}` @@ -34,7 +34,7 @@ function PrevNext({ }: { prevPagePath?: string nextPagePath?: string -}) { +}): JSX.Element { const link = prevPagePath || nextPagePath const rel = prevPagePath ? 'prev' : 'next' const title = prevPagePath ? 'Newer Posts' : 'Older Posts' diff --git a/src/components/molecules/RelatedPosts.tsx b/src/components/molecules/RelatedPosts.tsx index c4838952..acd0daae 100644 --- a/src/components/molecules/RelatedPosts.tsx +++ b/src/components/molecules/RelatedPosts.tsx @@ -21,7 +21,7 @@ function postsWithDataFilter( posts: [{ node: Post }], key: keyof Frontmatter, valuesToFind: string[] -) { +): { node: Post }[] { const newArray = posts .filter(({ node }: { node: Post }) => { const frontmatterKey = node.frontmatter[key] as [] @@ -39,7 +39,7 @@ function postsWithDataFilter( return newArray } -function photosWithDataFilter(posts: []) { +function photosWithDataFilter(posts: [{ node: Post }]): { node: Post }[] { const newArray = posts .filter((post: { node: Post }) => { const { fileAbsolutePath } = post.node diff --git a/src/components/molecules/Search/SearchButton.tsx b/src/components/molecules/Search/SearchButton.tsx index f671cf72..8c8e8881 100644 --- a/src/components/molecules/Search/SearchButton.tsx +++ b/src/components/molecules/Search/SearchButton.tsx @@ -2,8 +2,13 @@ import React, { ReactElement } from 'react' import { searchButton } from './SearchButton.module.css' import Icon from '../../atoms/Icon' -const SearchButton = (props: any): ReactElement => ( - ) diff --git a/src/components/molecules/Search/index.tsx b/src/components/molecules/Search/index.tsx index 3d7f2255..c8d0f869 100644 --- a/src/components/molecules/Search/index.tsx +++ b/src/components/molecules/Search/index.tsx @@ -26,7 +26,7 @@ export default function Search(): ReactElement { ) }, [query]) - const toggleSearch = () => { + function toggleSearch(): void { setSearchOpen(!searchOpen) } diff --git a/src/components/molecules/Web3Donation/Alert.tsx b/src/components/molecules/Web3Donation/Alert.tsx index 783df97a..83585ac0 100644 --- a/src/components/molecules/Web3Donation/Alert.tsx +++ b/src/components/molecules/Web3Donation/Alert.tsx @@ -17,10 +17,9 @@ const constructMessage = ( message?: { text?: string } ) => transactionHash - ? message && - message.text + - '

    ' + - getTransactionMessage(transactionHash).transaction + ? message?.text + + '

    ' + + getTransactionMessage(transactionHash).transaction : message && message.text const classes = (status: string) => diff --git a/src/components/organisms/Footer.tsx b/src/components/organisms/Footer.tsx index a48d0973..449f6ed0 100644 --- a/src/components/organisms/Footer.tsx +++ b/src/components/organisms/Footer.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement, PureComponent } from 'react' +import React from 'react' import { Link } from 'gatsby' import Icon from '../atoms/Icon' import Vcard from '../molecules/Vcard' @@ -30,13 +30,11 @@ function Copyright() { ) } -export default class Footer extends PureComponent { - render(): ReactElement { - return ( - - ) - } +export default function Footer(): JSX.Element { + return ( + + ) } diff --git a/src/components/organisms/Header.tsx b/src/components/organisms/Header.tsx index d3455759..e3a20655 100644 --- a/src/components/organisms/Header.tsx +++ b/src/components/organisms/Header.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement, PureComponent } from 'react' +import React from 'react' import { Link } from 'gatsby' import Search from '../molecules/Search' import Menu from '../molecules/Menu' @@ -6,24 +6,22 @@ import ThemeSwitch from '../molecules/ThemeSwitch' import { ReactComponent as Logo } from '../../images/logo.svg' import { header, headerContent, title, logo, nav } from './Header.module.css' -export default class Header extends PureComponent { - render(): ReactElement { - return ( -
    -
    -

    - - kremalicious - -

    +export default function Header(): JSX.Element { + return ( +
    +
    +

    + + kremalicious + +

    - -
    -
    - ) - } + +
    +
    + ) }