From d0bfa9fdb80b5b9630677559d6f65987aa281afb Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Sat, 4 Jun 2016 12:17:06 +0300 Subject: [PATCH] Fix eslint errors. Fixed bug in .eslintrc.json --- .eslintrc.json | 6 +++--- src/components/auth/actions.js | 31 +++++++++++++++---------------- src/components/user/actions.js | 7 +++---- src/index.js | 1 + src/routes.js | 2 +- src/services/authFlow/AuthFlow.js | 4 ++-- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 047c681..fef758c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -25,6 +25,7 @@ "env": { "browser": true, + "commonjs": true, "es6": true }, @@ -59,7 +60,6 @@ "no-labels": "error", "no-lone-blocks": "warn", "no-loop-func": "error", - "no-magic-numbers": "warn", "no-multi-spaces": "error", "no-multi-str": "error", "no-native-reassign": "error", @@ -107,11 +107,12 @@ "brace-style": ["error", "1tbs", {"allowSingleLine": true}], "comma-spacing": "error", "comma-style": "error", + "comma-dangle": ["warn", "only-multiline"], "computed-property-spacing": "error", "consistent-this": ["error", "that"], "camelcase": "warn", "eol-last": "warn", - "id-length": ["error", {"min": "error", "exceptions": ["x", "y", "i", "$"]}], + "id-length": ["error", {"min": 2, "exceptions": ["x", "y", "i", "$"]}], "indent": ["error", 4, {"SwitchCase": 1}], "jsx-quotes": "error", "key-spacing": ["error", {"mode": "minimum"}], @@ -136,7 +137,6 @@ "quotes": ["warn", "single"], "semi": "error", "semi-spacing": "error", - "space-after-keywords": "error", "keyword-spacing": "warn", "space-before-blocks": "error", "space-before-function-paren": ["error", "never"], diff --git a/src/components/auth/actions.js b/src/components/auth/actions.js index 39c758b..8f280fd 100644 --- a/src/components/auth/actions.js +++ b/src/components/auth/actions.js @@ -46,7 +46,7 @@ export function changePassword({ newRePassword = '' }) { return wrapInLoader((dispatch) => - dispatch(changeUserPassword({password, newPassword, newRePassword, logoutAll : false})) + dispatch(changeUserPassword({password, newPassword, newRePassword, logoutAll: false})) .catch(validationErrorsHandler(dispatch)) ); } @@ -237,23 +237,22 @@ function getOAuthRequest(oauth) { } function handleOauthParamsValidation(resp = {}) { - const error = new Error('Error completing request'); + let userMessage; if (resp.statusCode === 400 && resp.error === 'invalid_request') { - alert(`Invalid request (${resp.parameter} required).`); - throw error; - } - if (resp.statusCode === 400 && resp.error === 'unsupported_response_type') { - alert(`Invalid response type '${resp.parameter}'.`); - throw error; - } - if (resp.statusCode === 400 && resp.error === 'invalid_scope') { - alert(`Invalid scope '${resp.parameter}'.`); - throw error; - } - if (resp.statusCode === 401 && resp.error === 'invalid_client') { - alert('Can not find application you are trying to authorize.'); - throw error; + userMessage = `Invalid request (${resp.parameter} required).`; + } else if (resp.statusCode === 400 && resp.error === 'unsupported_response_type') { + userMessage = `Invalid response type '${resp.parameter}'.`; + } else if (resp.statusCode === 400 && resp.error === 'invalid_scope') { + userMessage = `Invalid scope '${resp.parameter}'.`; + } else if (resp.statusCode === 401 && resp.error === 'invalid_client') { + userMessage = 'Can not find application you are trying to authorize.'; + } else { + return; } + + /* eslint no-alert: "off" */ + alert(userMessage); + throw new Error('Error completing request'); } export const SET_CLIENT = 'set_client'; diff --git a/src/components/user/actions.js b/src/components/user/actions.js index 0ce8074..13af82a 100644 --- a/src/components/user/actions.js +++ b/src/components/user/actions.js @@ -60,9 +60,9 @@ export function fetchUserData() { dispatch(updateUser(resp)); return dispatch(changeLang(resp.lang)); - }) + }); + /* .catch((resp) => { - /* { "name": "Unauthorized", "message": "You are requesting with an invalid credential.", @@ -70,9 +70,8 @@ export function fetchUserData() { "status": 401, "type": "yii\\web\\UnauthorizedHttpException" } - */ - console.log(resp); }); + */ } export function changePassword({ diff --git a/src/index.js b/src/index.js index 2fc9cdd..384b606 100644 --- a/src/index.js +++ b/src/index.js @@ -87,6 +87,7 @@ function stopLoading() { document.getElementById('loader').classList.remove('is-active'); } +/* global process: false */ if (process.env.NODE_ENV !== 'production') { // some shortcuts for testing on localhost window.testOAuth = () => location.href = '/oauth?client_id=ely&redirect_uri=http%3A%2F%2Fely.by&response_type=code&scope=minecraft_server_session'; diff --git a/src/routes.js b/src/routes.js index e98c4a2..969def1 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1,5 +1,5 @@ import React from 'react'; -import { Route, IndexRoute, browserHistory } from 'react-router'; +import { Route, IndexRoute } from 'react-router'; import RootPage from 'pages/root/RootPage'; import IndexPage from 'pages/index/IndexPage'; diff --git a/src/services/authFlow/AuthFlow.js b/src/services/authFlow/AuthFlow.js index 3d2ef97..2656908 100644 --- a/src/services/authFlow/AuthFlow.js +++ b/src/services/authFlow/AuthFlow.js @@ -86,9 +86,9 @@ export default class AuthFlow { const callback = this.onReady; this.onReady = () => {}; return resp.then(callback); - } else { - return resp; } + + return resp; } }