#305: fix linting errors after upgrading to eslint 4

This commit is contained in:
SleepWalker 2017-08-23 00:00:10 +03:00
parent e21f6c397d
commit 02ce9bb3b5
17 changed files with 115 additions and 138 deletions

View File

@ -9,25 +9,6 @@
"react" "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": { "env": {
"mocha": true, // needed for tests. Apply it globaly till eslint/selint#3611 "mocha": true, // needed for tests. Apply it globaly till eslint/selint#3611
"browser": true, "browser": true,

View File

@ -73,9 +73,9 @@ describe('Accounts reducer', () => {
}; };
expect(accounts({...initial, available: [account]}, add(newAccount)), expect(accounts({...initial, available: [account]}, add(newAccount)),
'to satisfy', { 'to satisfy', {
available: [newAccount, account] available: [newAccount, account]
}); });
}); });
it('throws, when account is invalid', () => { it('throws, when account is invalid', () => {

View File

@ -32,8 +32,7 @@ export default class BaseAuthBody extends Component {
renderErrors() { renderErrors() {
return this.form.hasErrors() return this.form.hasErrors()
? <AuthError error={this.form.getFirstError()} onClose={this.onClearErrors} /> ? <AuthError error={this.form.getFirstError()} onClose={this.onClearErrors} />
: null : null;
;
} }
onFormSubmit() { onFormSubmit() {

View File

@ -258,8 +258,8 @@ class PanelTransition extends Component {
const currentContext = contexts.find((context) => context.includes(key)); const currentContext = contexts.find((context) => context.includes(key));
let sign = currentContext.indexOf(panelId) > currentContext.indexOf(prevPanelId) let sign = currentContext.indexOf(panelId) > currentContext.indexOf(prevPanelId)
? fromRight ? fromRight
: fromLeft; : fromLeft;
if (prevPanelId === key) { if (prevPanelId === key) {
sign *= -1; sign *= -1;
} }

View File

@ -66,28 +66,28 @@ export function login({
authentication.login( authentication.login(
{login, password, totp, rememberMe} {login, password, totp, rememberMe}
) )
.then(authHandler(dispatch)) .then(authHandler(dispatch))
.catch((resp) => { .catch((resp) => {
if (resp.errors) { if (resp.errors) {
if (resp.errors.password === PASSWORD_REQUIRED) { if (resp.errors.password === PASSWORD_REQUIRED) {
return dispatch(setLogin(login)); return dispatch(setLogin(login));
} else if (resp.errors.login === ACTIVATION_REQUIRED) { } else if (resp.errors.login === ACTIVATION_REQUIRED) {
return dispatch(needActivation()); return dispatch(needActivation());
} else if (resp.errors.totp === TOTP_REQUIRED) { } else if (resp.errors.totp === TOTP_REQUIRED) {
return dispatch(requestTotp({ return dispatch(requestTotp({
login, login,
password, password,
rememberMe rememberMe
})); }));
} else if (resp.errors.login === LOGIN_REQUIRED && password) { } else if (resp.errors.login === LOGIN_REQUIRED && password) {
logger.warn('No login on password panel'); 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, rulesAgreement, lang: getState().user.lang,
captcha captcha
}) })
.then(() => { .then(() => {
dispatch(updateUser({ dispatch(updateUser({
username, username,
email email
})); }));
dispatch(needActivation()); dispatch(needActivation());
browserHistory.push('/activation'); browserHistory.push('/activation');
}) })
.catch(validationErrorsHandler(dispatch)) .catch(validationErrorsHandler(dispatch))
); );
} }

View File

@ -168,8 +168,7 @@ export class ContactForm extends Component {
logger.warn('Error sending feedback', resp); logger.warn('Error sending feedback', resp);
}) })
.finally(() => this.setState({isLoading: false})) .finally(() => this.setState({isLoading: false}));
;
}; };
} }

View File

@ -68,14 +68,14 @@ class LangMenu extends Component {
<a className={styles.trigger} href="#"> <a className={styles.trigger} href="#">
{showCurrentLang {showCurrentLang
? this.renderLangLabel(userLocale, LANGS[userLocale]) : ( ? this.renderLangLabel(userLocale, LANGS[userLocale]) : (
<span> <span>
<span className={styles.triggerIcon} /> <span className={styles.triggerIcon} />
{' '} {' '}
<Message {...messages.siteLanguage} /> <Message {...messages.siteLanguage} />
{' '} {' '}
<span className={isActive ? styles.triggerArrowBottom : styles.triggerArrowTop} /> <span className={isActive ? styles.triggerArrowBottom : styles.triggerArrowTop} />
</span> </span>
)} )}
</a> </a>
</div> </div>
</div> </div>

View File

@ -188,17 +188,17 @@ export default class MultiFactorAuth extends Component<Props, {
return mfa.enable(data); return mfa.enable(data);
} }
) )
.catch((resp) => { .catch((resp) => {
const {errors} = resp || {}; const {errors} = resp || {};
if (errors) { if (errors) {
return Promise.reject(errors); return Promise.reject(errors);
} }
logger.error('MFA: Unexpected form submit result', { logger.error('MFA: Unexpected form submit result', {
resp resp
}); });
}) })
.finally(() => this.setState({isLoading: false})); .finally(() => this.setState({isLoading: false}));
}; };
} }

