Skip to content

Commit

Permalink
Fix linting issues that couldn't be autofixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham42 committed Jun 30, 2017
1 parent a700739 commit 04ad6cf
Show file tree
Hide file tree
Showing 29 changed files with 59 additions and 53 deletions.
3 changes: 1 addition & 2 deletions app/scripts/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import PitchStatisticService from "./services/pitch_statistic_service.js";
import RhythmStatisticService from "./services/rhythm_statistic_service.js";
import AnalyticsService from "./services/analytics_service.js";
import AppFreezer from "./AppFreezer.js";
import { Nav, NavItem, Button, Input } from "react-bootstrap";
import classNames from "classnames";
import { Nav, NavItem } from "react-bootstrap";

const pianoBackgroundJpg = require("file!../images/piano-background.jpg");

Expand Down
1 change: 1 addition & 0 deletions app/scripts/services/analytics_service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global ga */
export default {
sendEvent: function(eventCategory, eventAction, eventValue) {
if (window.location.hostname === "localhost" || typeof ga === "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/services/bar_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default {
const onePerTime = !isMidiAvailable;

const [trebleNotes, bassNotes] = _.unzip(
_.range(0, options.chordsPerBar).map(index => {
_.range(0, options.chordsPerBar).map(() => {
const generatePossibleNotes = clef => {
if (level) {
return {
Expand Down
6 changes: 3 additions & 3 deletions app/scripts/services/key_converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ function initializeKeyMap() {
.concat(_.flatten(_.times(octaveCount, () => octaveNotes)))
.concat([octaveNotes[0]]);

const keyMap = {};
const newKeyMap = {};

for (let index = 0, key; index < claviature.length; index++) {
key = claviature[index];
const offsettedIndex = index + claviatureOffset;
const nr = Math.floor((offsettedIndex + octaveNoteLength) / octaveNoteLength);

keyMap[index + 21] = key + "/" + nr;
newKeyMap[index + 21] = key + "/" + nr;
}

return keyMap;
return newKeyMap;
}

const KeyConverter = {
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/services/level_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const LevelService = {
},
getAllNotesUntilLevelIndex(levelIndex, optClef) {
return _.flatten(
_.range(levelIndex).map(levelIndex => {
const keys = Levels[levelIndex].keys;
_.range(levelIndex).map(index => {
const keys = Levels[index].keys;
if (optClef) {
return keys[optClef];
}
Expand Down
7 changes: 3 additions & 4 deletions app/scripts/services/metronome_service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import _ from "lodash";

const successMp3Url = require("file!../../resources/success.mp3");
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
let audioBuffer;
Expand All @@ -18,7 +16,7 @@ function loadMp3() {
audioBuffer = buffer;
},
function(e) {
"Error with decoding audio data" + e.err;
console.error("Error with decoding audio data" + e.err);
}
);
};
Expand All @@ -38,8 +36,9 @@ export default {
play: function(delay) {
const source = this.createAudioNode();
source.start(audioCtx.currentTime + delay / 1000);
return source;
},
stop: function() {
stop: function(source) {
source.stop(0);
}
};
4 changes: 1 addition & 3 deletions app/scripts/services/rhythm_checker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import _ from "lodash";

export default {
convertDurationsToTimes: function(durations, barDuration) {
const times = [];
Expand Down Expand Up @@ -69,7 +67,7 @@ export default {

if (givenTimes.length > expectedTimes.length) {
beatEvaluations = beatEvaluations.concat(
givenTimes.slice(expectedTimes.length).map(el => ({ superfluous: true, correct: false }))
givenTimes.slice(expectedTimes.length).map(() => ({ superfluous: true, correct: false }))
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/services/rhythm_statistic_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RhythmStatisticService {

off(event, callback) {
if (callback) {
this.callbacks = this.callbacks.filter(el => el != callback);
this.callbacks = this.callbacks.filter(el => el !== callback);
} else {
this.callbacks = [];
}
Expand Down
1 change: 1 addition & 0 deletions app/scripts/services/stat_evolver.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from "lodash";
// Runs evolutions on statistic objects, so that we can update the schema

const evolutions = [
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/views/animated_number.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import React, { Component } from "react";
import { Motion, spring } from "react-motion";

export default class AnimatedNumber extends Component {
static propTypes = {
formatter: React.PropTypes.func,
number: React.PropTypes.number
};
render() {
const formatter = this.props.formatter;
const number = this.props.number;
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/views/beat_visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _ from "lodash";
import RhythmChecker from "../services/rhythm_checker.js";

export default class BeatVisualization extends Component {
propTypes: {
static propTypes = {
settings: React.PropTypes.object.isRequired,
barDuration: React.PropTypes.number.isRequired,
currentRhythm: React.PropTypes.object.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/views/claviature_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import KeyConverter from "../services/key_converter.js";
import classNames from "classnames";

export default class ClaviatureView extends Component {
propTypes: {
static propTypes = {
desiredKeys: React.PropTypes.array,
keySignature: React.PropTypes.string,
successCallback: React.PropTypes.func,
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/views/collapsable_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import classNames from "classnames";
import _ from "lodash";

export default class BeatVisualization extends Component {
propTypes: {
static propTypes = {
children: React.PropTypes.node,
collapsed: React.PropTypes.bool.isRequired,
maxHeight: React.PropTypes.number,
freeze: React.PropTypes.bool,
Expand Down
11 changes: 4 additions & 7 deletions app/scripts/views/game_button.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { Component } from "react";
import classNames from "classnames";
import _ from "lodash";
import { Button, ButtonToolbar } from "react-bootstrap";
import { Button } from "react-bootstrap";

export default class GameButton extends Component {
propTypes: {
static propTypes = {
label: React.PropTypes.string.isRequired,
onClick: React.PropTypes.func.isRequired,
primary: React.PropTypes.bool,
Expand All @@ -21,16 +19,15 @@ export default class GameButton extends Component {
return;
}

if (this.props.shortcutLetter === undefined) {
if (!this.props.shortcutLetter) {
return;
}
const isPrimaryAndEnter = this.props.primary && event.code === "Enter";
const charCode = event.which || event.keyCode;
const isShortcutLetter = String.fromCharCode(charCode) === this.props.shortcutLetter;
if (isPrimaryAndEnter || isShortcutLetter) {
return this.props.onClick();
this.props.onClick();
}
return false;
};

document.addEventListener("keypress", this.keyHandler);
Expand Down
5 changes: 2 additions & 3 deletions app/scripts/views/level_view.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Chartist from "Chartist";
import _ from "lodash";
import React, { Component } from "react";
import { Tooltip, OverlayTrigger } from "react-bootstrap";
import LevelService from "../services/level_service.js";
import PieChart from "../views/pie_chart.js";

export default class LevelView extends Component {
propTypes: {
static propTypes = {
statisticService: React.PropTypes.object.isRequired
};

Expand Down
5 changes: 3 additions & 2 deletions app/scripts/views/metronome_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import MetronomeService from "../services/metronome_service.js";
import CollapsableContainer from "./collapsable_container.js";

export default class MetronomeView extends Component {
propTypes: {
static propTypes = {
onMetronomeEnded: React.PropTypes.func,
settings: React.PropTypes.object.isRequired,
statisticService: React.PropTypes.object.isRequired
};
Expand Down Expand Up @@ -59,7 +60,7 @@ export default class MetronomeView extends Component {
render() {
return (
<CollapsableContainer
collapsed={this.state.currentMetronomeBeat == -1}
collapsed={this.state.currentMetronomeBeat === -1}
className={classNames({
opacityOut: (this.state.currentMetronomeBeat + 1) % 4 === 0
})}
Expand Down
1 change: 0 additions & 1 deletion app/scripts/views/newsletter_form.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component } from "react";
import { Input } from "react-bootstrap";

export default class NewsLetterForm extends Component {
componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/views/pie_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { Component } from "react";
import PureRenderMixin from "react-addons-pure-render-mixin";

export default class LevelView extends Component {
propTypes: {
static propTypes = {
pieParts: React.PropTypes.array.isRequired
};

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/views/pitch_reading_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import CollapsableContainer from "./collapsable_container.js";
const successMp3Url = require("file!../../resources/success.mp3");

export default class PitchReadingView extends Component {
propTypes: {
static propTypes = {
statisticService: React.PropTypes.object.isRequired,
settings: React.PropTypes.object.isRequired,
isActive: React.PropTypes.bool.isRequired
Expand Down
8 changes: 6 additions & 2 deletions app/scripts/views/pitch_settings_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import _ from "lodash";
import AnalyticsService from "../services/analytics_service.js";

export default class PitchSettingsView extends Component {
static propTypes = {
settings: React.PropTypes.object
};

constructor(props, context) {
super(props, context);
}
Expand Down Expand Up @@ -37,8 +41,8 @@ export default class PitchSettingsView extends Component {
};
}

onMidiSelectChange(event) {
AppFreezer.trigger("input:changed", parseInt(this.refs.midiSelect.value));
onMidiSelectChange() {
AppFreezer.trigger("input:changed", parseInt(this.refs.midiSelect.value, 10));
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/views/pitch_statistic_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AnimatedNumber from "./animated_number.js";
import StarAnimation from "./star_animation.js";

export default class PitchStatisticView extends Component {
propTypes: {
static propTypes = {
statisticService: React.PropTypes.object.isRequired,
settings: React.PropTypes.object.isRequired
};
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/views/privacy_policy_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import React, { Component } from "react";
import { Modal, Button } from "react-bootstrap";

export default class PrivacyPolicyModal extends Component {
static propTypes = {
onHide: React.PropTypes.func.isRequired
};

render() {
return (
<Modal {...this.props} bsSize="large" aria-labelledby="contained-modal-title-lg">
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/views/range_setting_component.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class SettingsView extends Component {
label: ""
};

propTypes: {
static propTypes = {
rangeMin: PropTypes.number.isRequired,
rangeMax: PropTypes.number.isRequired,
values: PropTypes.array,
Expand Down
8 changes: 1 addition & 7 deletions app/scripts/views/rhythm_reading_view.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { Component } from "react";
import classNames from "classnames";
import _ from "lodash";

import BarGenerator from "../services/bar_generator.js";
import RhythmChecker from "../services/rhythm_checker.js";
import MetronomeService from "../services/metronome_service.js";
import AnalyticsService from "../services/analytics_service.js";

import StaveRenderer from "./stave_renderer.js";
Expand All @@ -25,7 +23,7 @@ const Phases = {
};

export default class RhythmReadingView extends Component {
propTypes: {
static propTypes = {
settings: React.PropTypes.object.isRequired,
statisticService: React.PropTypes.object.isRequired,
isActive: React.PropTypes.bool.isRequired
Expand Down Expand Up @@ -204,10 +202,6 @@ export default class RhythmReadingView extends Component {
}

render() {
const messageContainerClasses = classNames({
hide: this.state.errorMessage === null
});

const welcomeText = (
<CollapsableContainer collapsed={this.state.phase !== Phases.welcome}>
<h3>Welcome to this rhythm training!</h3>
Expand Down
6 changes: 4 additions & 2 deletions app/scripts/views/rhythm_settings_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import React, { Component } from "react";
import PureRenderMixin from "react-addons-pure-render-mixin";
import RangeSettingComponent from "./range_setting_component";
import SettingLine from "./setting_line";
import KeyConverter from "../services/key_converter";
import AppFreezer from "../AppFreezer.js";
import AnalyticsService from "../services/analytics_service.js";
import _ from "lodash";

export default class PitchSettingsView extends Component {
static propTypes = {
settings: React.PropTypes.object
};

constructor(props, context) {
super(props, context);
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/views/rhythm_statistic_view.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Chartist from "Chartist";
import React, { Component } from "react";
import { Tooltip, OverlayTrigger } from "react-bootstrap";
import _ from "lodash";

import AnimatedNumber from "./animated_number.js";
import StarAnimation from "./star_animation.js";
import PureRenderMixin from "react-addons-pure-render-mixin";

export default class RhythmStatisticView extends Component {
propTypes: {
static propTypes = {
statisticService: React.PropTypes.object.isRequired
};

Expand Down
4 changes: 2 additions & 2 deletions app/scripts/views/setting_line.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { Component, PropTypes } from "react";
import _ from "lodash";

export default class SettingLine extends Component {
static defaultProps = {
label: ""
};

propTypes: {
static propTypes = {
children: PropTypes.node,
label: PropTypes.string,
className: PropTypes.string
};
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/views/star_animation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, { Component } from "react";
import { Motion, spring } from "react-motion";

export default class StarAnimation extends Component {
static propTypes = {
number: React.PropTypes.number
};

constructor() {
super();
this.state = {
Expand Down
3 changes: 1 addition & 2 deletions app/scripts/views/stave_renderer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Vex from "vexflow";
import React, { Component } from "react";
import classNames from "classnames";
import _ from "lodash";
import PureRenderMixin from "react-addons-pure-render-mixin";

Expand All @@ -9,7 +8,7 @@ class StaveRenderer extends Component {
staveCount: 2
};

propTypes: {
static propTypes = {
keys: React.PropTypes.array,
chordIndex: React.PropTypes.number,
keySignature: React.PropTypes.string,
Expand Down

0 comments on commit 04ad6cf

Please sign in to comment.