#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"
],
"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,

View File

@ -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', () => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -188,17 +188,17 @@ export default class MultiFactorAuth extends Component<Props, {
return mfa.enable(data);
}
)
.catch((resp) => {
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}));
};
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -95,19 +95,19 @@ const authentication = {
resolve();
})
.then(() => accounts.current({token}))
.then((user) => ({token, refreshToken, user}))
.catch((resp) => {
if (resp.message === 'Token expired') {
return authentication.requestToken(refreshToken)
.then(({token}) =>
accounts.current({token})
.then((user) => ({token, refreshToken, user}))
);
}
.then(() => accounts.current({token}))
.then((user) => ({token, refreshToken, user}))
.catch((resp) => {
if (resp.message === 'Token expired') {
return authentication.requestToken(refreshToken)
.then(({token}) =>
accounts.current({token})
.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,
login
})
.then(() => context.setState(new CompleteState()))
.catch((err = {}) =>
err.errors || logger.warn('Error logging in', err)
);
.then(() => context.setState(new CompleteState()))
.catch((err = {}) =>
err.errors || logger.warn('Error logging in', err)
);
}
goBack(context: AuthContext) {

View File

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

View File

@ -117,8 +117,7 @@ function doFetch(url, options = {}) {
.then(toJSON, rejectWithJSON)
.then(handleResponseSuccess)
.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)
.join('=')
)
.join('&')
;
.join('&');
}