View File

@ -36,11 +36,12 @@ export default class Button extends FormComponent {
} = this.props; } = this.props;
return ( return (
<button className={classNames(buttons[color], { <button
[buttons.loading]: loading, className={classNames(buttons[color], {
[buttons.block]: block, [buttons.loading]: loading,
[buttons.smallButton]: small [buttons.block]: block,
}, className)} [buttons.smallButton]: small
}, className)}
{...restProps} {...restProps}
> >
{this.formatMessage(label)} {this.formatMessage(label)}

View File

@ -24,14 +24,12 @@ export default class Captcha extends FormInputComponent {
}; };
componentDidMount() { componentDidMount() {
setTimeout(() => setTimeout(() => {
captcha.render(this.el, { captcha.render(this.el, {
skin: this.props.skin, skin: this.props.skin,
onSetCode: this.setCode onSetCode: this.setCode
}) }).then((captchaId) => this.captchaId = captchaId);
.then((captchaId) => this.captchaId = captchaId), }, this.props.delay);
this.props.delay
);
} }
render() { render() {

View File

@ -59,10 +59,11 @@ export default class Dropdown extends FormInputComponent {
return ( return (
<div> <div>
<div className={classNames(styles[color], { <div
[styles.block]: block, className={classNames(styles[color], {
[styles.opened]: isActive [styles.block]: block,
})} [styles.opened]: isActive
})}
{...props} {...props}
onClick={this.onToggle} onClick={this.onToggle}
> >

View File

@ -113,9 +113,9 @@ export default class Form extends Component<Props, State> {
Promise.resolve(this.props.onSubmit( Promise.resolve(this.props.onSubmit(
this.props.form ? this.props.form : new FormData(form) this.props.form ? this.props.form : new FormData(form)
)) ))
.catch((errors: {[key: string]: string}) => { .catch((errors: {[key: string]: string}) => {
this.setErrors(errors); this.setErrors(errors);
}); });
} else { } else {
const invalidEls = form.querySelectorAll(':invalid'); const invalidEls = form.querySelectorAll(':invalid');
const errors = {}; const errors = {};

View File

@ -34,24 +34,24 @@ Promise.all([
userFactory(store), userFactory(store),
font.load(['Roboto', 'Roboto Condensed']) font.load(['Roboto', 'Roboto Condensed'])
]) ])
.then(() => { .then(() => {
ReactDOM.render( ReactDOM.render(
<ReduxProvider store={store}> <ReduxProvider store={store}>
<IntlProvider> <IntlProvider>
<Router history={browserHistory}> <Router history={browserHistory}>
<Switch> <Switch>
<Route path="/oauth2/code/success" component={SuccessOauthPage} /> <Route path="/oauth2/code/success" component={SuccessOauthPage} />
<AuthFlowRoute path="/oauth2/:version(v\d+)/:clientId?" component={() => null} /> <AuthFlowRoute path="/oauth2/:version(v\d+)/:clientId?" component={() => null} />
<Route path="/" component={RootPage} /> <Route path="/" component={RootPage} />
</Switch> </Switch>
</Router> </Router>
</IntlProvider> </IntlProvider>
</ReduxProvider>, </ReduxProvider>,
document.getElementById('app') document.getElementById('app')
); );
initAnalytics(); initAnalytics();
}); });
import { loadScript, debounce } from 'functions'; import { loadScript, debounce } from 'functions';
const trackPageView = debounce(_trackPageView); const trackPageView = debounce(_trackPageView);

View File

@ -95,19 +95,19 @@ const authentication = {
resolve(); resolve();
}) })
.then(() => accounts.current({token})) .then(() => accounts.current({token}))
.then((user) => ({token, refreshToken, user})) .then((user) => ({token, refreshToken, user}))
.catch((resp) => { .catch((resp) => {
if (resp.message === 'Token expired') { if (resp.message === 'Token expired') {
return authentication.requestToken(refreshToken) return authentication.requestToken(refreshToken)
.then(({token}) => .then(({token}) =>
accounts.current({token}) accounts.current({token})
.then((user) => ({token, refreshToken, user})) .then((user) => ({token, refreshToken, user}))
); );
} }
return Promise.reject(resp); return Promise.reject(resp);
}); });
}, },
/** /**

View File

@ -37,10 +37,10 @@ export default class MfaState extends AbstractState {
rememberMe, rememberMe,
login login
}) })
.then(() => context.setState(new CompleteState())) .then(() => context.setState(new CompleteState()))
.catch((err = {}) => .catch((err = {}) =>
err.errors || logger.warn('Error logging in', err) err.errors || logger.warn('Error logging in', err)
); );
} }
goBack(context: AuthContext) { goBack(context: AuthContext) {

View File

@ -38,18 +38,18 @@ export default class PasswordState extends AbstractState {
rememberMe, rememberMe,
login login
}) })
.then(() => { .then(() => {
const {isTotpRequired} = getCredentials(context.getState()); const {isTotpRequired} = getCredentials(context.getState());
if (isTotpRequired) { if (isTotpRequired) {
return context.setState(new MfaState()); return context.setState(new MfaState());
} }
return context.setState(new CompleteState()); return context.setState(new CompleteState());
}) })
.catch((err = {}) => .catch((err = {}) =>
err.errors || logger.warn('Error logging in', err) err.errors || logger.warn('Error logging in', err)
); );
} }
reject(context: AuthContext) { reject(context: AuthContext) {

View File

@ -117,8 +117,7 @@ function doFetch(url, options = {}) {
.then(toJSON, rejectWithJSON) .then(toJSON, rejectWithJSON)
.then(handleResponseSuccess) .then(handleResponseSuccess)
.then((resp) => middlewareLayer.run('then', resp, {url, options})) .then((resp) => middlewareLayer.run('then', resp, {url, options}))
.catch((resp) => middlewareLayer.run('catch', resp, {url, options}, () => doFetch(url, options))) .catch((resp) => middlewareLayer.run('catch', resp, {url, options}, () => doFetch(url, options)));
;
} }
/** /**
@ -159,6 +158,5 @@ function buildQuery(data: Object = {}): string {
.map(encodeURIComponent) .map(encodeURIComponent)
.join('=') .join('=')
) )
.join('&') .join('&');
;
} }