From 02ce9bb3b511b8d187f70ff2200b74efc7179009 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Wed, 23 Aug 2017 00:00:10 +0300 Subject: [PATCH] #305: fix linting errors after upgrading to eslint 4 --- .eslintrc | 19 ------- src/components/accounts/reducer.test.js | 6 +- src/components/auth/BaseAuthBody.js | 3 +- src/components/auth/PanelTransition.js | 4 +- src/components/auth/actions.js | 56 +++++++++---------- src/components/contact/ContactForm.js | 3 +- src/components/langMenu/LangMenu.js | 16 +++--- .../multiFactorAuth/MultiFactorAuth.js | 20 +++---- src/components/ui/form/Button.js | 11 ++-- src/components/ui/form/Captcha.js | 8 +-- src/components/ui/form/Dropdown.js | 9 +-- src/components/ui/form/Form.js | 6 +- src/index.js | 34 +++++------ src/services/api/authentication.js | 24 ++++---- src/services/authFlow/MfaState.js | 8 +-- src/services/authFlow/PasswordState.js | 20 +++---- src/services/request/request.js | 6 +- 17 files changed, 115 insertions(+), 138 deletions(-) diff --git a/.eslintrc b/.eslintrc index 8bf8609..ec5894b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,25 +9,6 @@ "react" ], - "ecmaFeatures": { - "jsx": true, - "modules": true, - "classes": true, - "defaultParams": true, - "destructuring": true, - "spread": true, - "arrowFunctions": true, - "blockBindings": true, - "objectLiteralComputedProperties": true, - "objectLiteralDuplicateProperties": true, - "objectLiteralShorthandMethods": true, - "objectLiteralShorthandProperties": true, - "restParams": true, - "superInFunctions": true, - "templateStrings": true, - "experimentalObjectRestSpread": true - }, - "env": { "mocha": true, // needed for tests. Apply it globaly till eslint/selint#3611 "browser": true, diff --git a/src/components/accounts/reducer.test.js b/src/components/accounts/reducer.test.js index b3d21c4..ac8e7cf 100644 --- a/src/components/accounts/reducer.test.js +++ b/src/components/accounts/reducer.test.js @@ -73,9 +73,9 @@ describe('Accounts reducer', () => { }; expect(accounts({...initial, available: [account]}, add(newAccount)), - 'to satisfy', { - available: [newAccount, account] - }); + 'to satisfy', { + available: [newAccount, account] + }); }); it('throws, when account is invalid', () => { diff --git a/src/components/auth/BaseAuthBody.js b/src/components/auth/BaseAuthBody.js index d9b72f2..d7fea31 100644 --- a/src/components/auth/BaseAuthBody.js +++ b/src/components/auth/BaseAuthBody.js @@ -32,8 +32,7 @@ export default class BaseAuthBody extends Component { renderErrors() { return this.form.hasErrors() ? - : null - ; + : null; } onFormSubmit() { diff --git a/src/components/auth/PanelTransition.js b/src/components/auth/PanelTransition.js index 875c4bb..8f84b26 100644 --- a/src/components/auth/PanelTransition.js +++ b/src/components/auth/PanelTransition.js @@ -258,8 +258,8 @@ class PanelTransition extends Component { const currentContext = contexts.find((context) => context.includes(key)); let sign = currentContext.indexOf(panelId) > currentContext.indexOf(prevPanelId) - ? fromRight - : fromLeft; + ? fromRight + : fromLeft; if (prevPanelId === key) { sign *= -1; } diff --git a/src/components/auth/actions.js b/src/components/auth/actions.js index 40892a3..38a4ff9 100644 --- a/src/components/auth/actions.js +++ b/src/components/auth/actions.js @@ -66,28 +66,28 @@ export function login({ authentication.login( {login, password, totp, rememberMe} ) - .then(authHandler(dispatch)) - .catch((resp) => { - if (resp.errors) { - if (resp.errors.password === PASSWORD_REQUIRED) { - return dispatch(setLogin(login)); - } else if (resp.errors.login === ACTIVATION_REQUIRED) { - return dispatch(needActivation()); - } else if (resp.errors.totp === TOTP_REQUIRED) { - return dispatch(requestTotp({ - login, - password, - rememberMe - })); - } else if (resp.errors.login === LOGIN_REQUIRED && password) { - logger.warn('No login on password panel'); + .then(authHandler(dispatch)) + .catch((resp) => { + if (resp.errors) { + if (resp.errors.password === PASSWORD_REQUIRED) { + return dispatch(setLogin(login)); + } else if (resp.errors.login === ACTIVATION_REQUIRED) { + return dispatch(needActivation()); + } else if (resp.errors.totp === TOTP_REQUIRED) { + return dispatch(requestTotp({ + login, + password, + rememberMe + })); + } else if (resp.errors.login === LOGIN_REQUIRED && password) { + logger.warn('No login on password panel'); - return dispatch(logoutAll()); + return dispatch(logoutAll()); + } } - } - return validationErrorsHandler(dispatch)(resp); - }) + return validationErrorsHandler(dispatch)(resp); + }) ); } @@ -152,17 +152,17 @@ export function register({ rulesAgreement, lang: getState().user.lang, captcha }) - .then(() => { - dispatch(updateUser({ - username, - email - })); + .then(() => { + dispatch(updateUser({ + username, + email + })); - dispatch(needActivation()); + dispatch(needActivation()); - browserHistory.push('/activation'); - }) - .catch(validationErrorsHandler(dispatch)) + browserHistory.push('/activation'); + }) + .catch(validationErrorsHandler(dispatch)) ); } diff --git a/src/components/contact/ContactForm.js b/src/components/contact/ContactForm.js index 4135f57..1d77952 100644 --- a/src/components/contact/ContactForm.js +++ b/src/components/contact/ContactForm.js @@ -168,8 +168,7 @@ export class ContactForm extends Component { logger.warn('Error sending feedback', resp); }) - .finally(() => this.setState({isLoading: false})) - ; + .finally(() => this.setState({isLoading: false})); }; } diff --git a/src/components/langMenu/LangMenu.js b/src/components/langMenu/LangMenu.js index 1165e89..1a867a2 100644 --- a/src/components/langMenu/LangMenu.js +++ b/src/components/langMenu/LangMenu.js @@ -68,14 +68,14 @@ class LangMenu extends Component { {showCurrentLang ? this.renderLangLabel(userLocale, LANGS[userLocale]) : ( - - - {' '} - - {' '} - - - )} + + + {' '} + + {' '} + + + )} diff --git a/src/components/profile/multiFactorAuth/MultiFactorAuth.js b/src/components/profile/multiFactorAuth/MultiFactorAuth.js index 1604abc..a812615 100644 --- a/src/components/profile/multiFactorAuth/MultiFactorAuth.js +++ b/src/components/profile/multiFactorAuth/MultiFactorAuth.js @@ -188,17 +188,17 @@ export default class MultiFactorAuth extends Component { - const {errors} = resp || {}; + .catch((resp) => { + const {errors} = resp || {}; - if (errors) { - return Promise.reject(errors); - } + if (errors) { + return Promise.reject(errors); + } - logger.error('MFA: Unexpected form submit result', { - resp - }); - }) - .finally(() => this.setState({isLoading: false})); + logger.error('MFA: Unexpected form submit result', { + resp + }); + }) + .finally(() => this.setState({isLoading: false})); }; } diff --git a/src/components/ui/form/Button.js b/src/components/ui/form/Button.js index bef73e8..dcbdfbb 100644 --- a/src/components/ui/form/Button.js +++ b/src/components/ui/form/Button.js @@ -36,11 +36,12 @@ export default class Button extends FormComponent { } = this.props; return ( -