From ffcd020cc62b108b28202171cccfac286e3addc9 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 23 Aug 2020 11:30:49 -0700 Subject: [PATCH] chore: React rules of hooks lint --- .eslintrc | 3 ++- app/components/DelayedMount.js | 2 +- app/components/HoverPreview.js | 16 ++++++++++------ package.json | 1 + yarn.lock | 5 +++++ 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.eslintrc b/.eslintrc index 87aabc376b..8eeaa95b1d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,7 +4,8 @@ "react-app", "plugin:import/errors", "plugin:import/warnings", - "plugin:flowtype/recommended" + "plugin:flowtype/recommended", + "plugin:react-hooks/recommended" ], "plugins": [ "prettier", diff --git a/app/components/DelayedMount.js b/app/components/DelayedMount.js index 65c5157843..e127456c98 100644 --- a/app/components/DelayedMount.js +++ b/app/components/DelayedMount.js @@ -14,7 +14,7 @@ export default function DelayedMount({ delay = 250, children }: Props) { return () => { clearTimeout(timeout); }; - }, []); + }, [delay]); if (!isShowing) { return null; diff --git a/app/components/HoverPreview.js b/app/components/HoverPreview.js index 1b05cf01c9..198f5eeba9 100644 --- a/app/components/HoverPreview.js +++ b/app/components/HoverPreview.js @@ -20,12 +20,7 @@ type Props = { onClose: () => void, }; -function HoverPreview({ node, documents, onClose, event }: Props) { - // previews only work for internal doc links for now - if (!isInternalUrl(node.href)) { - return null; - } - +function HoverPreviewInternal({ node, documents, onClose, event }: Props) { const slug = parseDocumentSlugFromUrl(node.href); const [isVisible, setVisible] = React.useState(false); @@ -131,6 +126,15 @@ function HoverPreview({ node, documents, onClose, event }: Props) { ); } +function HoverPreview({ node, ...rest }: Props) { + // previews only work for internal doc links for now + if (!isInternalUrl(node.href)) { + return null; + } + + return ; +} + const Animate = styled.div` animation: ${fadeAndSlideIn} 150ms ease; diff --git a/package.json b/package.json index bff5859fb9..ac108c5146 100644 --- a/package.json +++ b/package.json @@ -170,6 +170,7 @@ "eslint-plugin-jsx-a11y": "^6.1.0", "eslint-plugin-prettier": "^3.1.0", "eslint-plugin-react": "^7.20.0", + "eslint-plugin-react-hooks": "^4.1.0", "fetch-test-server": "^1.1.0", "flow-bin": "^0.104.0", "html-webpack-plugin": "3.2.0", diff --git a/yarn.lock b/yarn.lock index 52855fad79..1647b6ef37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4383,6 +4383,11 @@ eslint-plugin-prettier@^3.1.0: dependencies: prettier-linter-helpers "^1.0.0" +eslint-plugin-react-hooks@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.1.0.tgz#6323fbd5e650e84b2987ba76370523a60f4e7925" + integrity sha512-36zilUcDwDReiORXmcmTc6rRumu9JIM3WjSvV0nclHoUQ0CNrX866EwONvLR/UqaeqFutbAnVu8PEmctdo2SRQ== + eslint-plugin-react@^7.20.0: version "7.20.5" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.20.5.tgz#29480f3071f64a04b2c3d99d9b460ce0f76fb857"