Skip to content

Commit

Permalink
Fixing errors discovered by new version of eslint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Krulis committed Jul 25, 2019
1 parent 7554f30 commit 95f483e
Show file tree
Hide file tree
Showing 48 changed files with 115 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ AssignmentStatusIcon.propTypes = {
id: PropTypes.string.isRequired,
status: PropTypes.string,
accepted: PropTypes.bool,
isBestSolution: PropTypes.bool,
};

export default AssignmentStatusIcon;
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,18 @@ const AssignmentTableRow = ({

AssignmentTableRow.propTypes = {
item: PropTypes.shape({
id: PropTypes.string,
id: PropTypes.string.isRequired,
groupId: PropTypes.string.isRequired,
localizedTexts: PropTypes.array,
allowSecondDeadline: PropTypes.bool,
firstDeadline: PropTypes.number,
maxPointsBeforeFirstDeadline: PropTypes.number,
secondDeadline: PropTypes.number,
maxPointsBeforeSecondDeadline: PropTypes.number,
isBonus: PropTypes.bool,
isPublic: PropTypes.bool,
visibleFrom: PropTypes.number,
accepted: PropTypes.bool,
}).isRequired,
runtimeEnvironments: PropTypes.array,
status: PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions src/components/Exercises/ExerciseGroups/ExerciseGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ExerciseGroups extends Component {
state = { dialogOpen: false };

openDialog = () => this.setState({ dialogOpen: true });

closeDialog = () => this.setState({ dialogOpen: false });

attachButton = groupId => {
Expand Down
7 changes: 5 additions & 2 deletions src/components/Groups/GroupDetail/GroupInfoTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const GroupInfoTable = ({
localizedTexts,
primaryAdminsIds,
public: isPublic = false,
privateData: { threshold, publicStats, parentGroupId, bindings, ...privateGroup },
privateData: { threshold, publicStats, bindings },
},
groups,
supervisors,
Expand Down Expand Up @@ -148,14 +148,17 @@ const GroupInfoTable = ({
GroupInfoTable.propTypes = {
group: PropTypes.shape({
id: PropTypes.string.isRequired,
externalId: PropTypes.string,
parentGroupId: PropTypes.string,
threshold: PropTypes.number,
primaryAdminsIds: PropTypes.array.isRequired,
public: PropTypes.bool.isRequired,
organizational: PropTypes.bool.isRequired,
localizedTexts: PropTypes.array,
privateData: PropTypes.shape({
threshold: PropTypes.number,
publicStats: PropTypes.bool.isRequired,
supervisors: PropTypes.array.isRequired,
bindings: PropTypes.object,
}),
}),
groups: PropTypes.object.isRequired,
Expand Down
6 changes: 3 additions & 3 deletions src/components/Groups/ResultsTable/ResultsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ const getCSVValues = (assignments, shadowAssignments, data, locale) => {
const QUOTE = '"';
const SEPARATOR = ';';
const NEWLINE = '\n';
let result = [];
const result = [];

const enquote = string => `${QUOTE}${string}${QUOTE}`;

let header = [enquote('userName'), enquote('userEmail'), enquote('totalPoints')];
const header = [enquote('userName'), enquote('userEmail'), enquote('totalPoints')];
assignments.forEach(assignment => {
header.push(enquote(escapeString(getLocalizedName(assignment, locale))));
});
Expand All @@ -67,7 +67,7 @@ const getCSVValues = (assignments, shadowAssignments, data, locale) => {
result.push(header);

data.forEach(item => {
let row = [
const row = [
enquote(`${escapeString(item.user.fullName)}`),
item.user.privateData ? enquote(`${escapeString(item.user.privateData.email)}`) : '',
item.total.gained,
Expand Down
1 change: 1 addition & 0 deletions src/components/Instances/LicencesTable/LicencesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const LicencesTable = ({ instance, licences }) => (
LicencesTable.propTypes = {
instance: PropTypes.shape({
hasValidLicence: PropTypes.bool.isRequired,
name: PropTypes.string,
}).isRequired,
licences: PropTypes.array.isRequired,
};
Expand Down
16 changes: 7 additions & 9 deletions src/components/Pipelines/BoxForm/BoxForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,11 @@ const validate = ({ name, type, portsIn = {}, portsOut = {} }, { boxTypes, exist
const errors = {};

if (!name || name.length === 0) {
errors['name'] = (
<FormattedMessage id="app.pipelineEditor.BoxForm.emptyName" defaultMessage="Name cannot be empty." />
);
errors.name = <FormattedMessage id="app.pipelineEditor.BoxForm.emptyName" defaultMessage="Name cannot be empty." />;
}

if (!type) {
errors['type'] = (
errors.type = (
<FormattedMessage id="app.pipelineEditor.BoxForm.missingType" defaultMessage="You must select some type." />
);
} else {
Expand All @@ -184,7 +182,7 @@ const validate = ({ name, type, portsIn = {}, portsOut = {} }, { boxTypes, exist
existingBoxes.filter(box => box.name !== name && box.type !== type)
);

for (let portName of portsInNames) {
for (const portName of portsInNames) {
if (portsIn[portName] && portsIn[portName].length > 0) {
const intendedVariableName = portsIn[portName].value;
const portType = boxType.portsIn[portName].type;
Expand All @@ -210,14 +208,14 @@ const validate = ({ name, type, portsIn = {}, portsOut = {} }, { boxTypes, exist

// check that the variable in a certain port has the correct port
if (Object.keys(portsInErrors).length > 0) {
errors['portsIn'] = portsInErrors;
errors.portsIn = portsInErrors;
}

const portsOutErrors = {};

// check that one box does not have the same var as input and output
for (let portIn of portsInNames) {
for (let portOut of portsOutNames) {
for (const portIn of portsInNames) {
for (const portOut of portsOutNames) {
if (portsIn[portIn] && portsOut[portOut] && portsIn[portIn].value === portsOut[portOut].value) {
portsOutErrors[portOut] = {
value: (
Expand All @@ -232,7 +230,7 @@ const validate = ({ name, type, portsIn = {}, portsOut = {} }, { boxTypes, exist
}

if (Object.keys(portsOutErrors).length > 0) {
errors['portsOut'] = portsOutErrors;
errors.portsOut = portsOutErrors;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PipelineVisualEditor extends Component {
};

onClick = target => {
let boxId = this.findTopmostCluster(target);
const boxId = this.findTopmostCluster(target);
const nodeToEdit = boxId ? this.state.graph.nodes.find(node => node.name === boxId) : null;

this.setState({ nodeToEdit });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const getLastSubmissionId = evaluations => {

class ReferenceSolutionDetail extends Component {
state = { openFileId: null, activeSubmissionId: null };

openFile = id => this.setState({ openFileId: id });

hideFile = () => this.setState({ openFileId: null });

render() {
Expand Down Expand Up @@ -171,6 +173,8 @@ class ReferenceSolutionDetail extends Component {
ReferenceSolutionDetail.propTypes = {
solution: PropTypes.shape({
id: PropTypes.string.isRequired,
description: PropTypes.string,
runtimeEnvironmentId: PropTypes.string,
note: PropTypes.string,
lastSubmission: PropTypes.shape({ id: PropTypes.string.isRequired }),
solution: PropTypes.shape({
Expand Down
3 changes: 3 additions & 0 deletions src/components/Solutions/SolutionDetail/SolutionDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import { safeGet, EMPTY_OBJ } from '../../../helpers/common';

class SolutionDetail extends Component {
state = { openFileId: null, activeSubmissionId: null };

openFile = id => this.setState({ openFileId: id });

hideFile = () => this.setState({ openFileId: null });

render() {
Expand Down Expand Up @@ -220,6 +222,7 @@ SolutionDetail.propTypes = {
bonusPoints: PropTypes.number.isRequired,
overriddenPoints: PropTypes.number,
actualPoints: PropTypes.number,
accepted: PropTypes.bool,
runtimeEnvironmentId: PropTypes.string,
permissionHints: PropTypes.object,
}).isRequired,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Users/StudentsListItem/StudentsListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ StudentsListItem.propTypes = {
total: PropTypes.number.isRequired,
gained: PropTypes.number.isRequired,
}),
hasLimit: PropTypes.bool,
passesLimit: PropTypes.bool,
}),
renderActions: PropTypes.func,
};
Expand Down
2 changes: 2 additions & 0 deletions src/components/Users/UsersStats/UsersStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ UsersStats.propTypes = {
total: PropTypes.number.isRequired,
gained: PropTypes.number.isRequired,
}),
hasLimit: PropTypes.bool,
passesLimit: PropTypes.bool,
}).isRequired,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const ResendEmailVerification = ({ resend, state, intl: { formatMessage }, ...pr

ResendEmailVerification.propTypes = {
resend: PropTypes.func.isRequired,
state: PropTypes.string,
intl: intlShape,
};

Expand Down
1 change: 1 addition & 0 deletions src/components/forms/Fields/DatetimeField.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ DatetimeField.propTypes = {
input: PropTypes.shape({
name: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]),
onChange: PropTypes.func,
}).isRequired,
meta: PropTypes.shape({
active: PropTypes.bool,
Expand Down
1 change: 1 addition & 0 deletions src/components/forms/Fields/MarkdownTextAreaField.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ MarkdownTextAreaField.propTypes = {
name: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
}).isRequired,
disabled: PropTypes.bool,
};

export default MarkdownTextAreaField;
2 changes: 2 additions & 0 deletions src/components/forms/Fields/PipelineField.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const PipelineField = ({ input, meta: { touched, error }, label, ...props }) =>
PipelineField.propTypes = {
input: PropTypes.shape({
name: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]).isRequired,
onChange: PropTypes.func.isRequired,
}).isRequired,
label: PropTypes.oneOfType([
PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions src/components/forms/Fields/PipelineVariablesField.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const PipelineVariablesField = ({ input, label, variables, supplementaryFiles, i
PipelineVariablesField.propTypes = {
input: PropTypes.shape({
name: PropTypes.string.isRequired,
value: PropTypes.object,
}).isRequired,
label: PropTypes.oneOfType([
PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions src/components/forms/Fields/PortField.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const PortField = ({

PortField.propTypes = {
input: PropTypes.shape({
name: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
}).isRequired,
meta: PropTypes.shape({
Expand Down
1 change: 1 addition & 0 deletions src/components/forms/Fields/RadioField.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RadioField.propTypes = {
input: PropTypes.shape({
name: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
onChange: PropTypes.func,
}).isRequired,
meta: PropTypes.shape({
dirty: PropTypes.bool,
Expand Down
3 changes: 2 additions & 1 deletion src/components/forms/Fields/SourceCodeField.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UserSettingsContext } from '../../../helpers/contexts';

// load the ACE editor only when rendering in the browser
import { loadAceEditor, getAceModeFromExtension } from '../../helpers/AceEditorLoader';
let AceEditor = loadAceEditor();
const AceEditor = loadAceEditor();

const SourceCodeField = ({
input,
Expand Down Expand Up @@ -61,6 +61,7 @@ const SourceCodeField = ({
SourceCodeField.propTypes = {
input: PropTypes.shape({
name: PropTypes.string.isRequired,
onBlur: PropTypes.func.isRequired,
}).isRequired,
mode: PropTypes.string.isRequired,
children: PropTypes.any,
Expand Down
1 change: 1 addition & 0 deletions src/components/forms/Fields/TabbedArrayField.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { identity } from '../../../helpers/common';

class TabbedArrayField extends Component {
state = { activeTab: 0 };

changeTab = n => this.setState({ activeTab: n });

prepareFieldsIndices = () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/forms/Fields/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const TextField = ({
TextField.propTypes = {
type: PropTypes.string,
input: PropTypes.shape({
name: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.array, PropTypes.string, PropTypes.number]).isRequired,
}).isRequired,
meta: PropTypes.shape({
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/ForkExerciseForm/ForkExerciseForm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';
import { injectIntl, FormattedMessage, defineMessages, intlShape } from 'react-intl';
import { Alert, Form } from 'react-bootstrap';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
Expand Down Expand Up @@ -153,7 +153,7 @@ ForkExerciseForm.propTypes = {
links: PropTypes.object,
groups: ImmutablePropTypes.map,
groupsAccessor: PropTypes.func.isRequired,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired,
intl: intlShape,
};

const mapStateToProps = (state, { exerciseId, forkId }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const shallowResourcesEqual = (oldResources, newResources) => {
*/
class ResourceRenderer extends Component {
oldResources = null;

oldData = null;

// Perform rendering of the childs whilst keeping resource data cached ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';

import { UserSettingsContext } from '../../../helpers/contexts';
import { loadAceEditor, getAceModeFromExtension } from '../../helpers/AceEditorLoader';
let AceEditor = loadAceEditor();
const AceEditor = loadAceEditor();

const SourceCodeViewer = ({ name, content = '', lineNumbers = true }) => (
<UserSettingsContext.Consumer>
Expand Down
8 changes: 8 additions & 0 deletions src/components/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ SuccessOrFailureIcon.propTypes = {
success: PropTypes.bool,
};

TypedMessageIcon.propTypes = {
type: PropTypes.string.isRequired,
};

VisibleIcon.propTypes = {
visible: PropTypes.bool,
};

export { default as ExercisePrefixIcons } from './ExercisePrefixIcons';
export { default as MaybeBonusAssignmentIcon } from './MaybeBonusAssignmentIcon';
export { default as MaybeVisibleAssignmentIcon } from './MaybeVisibleAssignmentIcon';
Expand Down
1 change: 1 addition & 0 deletions src/components/widgets/Box/Box.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Box extends Component {
};

showDetails = () => this.setState({ isOpen: true });

hideDetails = () => this.setState({ isOpen: false });

renderBody() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/widgets/Breadcrumbs/Breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const Breadcrumbs = ({ items = [] }) => (
{items
.filter(({ hidden = false }) => hidden !== true)
.map((item, i) => {
const Component = item.hasOwnProperty('resource') ? ResourceDependentBreadcrumbItem : BreadcrumbItem;
const Component = Object.prototype.hasOwnProperty.call(item, 'resource')
? ResourceDependentBreadcrumbItem
: BreadcrumbItem;
return <Component {...item} key={i} isActive={i === items.length - 1} />;
})}
</Breadcrumb>
Expand Down
2 changes: 2 additions & 0 deletions src/components/widgets/Comments/Comment/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Comment.propTypes = {
user: PropTypes.shape({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
firstName: PropTypes.string,
avatarLetter: PropTypes.string,
avatarUrl: PropTypes.string,
}).isRequired,
postedAt: PropTypes.number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ class SortableTableColumnDescriptor {
}

getHeaderStyle = () => this.headerStyle || this.style;

getHeaderClassName = () => this.headerClassName || this.className;

getHeaderSuffixStyle = () => this.headerSuffixStyle || this.headerStyle || this.style;

getHeaderSuffixClassName = () => this.headerSuffixClassName || this.headerClassName || this.className;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import randomMessages, { extraMessages } from './randomMessages';

class EvaluationProgressContainer extends Component {
state = { realTimeProcessing: true, monitor: null };

socket = null;

componentDidMount = () => this.init(this.props);
Expand Down
Loading

0 comments on commit 95f483e

Please sign in to comment.