Automatically apply eslint rules

This commit is contained in:
Felix Hamme 2019-05-08 18:26:54 +02:00 committed by Felix Hamme
parent f93f9a57ce
commit b40c0382a8
24 changed files with 439 additions and 458 deletions

View File

@ -59,7 +59,7 @@ const actiontypes_tournamentinfo = {
'MODIFY_TOURNAMENT_ERROR': 'MODIFY_TOURNAMENT_ERROR',
'REHYDRATE': 'TOURNAMENTINFO_REHYDRATE',
'CLEAR' : 'TOURNAMENTINFO_CLEAR',
'CLEAR': 'TOURNAMENTINFO_CLEAR'
};
const defaultstate_tournamentinfo = {
@ -138,7 +138,7 @@ function checkForAuthenticationHeaders(response) {
const requiredHeaders = [
'access-token', 'client', 'uid', 'expiry'
];
for(var i = 0; i < requiredHeaders.length; i++) {
for (let i = 0; i < requiredHeaders.length; i++) {
if (!response.headers[requiredHeaders[i]]) {
return false;
}
@ -155,12 +155,12 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
'username': action.parameters.username,
'email': action.parameters.email,
'password': action.parameters.password
}).then((resp) => {
}).then(resp => {
__store.dispatch({
type: actiontypes_userinfo.REGISTER_RESULT_SUCCESS
});
storeOptionalToken(resp);
}).catch((error) => {
}).catch(error => {
if (error.response) {
__store.dispatch({
'type': actiontypes_userinfo.REGISTER_RESULT_ERROR,
@ -195,7 +195,7 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
postRequest(action.state, '/users/sign_in', {
email: action.parameters.email,
password: action.parameters.password
}).then((resp) => {
}).then(resp => {
__store.dispatch({
type: actiontypes_userinfo.LOGIN_RESULT_SUCCESS,
parameters: {
@ -204,7 +204,7 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
}
});
storeOptionalToken(resp);
}).catch((error) => {
}).catch(error => {
if (error.response) {
__store.dispatch({
'type': actiontypes_userinfo.LOGIN_RESULT_ERROR,
@ -229,7 +229,7 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
isSignedIn: true,
error: false,
errorMessages: [],
username : action.parameters.username,
username: action.parameters.username
});
case actiontypes_userinfo.LOGIN_RESULT_ERROR:
return Object.assign({}, state, {
@ -252,7 +252,7 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
uid: action.parameters.uid
});
case actiontypes_userinfo.VERIFY_CREDENTIALS:
getRequest(action.state, '/users/validate_token').then((resp) => {
getRequest(action.state, '/users/validate_token').then(resp => {
storeOptionalToken(resp);
}).catch(() => {
__store.dispatch({type: actiontypes_userinfo.CLEAR});
@ -279,7 +279,7 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
const reducer_tournamentinfo = (state = defaultstate_tournamentinfo, action) => {
switch (action.type) {
case actiontypes_tournamentinfo.CREATE_TOURNAMENT:
postRequest(action.state, '/tournaments', action.parameters.tournament).then((resp) => {
postRequest(action.state, '/tournaments', action.parameters.tournament).then(resp => {
storeOptionalToken(resp);
action.parameters.successCallback();
}).catch(() => {
@ -287,7 +287,7 @@ const reducer_tournamentinfo = (state = defaultstate_tournamentinfo, action) =>
});
return Object.assign({}, state, {});
case actiontypes_tournamentinfo.REQUEST_TOURNAMENT:
getRequest(action.state, '/tournaments/' + action.parameters.code).then((resp) => {
getRequest(action.state, '/tournaments/' + action.parameters.code).then(resp => {
__store.dispatch({
type: actiontypes_tournamentinfo.REQUEST_TOURNAMENT_SUCCESS,
parameters: resp.data
@ -312,10 +312,10 @@ const reducer_tournamentinfo = (state = defaultstate_tournamentinfo, action) =>
case actiontypes_tournamentinfo.MODIFY_TOURNAMENT:
patchRequest(action.state, '/teams/' + action.parameters.teamid, {
name: action.parameters.name
}).then((resp) => {
}).then(resp => {
storeOptionalToken(resp);
action.parameters.onSuccess();
}).catch((error) => {
}).catch(error => {
if (error.response) {
storeOptionalToken(error.response);
}
@ -341,14 +341,14 @@ const reducer_tournamentinfo = (state = defaultstate_tournamentinfo, action) =>
const reducer_tournamentlist = (state = defaultstate_tournamentlist, action) => {
switch (action.type) {
case actiontypes_tournamentlist.FETCH:
getRequest(action.state, '/tournaments?type=' + action.parameters.type).then((resp) => {
getRequest(action.state, '/tournaments?type=' + action.parameters.type).then(resp => {
__store.dispatch({
type: actiontypes_tournamentlist.FETCH_SUCCESS,
parameters: resp.data
});
storeOptionalToken(resp);
action.parameters.successCallback(resp.data);
}).catch((error) => {
}).catch(error => {
if (error.response) {
storeOptionalToken(error.response);
}
@ -374,8 +374,8 @@ const default_applicationstate = {
tournamentlist: defaultstate_tournamentlist
};
var __store;
var applicationHydrated = false;
let __store;
let applicationHydrated = false;
export function initializeStore(initialState = default_applicationstate) {
__store = createStore(

View File

@ -13,7 +13,6 @@ import {
import '../../static/css/editablestringlist.css';
export default class EditableStringList extends React.Component {
constructor(props) {
super(props);
this.state = {
@ -32,7 +31,7 @@ export default class EditableStringList extends React.Component {
}
this.state.teams.push(text);
var lastGroup = this.state.groups[this.state.groups.length - 1];
let lastGroup = this.state.groups[this.state.groups.length - 1];
if (lastGroup === undefined || lastGroup.length >= this.state.groupSize) {
this.state.groups[this.state.groups.length] = [];
}
@ -67,15 +66,15 @@ export default class EditableStringList extends React.Component {
removeTeamFromGroup(text) {
this.state.teams = this.state.teams.filter(item => item !== text);
let teamIndex = this.findTeam(text);
const teamIndex = this.findTeam(text);
if (teamIndex === null) {
return false;
}
// Move every first team to the next group
this.state.groups[teamIndex.group].splice(teamIndex.team, 1);
for(var group = teamIndex.group; group < this.state.groups.length - 1; group++) {
let currentGroup = this.state.groups[group];
for (let group = teamIndex.group; group < this.state.groups.length - 1; group++) {
const currentGroup = this.state.groups[group];
currentGroup[currentGroup.length] = this.state.groups[group + 1].splice(0, 1)[0];
}
@ -88,8 +87,8 @@ export default class EditableStringList extends React.Component {
}
findTeam(text) {
for(var group = 0; group < this.state.groups.length; group++) {
for(var team = 0; team < this.state.groups[group].length; team++) {
for (let group = 0; group < this.state.groups.length; group++) {
for (let team = 0; team < this.state.groups[group].length; team++) {
if (this.state.groups[group][team] === text) {
return {
group: group,
@ -102,15 +101,15 @@ export default class EditableStringList extends React.Component {
}
resizeGroups(newSize) {
let oldGroups = this.state.groups;
var rearrangedGroups = [];
const oldGroups = this.state.groups;
const rearrangedGroups = [];
for(var oldGroupIndex = 0; oldGroupIndex < oldGroups.length; oldGroupIndex++) {
for(var oldTeamIndex = 0; oldTeamIndex < oldGroups[oldGroupIndex].length; oldTeamIndex++) {
let index = oldGroupIndex * this.state.groupSize + oldTeamIndex;
for (let oldGroupIndex = 0; oldGroupIndex < oldGroups.length; oldGroupIndex++) {
for (let oldTeamIndex = 0; oldTeamIndex < oldGroups[oldGroupIndex].length; oldTeamIndex++) {
const index = oldGroupIndex * this.state.groupSize + oldTeamIndex;
let newGroupIndex = Math.floor(index / newSize);
let newTeamIndex = index % newSize;
const newGroupIndex = Math.floor(index / newSize);
const newTeamIndex = index % newSize;
if (newTeamIndex === 0) {
rearrangedGroups[newGroupIndex] = [];
@ -168,7 +167,7 @@ export default class EditableStringList extends React.Component {
return (
<div className="bg-light p-3 text-secondary font-italic">
<StringInput submit={this.add} placeholder={this.props.inputPlaceholder} addButtonText={this.props.addButtonText}/>
{this.state.teams.map((text) => <Item text={text} key={text} removeItem={this.remove}/>)}
{this.state.teams.map(text => <Item text={text} key={text} removeItem={this.remove}/>)}
</div>
);
} else {
@ -184,7 +183,6 @@ export default class EditableStringList extends React.Component {
}
class GroupView extends React.Component {
constructor(props) {
super(props);
}
@ -199,9 +197,9 @@ class GroupView extends React.Component {
{group.map((team, teamindex) => (
<div key={team} draggable droppable="droppable"
className="grouped-team-item"
onDragStart={(e) => this.onDragStart(e, groupindex,teamindex)}
onDragOver={(e) => this.onDragOver(e)}
onDrop={(e) => this.onDrop(e, groupindex, teamindex)}>
onDragStart={e => this.onDragStart(e, groupindex, teamindex)}
onDragOver={e => this.onDragOver(e)}
onDrop={e => this.onDrop(e, groupindex, teamindex)}>
<Item text={team} removeItem={this.props.removeTeam}/>
@ -231,8 +229,8 @@ class GroupView extends React.Component {
onDrop(e, group, team) {
e.preventDefault();
let src = JSON.parse(e.dataTransfer.getData('text'));
let dest = {
const src = JSON.parse(e.dataTransfer.getData('text'));
const dest = {
group: group,
team: team
};
@ -256,7 +254,7 @@ class StringInput extends React.Component {
render() {
return (
<InputGroup className="mb-3">
<Input placeholder={this.props.placeholder} type="text" size="255" value={this.state.value} required onChange={this.handleChange} onKeyPress={(e) => {
<Input placeholder={this.props.placeholder} type="text" size="255" value={this.state.value} required onChange={this.handleChange} onKeyPress={e => {
if (e.key === 'Enter') {
this.submit();
return false;

View File

@ -11,7 +11,6 @@ import '../../static/everypage.css';
import '../../static/css/error.css';
export class ErrorPageComponent extends React.Component {
static getInitialProps({statusCode}) {
return {statusCode};
}

View File

@ -46,7 +46,7 @@ class LoginErrorList extends React.Component {
}
}
const mapStateToErrorMessages = (state) => {
const mapStateToErrorMessages = state => {
const {errorMessages, error} = state.userinfo;
return {errorMessages, error};
};
@ -64,7 +64,7 @@ class LoginSuccessRedirectComponent extends React.Component {
}
}
const mapLoginState = (state) => {
const mapLoginState = state => {
const {isSignedIn} = state.userinfo;
return {isSignedIn};
};
@ -72,7 +72,6 @@ const mapLoginState = (state) => {
const LoginSuccessRedirect = connect(mapLoginState)(LoginSuccessRedirectComponent);
class LoginForm extends React.Component {
constructor(props) {
super(props);
@ -84,7 +83,7 @@ class LoginForm extends React.Component {
tryLogin(event) {
event.preventDefault();
login(this.state.email, this.state.password, (username) => notify.show('Willkommen, ' + username + '!', 'success', 2500));
login(this.state.email, this.state.password, username => notify.show('Willkommen, ' + username + '!', 'success', 2500));
}
render() {

View File

@ -17,7 +17,6 @@ import { logout } from '../api';
import {notify} from 'react-notify-toast';
export class TurniereNavigation extends React.Component {
constructor(props) {
super(props);
@ -58,7 +57,6 @@ function Navlink(props) {
}
class SmartNavLinks extends React.Component {
render() {
return (<Nav navbar className="mr-auto">
<Navlink target="/create" text="Turnier erstellen"/>
@ -74,7 +72,6 @@ function Betabadge() {
}
class InvisibleLoginLogoutButtons extends React.Component {
logout() {
logout(() => notify.show('Du bist jetzt abgemeldet.', 'success', 2500));
}
@ -100,7 +97,7 @@ class InvisibleLoginLogoutButtons extends React.Component {
}
}
const mapStateToUserinfo = (state) => {
const mapStateToUserinfo = state => {
const {isSignedIn, username} = state.userinfo;
return {isSignedIn, username};
};

View File

@ -30,12 +30,11 @@ import React from 'react';
* since it would always be taken otherwise (the options' conditions are checked from top to bottom)
*/
export class UserRestrictor extends React.Component {
render() {
const {children} = this.props;
for(var i in children) {
var c = children[i];
for (const i in children) {
const c = children[i];
if (c.props.condition) {
return c;

View File

@ -17,7 +17,7 @@ function getOrCreateStore (initialState) {
return window[__NEXT_REDUX_STORE__];
}
export default (App) => {
export default App => {
return class AppWithRedux extends React.Component {
static async getInitialProps(appContext) {
// Get or Create the store with `undefined` as initialState

View File

@ -8,7 +8,6 @@ import withReduxStore from '../js/redux/reduxStoreBinder';
import {verifyCredentials} from '../js/api.js';
class TurniereApp extends App {
componentDidMount() {
verifyCredentials();
}

View File

@ -26,7 +26,6 @@ import { createTournament } from '../js/api';
import '../static/everypage.css';
class CreatePage extends React.Component {
render() {
const {isSignedIn} = this.props;
@ -181,7 +180,7 @@ class CreateTournamentForm extends React.Component {
}
handleGroupSizeInput(input) {
let newSize = input.target.value;
const newSize = input.target.value;
if (newSize <= this.state.groupAdvance) {
this.setState({
groupSize: newSize,
@ -225,7 +224,6 @@ class CreateTournamentForm extends React.Component {
notify.show('Das Turnier konnte nicht erstellt werden.', 'warning', 5000);
});
}
}
/**
@ -245,7 +243,7 @@ class CreateTournamentForm extends React.Component {
* backend
*/
function createTeamArray(groupphase, groups, teams) {
let result = [];
const result = [];
if (groupphase) {
for (let groupNumber = 0; groupNumber < groups.length; groupNumber++) {

View File

@ -222,7 +222,6 @@ function TournamentFaq() {
}
export default class FaqPage extends React.Component {
render() {
return (
<div>

View File

@ -74,7 +74,6 @@ function ImprintText(){
export default class ImprintPage extends React.Component {
render() {
return (
<div>

View File

@ -170,7 +170,6 @@ function PromotedLinkCreateTournament() {
class Index extends React.Component {
render() {
return (
<div>

View File

@ -10,7 +10,6 @@ import TournamentList from '../js/components/TournamentList';
import {connect} from 'react-redux';
export default class PublicTournamentsPage extends React.Component {
render() {
return (
<div className="main generic-fullpage-bg">
@ -46,7 +45,6 @@ function PublicTournaments(props) {
<a href='/private' className="btn btn-success shadow">zu den privaten Turnieren</a>
</Container>
</div>);
} else {
return (<Container className='py-5'>
<PublicTournamentsCard/>

View File

@ -8,7 +8,6 @@ import { Login } from '../js/components/Login';
import '../static/everypage.css';
export default class LoginPage extends React.Component {
render() {
return (
<div className="main generic-fullpage-bg">

View File

@ -494,7 +494,6 @@ function PrivacyText(){
export default class PrivacyPage extends React.Component {
render() {
return (
<div>

View File

@ -2,7 +2,7 @@ import Head from 'next/head';
import React from 'react';
import {connect} from 'react-redux';
import {Card, CardBody, Container,} from 'reactstrap';
import {Card, CardBody, Container} from 'reactstrap';
import {TurniereNavigation} from '../js/components/Navigation';
import {Footer} from '../js/components/Footer';
@ -13,7 +13,6 @@ import '../static/everypage.css';
import TournamentList from '../js/components/TournamentList';
class PrivateTournamentsPage extends React.Component {
render() {
const {isSignedIn} = this.props;

View File

@ -39,7 +39,6 @@ export default class RegisterPage extends React.Component {
}
class Register extends React.Component {
render() {
return (
<Container className="py-5">
@ -74,7 +73,7 @@ class RegisterErrorList extends React.Component {
}
}
const mapStateToErrorMessages = (state) => {
const mapStateToErrorMessages = state => {
const {errorMessages, error} = state.userinfo;
return {errorMessages, error};
};

View File

@ -25,7 +25,6 @@ import '../static/everypage.css';
import '../static/css/index.css';
class EditTournamentPage extends React.Component {
static async getInitialProps({query}) {
return {query};
}
@ -64,7 +63,9 @@ class EditTournamentPage extends React.Component {
<TurniereNavigation/>
<BigImage text={ tournamentname }/>
<EditTournamentContent ref={(edittournamentcontent) => { this._edittournamentcontent = edittournamentcontent; }}/>
<EditTournamentContent ref={edittournamentcontent => {
this._edittournamentcontent = edittournamentcontent;
}}/>
<Footer/>
</div>
</Option>
@ -103,13 +104,16 @@ export default connect(
)(EditTournamentPage);
class EditTournamentContent extends React.Component {
render() {
return (
<div className='mb-5'>
<ReturnToTournamentButton/>
<EditTournamentPropertiesField ref={(field) => { this._edittournamentpropertiesfield = field; }}/>
<EditTeamField ref={(field) => { this._editteamfield = field; }}/>
<EditTournamentPropertiesField ref={field => {
this._edittournamentpropertiesfield = field;
}}/>
<EditTeamField ref={field => {
this._editteamfield = field;
}}/>
</div>
);
}
@ -129,13 +133,14 @@ function ReturnToTournamentButton() {
}
class EditTournamentPropertiesField extends React.Component {
render() {
return (
<Card className="container">
<CardBody>
<h2>Turnier-Eigenschaften ändern</h2>
<VisibleEditTournamentForm ref={(form) => { this._visibleedittournamentform = form; }}/>
<VisibleEditTournamentForm ref={form => {
this._visibleedittournamentform = form;
}}/>
</CardBody>
</Card>
);
@ -147,7 +152,6 @@ class EditTournamentPropertiesField extends React.Component {
}
class EditTournamentForm extends React.Component {
constructor(props) {
super(props);
@ -222,13 +226,14 @@ const VisibleEditTournamentForm = connect(
)(EditTournamentForm);
class EditTeamField extends React.Component {
render() {
return (
<Card className="container my-4">
<CardBody>
<h2>Team-Namen ändern</h2>
<VisibleEditTeamNamesForm ref={(form) => { this._visibleeditteamnamesform = form; }}/>
<VisibleEditTeamNamesForm ref={form => {
this._visibleeditteamnamesform = form;
}}/>
</CardBody>
</Card>
);
@ -240,7 +245,6 @@ class EditTeamField extends React.Component {
}
class EditTeamNamesForm extends React.Component {
constructor(props) {
super(props);
@ -279,7 +283,7 @@ class EditTeamNamesForm extends React.Component {
}
handleNameInput(index, input) {
let team = this.state.teams.slice();
const team = this.state.teams.slice();
team[index].name = input.target.value;

View File

@ -2,7 +2,6 @@ import Head from 'next/head';
import React from 'react';
class FullscreenTournamentPage extends React.Component {
static async getInitialProps({query}) {
return {query};
}

View File

@ -35,7 +35,6 @@ import '../static/everypage.css';
import '../static/css/tournament.css';
class PrivateTournamentPage extends React.Component {
render() {
const {id, description, isPublic, code, ownerUsername, playoffStages} = this.props.tournament;
const {isSignedIn, username} = this.props;
@ -126,7 +125,7 @@ class Match extends React.Component {
}
render() {
let cardClass, smallMessage, borderClass;
let cardClass; let smallMessage; let borderClass;
// possible states: single_team not_ready not_started in_progress team1_won team2_won undecided
switch (this.props.match.state) {
case 'in_progress':
@ -220,7 +219,7 @@ function MatchModal(props) {
}
function MatchTable(props) {
let team1Class, team2Class;
let team1Class; let team2Class;
// possible states: single_team not_ready not_started in_progress team1_won team2_won undecided
switch (props.match.state) {
case 'in_progress':
@ -327,8 +326,8 @@ class ScoreInput extends React.Component {
function convertTournament(apiTournament) {
let groupStage = null;
let playoffStages = [];
for (let stage of apiTournament.stages) {
const playoffStages = [];
for (const stage of apiTournament.stages) {
if (stage.groups.length > 0) {
// group stage
groupStage = {groups: stage.groups.map(group => convertGroup(group))};
@ -363,7 +362,7 @@ function convertGroup(apiGroup) {
}
function convertMatch(apiMatch) {
let result = {
const result = {
id: apiMatch.id,
state: apiMatch.state
};
@ -389,7 +388,6 @@ function convertMatch(apiMatch) {
}
class Main extends React.Component {
static async getInitialProps({query}) {
return {query};
}
@ -409,7 +407,7 @@ class Main extends React.Component {
.then(response => {
this.setState({status: response.status, tournament: convertTournament(response.data)});
})
.catch((err) => {
.catch(err => {
if (err.response) {
this.setState({status: err.response.status});
} else {

View File

@ -31,7 +31,7 @@ app.prepare()
return handle(req, res);
});
server.listen(dev ? 3000 : 80, (err) => {
server.listen(dev ? 3000 : 80, err => {
if (err) throw err;
});
})