update eslint configuration

This commit is contained in:
Dawid Wysokiński 2021-04-24 18:37:12 +02:00
parent 0b0aa7dad9
commit 1753752565
7 changed files with 31 additions and 20 deletions

13
.eslintrc.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
extends: ['react-app'],
rules: {
'react/react-in-jsx-scope': 0,
'react/jsx-pascal-case': [
'warn',
{
allowAllCaps: true,
ignore: [],
},
],
},
};

View File

@ -1,3 +0,0 @@
{
"extends": "react-app"
}

View File

@ -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",

View File

@ -32,12 +32,12 @@ const Section = ({
return (
<section
className={clsx(className, classes.section, {
['is-medium']: size === Size.Medium,
['is-large']: size === Size.Large,
['is-primary']: bgColor === BgColor.Primary,
['is-primary-dark']: bgColor === BgColor.PrimaryDark,
['is-secondary']: bgColor === BgColor.Secondary,
['is-secondary-dark']: bgColor === BgColor.SecondaryDark,
'is-medium': size === Size.Medium,
'is-large': size === Size.Large,
'is-primary': bgColor === BgColor.Primary,
'is-primary-dark': bgColor === BgColor.PrimaryDark,
'is-secondary': bgColor === BgColor.Secondary,
'is-secondary-dark': bgColor === BgColor.SecondaryDark,
})}
{...rest}
>

View File

@ -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';

View File

@ -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;

View File

@ -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]);
};