From 8d81390c8352696167a3aecafdcd8476b5734fc6 Mon Sep 17 00:00:00 2001 From: Michael Schramm Date: Tue, 9 Jun 2020 11:54:50 +0200 Subject: [PATCH] apply eslint --- .eslintrc.js | 16 +- .travis.yml | 1 - components/auth/footer.tsx | 93 ++++---- components/auth/layout.tsx | 14 +- components/clean.input.ts | 24 ++- components/date.time.tsx | 10 +- components/error.page.tsx | 16 +- components/form/admin/base.data.tab.tsx | 17 +- components/form/admin/design.tab.tsx | 23 +- components/form/admin/end.page.tab.tsx | 121 ++++++----- components/form/admin/field.card.tsx | 82 ++++--- components/form/admin/fields.tab.tsx | 139 ++++++------ components/form/admin/is.live.tsx | 20 +- .../admin/respondent.notifications.tab.tsx | 33 +-- .../form/admin/self.notifications.tab.tsx | 33 +-- components/form/admin/start.page.tab.tsx | 121 ++++++----- components/form/admin/submission.values.tsx | 41 ++-- components/form/admin/types/date.type.tsx | 24 +-- components/form/admin/types/dropdown.type.tsx | 29 +-- components/form/admin/types/email.type.tsx | 12 +- components/form/admin/types/hidden.type.tsx | 8 +- components/form/admin/types/index.ts | 46 ++-- components/form/admin/types/link.type.tsx | 12 +- components/form/admin/types/number.type.tsx | 8 +- components/form/admin/types/radio.type.tsx | 26 +-- components/form/admin/types/rating.type.tsx | 13 +- components/form/admin/types/text.type.tsx | 8 +- components/form/admin/types/textarea.type.tsx | 8 +- components/form/admin/types/type.props.ts | 4 +- components/form/admin/types/yes_no.type.tsx | 8 +- components/form/field.tsx | 78 ++++--- components/form/page.tsx | 68 +++--- components/form/types/date.type.tsx | 31 ++- components/form/types/dropdown.type.tsx | 32 +-- components/form/types/email.type.tsx | 16 +- components/form/types/index.ts | 42 ++-- components/form/types/link.type.tsx | 16 +- components/form/types/number.type.tsx | 13 +- components/form/types/radio.type.tsx | 32 ++- components/form/types/rating.type.tsx | 10 +- components/form/types/text.type.tsx | 20 +- components/form/types/textarea.type.tsx | 18 +- components/form/types/type.props.ts | 2 +- components/form/types/yes_no.type.tsx | 10 +- components/input/color.tsx | 12 +- components/loading.page.tsx | 22 +- components/sidemenu.tsx | 8 +- components/structure.tsx | 202 +++++++++--------- components/styled/button.tsx | 32 ++- components/styled/color.change.ts | 58 ++--- components/styled/date.input.tsx | 42 ++-- components/styled/h1.tsx | 13 +- components/styled/h2.tsx | 13 +- components/styled/input.tsx | 44 ++-- components/styled/number.input.tsx | 42 ++-- components/styled/p.tsx | 13 +- components/styled/radio.tsx | 32 ++- components/styled/select.tsx | 38 ++-- components/styled/textarea.input.tsx | 38 ++-- components/time.ago.tsx | 14 +- components/use.submission.ts | 68 +++--- components/use.window.size.ts | 24 +-- components/user/admin/base.data.tab.tsx | 41 ++-- components/user/role.tsx | 12 +- components/with.auth.tsx | 33 ++- graphql/fragment/admin.form.fragment.ts | 10 +- graphql/fragment/admin.profile.fragment.ts | 2 +- graphql/fragment/admin.user.fragment.ts | 2 +- graphql/fragment/form.fragment.ts | 14 +- graphql/fragment/submission.fragment.ts | 2 +- .../mutation/admin.form.create.mutation.ts | 6 +- .../mutation/admin.form.delete.mutation.ts | 2 +- .../mutation/admin.form.update.mutation.ts | 6 +- .../mutation/admin.profile.update.mutation.ts | 8 +- .../mutation/admin.user.delete.mutation.ts | 2 +- .../mutation/admin.user.update.mutation.ts | 6 +- graphql/mutation/login.mutation.ts | 2 +- graphql/mutation/register.mutation.ts | 2 +- .../mutation/submission.finish.mutation.ts | 4 +- .../mutation/submission.set.field.mutation.ts | 4 +- graphql/mutation/submission.start.mutation.ts | 4 +- graphql/query/admin.form.query.ts | 10 +- graphql/query/admin.pager.form.query.ts | 6 +- graphql/query/admin.pager.submission.query.ts | 12 +- graphql/query/admin.pager.user.query.ts | 6 +- graphql/query/admin.profile.query.ts | 11 +- graphql/query/admin.statistic.query.ts | 7 +- graphql/query/admin.user.query.ts | 10 +- graphql/query/form.query.ts | 10 +- graphql/query/me.query.ts | 4 +- graphql/query/settings.query.ts | 10 +- pages/_app.tsx | 12 +- pages/admin/forms/[id]/index.tsx | 136 ++++++------ pages/admin/forms/[id]/submissions.tsx | 102 +++++---- pages/admin/forms/create.tsx | 52 ++--- pages/admin/forms/index.tsx | 149 +++++++------ pages/admin/index.tsx | 27 +-- pages/admin/profile.tsx | 88 ++++---- pages/admin/users/[id]/index.tsx | 80 +++---- pages/admin/users/index.tsx | 99 +++++---- pages/form/[id]/index.tsx | 96 +++++---- pages/form/index.tsx | 8 +- pages/index.tsx | 42 ++-- pages/login/confirm/[code].tsx | 8 +- pages/login/index.tsx | 54 ++--- pages/login/recover.tsx | 8 +- pages/register.tsx | 68 ++---- store/auth/index.ts | 14 +- store/index.ts | 30 +-- 109 files changed, 1727 insertions(+), 1707 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index b810847..4fc05f5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,21 +2,25 @@ module.exports = { root: true, parser: '@typescript-eslint/parser', parserOptions: { - ecmaFeatures: { jsx: true } + ecmaFeatures: { jsx: true }, }, extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react/recommended', - "plugin:jsx-a11y/recommended", + 'plugin:jsx-a11y/recommended', 'prettier/@typescript-eslint', 'plugin:prettier/recommended', ], rules: { - 'prettier/prettier': [ - "error", {}, { "usePrettierrc": true } - ], + 'prettier/prettier': ['error', {}, { usePrettierrc: true }], 'react/prop-types': 'off', + '@typescript-eslint/no-empty-interface': 'off', }, -}; + settings: { + react: { + version: 'detect', + }, + }, +} diff --git a/.travis.yml b/.travis.yml index f5a7d57..0ab8eb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,3 @@ cache: script: - yarn - yarn lint - - yarn build diff --git a/components/auth/footer.tsx b/components/auth/footer.tsx index 21f8d10..584b8db 100644 --- a/components/auth/footer.tsx +++ b/components/auth/footer.tsx @@ -1,13 +1,12 @@ -import {UpOutlined} from '@ant-design/icons/lib' -import {useQuery} from '@apollo/react-hooks' -import {Button, Menu, Select} from 'antd' +import { useQuery } from '@apollo/react-hooks' +import { Button, Select } from 'antd' import Link from 'next/link' -import {useRouter} from 'next/router' +import { useRouter } from 'next/router' import React from 'react' -import {useTranslation} from 'react-i18next' -import {SETTINGS_QUERY, SettingsQueryData} from '../../graphql/query/settings.query' -import {languages} from '../../i18n' -import {clearAuth, withAuth} from '../with.auth' +import { useTranslation } from 'react-i18next' +import { SETTINGS_QUERY, SettingsQueryData } from '../../graphql/query/settings.query' +import { languages } from '../../i18n' +import { clearAuth, withAuth } from '../with.auth' interface Props { me?: { @@ -16,10 +15,10 @@ interface Props { } } -const AuthFooterInner: React.FC = props => { +const AuthFooterInner: React.FC = (props) => { const { t, i18n } = useTranslation() const router = useRouter() - const {data} = useQuery(SETTINGS_QUERY) + const { data } = useQuery(SETTINGS_QUERY) const logout = () => { clearAuth() @@ -38,67 +37,55 @@ const AuthFooterInner: React.FC = props => { }} > - - {props.me ? ( - [ - - Hi, {props.me.username} - , - - ] - ): ( - [ - - - , - - - - ] - )} -
+ {props.me + ? [ + + Hi, {props.me.username} + , + , + ] + : [ + + + , + + + , + ]} +
+
- )} - actions={[ - remove(index)} /> - ]} + } + actions={[ remove(index)} />]} > - + + + - setNextTitle(e.target.value)}/> + setNextTitle(e.target.value)} /> = props => { - + ) } diff --git a/components/form/admin/fields.tab.tsx b/components/form/admin/fields.tab.tsx index dcca2fc..31ad96d 100644 --- a/components/form/admin/fields.tab.tsx +++ b/components/form/admin/fields.tab.tsx @@ -1,86 +1,90 @@ -import {PlusOutlined} from '@ant-design/icons/lib' -import {Button, Form, Select, Space, Tabs} from 'antd' -import {FormInstance} from 'antd/lib/form' -import {TabPaneProps} from 'antd/lib/tabs' -import React, {useCallback, useState} from 'react' -import {useTranslation} from 'react-i18next' -import {AdminFormFieldFragment} from '../../../graphql/fragment/admin.form.fragment' -import {FieldCard} from './field.card' -import {adminTypes} from './types' +import { PlusOutlined } from '@ant-design/icons/lib' +import { Button, Form, Select, Space, Tabs } from 'antd' +import { FormInstance } from 'antd/lib/form' +import { TabPaneProps } from 'antd/lib/tabs' +import React, { useCallback, useState } from 'react' +import { useTranslation } from 'react-i18next' +import { AdminFormFieldFragment } from '../../../graphql/fragment/admin.form.fragment' +import { FieldCard } from './field.card' +import { adminTypes } from './types' interface Props extends TabPaneProps { form: FormInstance fields: AdminFormFieldFragment[] - onChangeFields: (fields: AdminFormFieldFragment[]) => any + onChangeFields: (fields: AdminFormFieldFragment[]) => void } -export const FieldsTab: React.FC = props => { +export const FieldsTab: React.FC = (props) => { const { t } = useTranslation() const [nextType, setNextType] = useState('textfield') - const renderType = useCallback((field, index, remove) => { - return ( - - ) - }, [props.fields]) + const renderType = useCallback( + (field, index, remove) => { + return ( + + ) + }, + [props.fields] + ) - const addField = useCallback((add, index) => { - return ( - - - - - - - ) - }, [props.fields, nextType]) + + + + + ) + }, + [props.fields, nextType] + ) return ( - - + {(fields, { add, remove, move }) => { const addAndMove = (index) => (defaults) => { add(defaults) @@ -102,7 +106,6 @@ export const FieldsTab: React.FC = props => { ) }} - ) } diff --git a/components/form/admin/is.live.tsx b/components/form/admin/is.live.tsx index 51aebd7..863b4b7 100644 --- a/components/form/admin/is.live.tsx +++ b/components/form/admin/is.live.tsx @@ -1,22 +1,26 @@ -import {CheckCircleOutlined, CloseCircleOutlined} from '@ant-design/icons/lib' +import { CheckCircleOutlined, CloseCircleOutlined } from '@ant-design/icons/lib' import React from 'react' interface Props { isLive: boolean } -export const FormIsLive: React.FC = props => { +export const FormIsLive: React.FC = (props) => { if (props.isLive) { return ( - + ) } return ( - + ) } diff --git a/components/form/admin/respondent.notifications.tab.tsx b/components/form/admin/respondent.notifications.tab.tsx index f849ba6..905e75b 100644 --- a/components/form/admin/respondent.notifications.tab.tsx +++ b/components/form/admin/respondent.notifications.tab.tsx @@ -1,17 +1,17 @@ -import {InfoCircleOutlined} from '@ant-design/icons/lib' -import {Form, Input, Select, Switch, Tabs} from 'antd' -import {FormInstance} from 'antd/lib/form' -import {TabPaneProps} from 'antd/lib/tabs' -import React, {useEffect, useState} from 'react' -import {Trans, useTranslation} from 'react-i18next' -import {AdminFormFieldFragment} from '../../../graphql/fragment/admin.form.fragment' +import { InfoCircleOutlined } from '@ant-design/icons/lib' +import { Form, Input, Select, Switch, Tabs } from 'antd' +import { FormInstance } from 'antd/lib/form' +import { TabPaneProps } from 'antd/lib/tabs' +import React, { useEffect, useState } from 'react' +import { Trans, useTranslation } from 'react-i18next' +import { AdminFormFieldFragment } from '../../../graphql/fragment/admin.form.fragment' interface Props extends TabPaneProps { form: FormInstance fields: AdminFormFieldFragment[] } -export const RespondentNotificationsTab: React.FC = props => { +export const RespondentNotificationsTab: React.FC = (props) => { const { t } = useTranslation() const [enabled, setEnabled] = useState() @@ -33,7 +33,7 @@ export const RespondentNotificationsTab: React.FC = props => { const groups = {} - props.fields.forEach(field => { + props.fields.forEach((field) => { if (!groups[field.type]) { groups[field.type] = [] } @@ -47,7 +47,7 @@ export const RespondentNotificationsTab: React.FC = props => { name={['form', 'respondentNotifications', 'enabled']} valuePropName={'checked'} > - setEnabled(e.valueOf())} /> + setEnabled(e.valueOf())} /> = props => { message: t('validation:templateRequired'), }, ]} - extra={( + extra={
form:respondentNotifications.htmlTemplateInfo = props => {
- )} + } >
@@ -102,10 +103,12 @@ export const RespondentNotificationsTab: React.FC = props => { ]} > - {Object.keys(groups).map(key => ( + {Object.keys(groups).map((key) => ( - {groups[key].map(field => ( - {field.title} + {groups[key].map((field) => ( + + {field.title} + ))} ))} diff --git a/components/form/admin/start.page.tab.tsx b/components/form/admin/start.page.tab.tsx index 9763654..e79ca09 100644 --- a/components/form/admin/start.page.tab.tsx +++ b/components/form/admin/start.page.tab.tsx @@ -1,11 +1,11 @@ -import {DeleteOutlined, PlusOutlined} from '@ant-design/icons/lib' -import {Button, Card, Form, Input, Switch, Tabs} from 'antd' -import {TabPaneProps} from 'antd/lib/tabs' +import { DeleteOutlined, PlusOutlined } from '@ant-design/icons/lib' +import { Button, Card, Form, Input, Switch, Tabs } from 'antd' +import { TabPaneProps } from 'antd/lib/tabs' import React from 'react' -import {useTranslation} from 'react-i18next' -import {InputColor} from '../../input/color' +import { useTranslation } from 'react-i18next' +import { InputColor } from '../../input/color' -export const StartPageTab: React.FC = props => { +export const StartPageTab: React.FC = (props) => { const { t } = useTranslation() return ( @@ -18,17 +18,11 @@ export const StartPageTab: React.FC = props => { - + - + @@ -39,54 +33,65 @@ export const StartPageTab: React.FC = props => { - + {(fields, { add, remove }) => { return (
{fields.map((field, index) => ( - - remove(index)} /> - ]} + + remove(index)} />]}> + - - - - - - - - - - - - - - - - - - - - - ) - )} + + + + + + + + + + + + + + + + + + + + ))} = props => {