From 17537525654c7b528d7df12537a41caba6084cb0 Mon Sep 17 00:00:00 2001 From: Kichiyaki Date: Sat, 24 Apr 2021 18:37:12 +0200 Subject: [PATCH 1/2] update eslint configuration --- .eslintrc.js | 13 +++++++++++++ eslintrc.json | 3 --- package.json | 3 ++- src/common/Section/Section.tsx | 12 ++++++------ .../components/Header/QualificationSelector.tsx | 2 +- .../IndexPage/components/Timer/Timer.tsx | 2 +- src/libs/hooks/usePrompt.ts | 16 ++++++++-------- 7 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 .eslintrc.js delete mode 100644 eslintrc.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..f0c307f --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,13 @@ +module.exports = { + extends: ['react-app'], + rules: { + 'react/react-in-jsx-scope': 0, + 'react/jsx-pascal-case': [ + 'warn', + { + allowAllCaps: true, + ignore: [], + }, + ], + }, +}; diff --git a/eslintrc.json b/eslintrc.json deleted file mode 100644 index 4bed466..0000000 --- a/eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "react-app" -} \ No newline at end of file diff --git a/package.json b/package.json index 58b235a..8843a0f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "postbuild": "next-sitemap", "start": "next start", "start:production": "NODE_ENV=production yarn run start", - "codegen": "graphql-codegen" + "codegen": "graphql-codegen", + "lint": "eslint . --ext ts --ext tsx --ext js" }, "dependencies": { "@kichiyaki/roboto": "^1.0.0", diff --git a/src/common/Section/Section.tsx b/src/common/Section/Section.tsx index 1d54d57..7038d76 100644 --- a/src/common/Section/Section.tsx +++ b/src/common/Section/Section.tsx @@ -32,12 +32,12 @@ const Section = ({ return (
diff --git a/src/features/IndexPage/components/Header/QualificationSelector.tsx b/src/features/IndexPage/components/Header/QualificationSelector.tsx index 0f30e20..4c35e3c 100644 --- a/src/features/IndexPage/components/Header/QualificationSelector.tsx +++ b/src/features/IndexPage/components/Header/QualificationSelector.tsx @@ -1,4 +1,4 @@ -import { MouseEventHandler, useState } from 'react'; +import { useState } from 'react'; import { Maybe, Qualification } from 'libs/graphql'; import { SECTION_ID as PROFESSIONS_SECTION_ID } from '../Professions/Professions'; diff --git a/src/features/IndexPage/components/Timer/Timer.tsx b/src/features/IndexPage/components/Timer/Timer.tsx index 33b6ef7..3d6d19e 100644 --- a/src/features/IndexPage/components/Timer/Timer.tsx +++ b/src/features/IndexPage/components/Timer/Timer.tsx @@ -3,7 +3,7 @@ import { useCountdown } from 'libs/hooks'; import { makeStyles } from '@material-ui/core/styles'; import { Container, Grid, Typography } from '@material-ui/core'; -import Section, { BgColor, Size } from 'common/Section/Section'; +import Section, { BgColor } from 'common/Section/Section'; export interface TimerProps { dateOfTheExam: Date | string; diff --git a/src/libs/hooks/usePrompt.ts b/src/libs/hooks/usePrompt.ts index b84ca15..6761c1c 100644 --- a/src/libs/hooks/usePrompt.ts +++ b/src/libs/hooks/usePrompt.ts @@ -3,6 +3,13 @@ import { useEffect, useRef, useCallback } from 'react'; export const usePrompt = (when: boolean) => { const whenRef = useRef(when); + const handleUnload = useCallback((event: BeforeUnloadEvent) => { + if (whenRef.current) { + event.preventDefault(); + event.returnValue = ''; + } + }, []); + useEffect(() => { whenRef.current = when; }, [when]); @@ -12,12 +19,5 @@ export const usePrompt = (when: boolean) => { return () => { window.removeEventListener('beforeunload', handleUnload); }; - }, []); - - const handleUnload = useCallback((event: BeforeUnloadEvent) => { - if (whenRef.current) { - event.preventDefault(); - event.returnValue = ''; - } - }, []); + }, [handleUnload]); }; From 4f64f138d431a775914b5d8ae69858d0d5d93c4b Mon Sep 17 00:00:00 2001 From: Kichiyaki Date: Sat, 24 Apr 2021 18:39:03 +0200 Subject: [PATCH 2/2] rename SEO -> Seo --- .eslintrc.js | 1 - src/common/{SEO/SEO.tsx => Seo/Seo.tsx} | 4 ++-- src/features/ErrorPage/ErrorPage.tsx | 4 ++-- src/features/IndexPage/IndexPage.tsx | 4 ++-- src/features/PrivacyPolicyPage/PrivacyPolicyPage.tsx | 4 ++-- src/features/QualificationPage/features/TestPage/TestPage.tsx | 4 ++-- 6 files changed, 10 insertions(+), 11 deletions(-) rename src/common/{SEO/SEO.tsx => Seo/Seo.tsx} (95%) diff --git a/.eslintrc.js b/.eslintrc.js index f0c307f..869e67d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,7 +5,6 @@ module.exports = { 'react/jsx-pascal-case': [ 'warn', { - allowAllCaps: true, ignore: [], }, ], diff --git a/src/common/SEO/SEO.tsx b/src/common/Seo/Seo.tsx similarity index 95% rename from src/common/SEO/SEO.tsx rename to src/common/Seo/Seo.tsx index 3652ca8..ca22a8a 100644 --- a/src/common/SEO/SEO.tsx +++ b/src/common/Seo/Seo.tsx @@ -13,7 +13,7 @@ export interface SEOProps { description?: string; } -const SEO = ({ title, description = DEFAULT_DESCRIPTION }: SEOProps) => { +const Seo = ({ title, description = DEFAULT_DESCRIPTION }: SEOProps) => { const { asPath } = useRouter(); const formattedTitle = title ? `${title} | ${NAME}` : NAME; return ( @@ -51,4 +51,4 @@ const SEO = ({ title, description = DEFAULT_DESCRIPTION }: SEOProps) => { ); }; -export default SEO; +export default Seo; diff --git a/src/features/ErrorPage/ErrorPage.tsx b/src/features/ErrorPage/ErrorPage.tsx index fe52cae..64f8c82 100644 --- a/src/features/ErrorPage/ErrorPage.tsx +++ b/src/features/ErrorPage/ErrorPage.tsx @@ -4,7 +4,7 @@ import { ErrorProps } from 'next/error'; import { Box, Typography } from '@material-ui/core'; import Layout from 'common/Layout/Layout'; import Section from 'common/Section/Section'; -import SEO from 'common/SEO/SEO'; +import Seo from 'common/Seo/Seo'; const getTitleForStatusCode = (statusCode: number): string => { switch (statusCode) { @@ -19,7 +19,7 @@ const ErrorPage: NextPage = ({ statusCode, title }: ErrorProps) => { const _title = title ?? getTitleForStatusCode(statusCode); return ( - + { return ( - +
diff --git a/src/features/PrivacyPolicyPage/PrivacyPolicyPage.tsx b/src/features/PrivacyPolicyPage/PrivacyPolicyPage.tsx index e1e95ce..368eaf5 100644 --- a/src/features/PrivacyPolicyPage/PrivacyPolicyPage.tsx +++ b/src/features/PrivacyPolicyPage/PrivacyPolicyPage.tsx @@ -4,7 +4,7 @@ import { makeStyles } from '@material-ui/core/styles'; import { Container, Typography, Divider, Link } from '@material-ui/core'; import { Alert } from '@material-ui/lab'; import Layout from 'common/Layout/Layout'; -import SEO from 'common/SEO/SEO'; +import Seo from 'common/Seo/Seo'; const DESCRIPTION = 'Polityka prywatności opisuje zasady przetwarzania przez zdamegzaminzawodowy.pl informacji na Twój temat, w tym danych osobowych oraz ciasteczek, czyli tzw. cookies.'; @@ -13,7 +13,7 @@ function PrivacyPolicyPage() { const classes = useStyles(); return ( - + { return ( -