diff --git a/app/scripts/App.js b/app/scripts/App.js index 79bbd2c..a3fdd68 100644 --- a/app/scripts/App.js +++ b/app/scripts/App.js @@ -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"); diff --git a/app/scripts/services/analytics_service.js b/app/scripts/services/analytics_service.js index 981695b..f4a3ca7 100644 --- a/app/scripts/services/analytics_service.js +++ b/app/scripts/services/analytics_service.js @@ -1,3 +1,4 @@ +/* global ga */ export default { sendEvent: function(eventCategory, eventAction, eventValue) { if (window.location.hostname === "localhost" || typeof ga === "undefined") { diff --git a/app/scripts/services/bar_generator.js b/app/scripts/services/bar_generator.js index 5146d19..1a2a17a 100644 --- a/app/scripts/services/bar_generator.js +++ b/app/scripts/services/bar_generator.js @@ -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 { diff --git a/app/scripts/services/key_converter.js b/app/scripts/services/key_converter.js index 481cebc..8d3c5ea 100644 --- a/app/scripts/services/key_converter.js +++ b/app/scripts/services/key_converter.js @@ -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 = { diff --git a/app/scripts/services/level_service.js b/app/scripts/services/level_service.js index 44016ec..169db1e 100644 --- a/app/scripts/services/level_service.js +++ b/app/scripts/services/level_service.js @@ -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]; } diff --git a/app/scripts/services/metronome_service.js b/app/scripts/services/metronome_service.js index 12fa8d2..3b45888 100644 --- a/app/scripts/services/metronome_service.js +++ b/app/scripts/services/metronome_service.js @@ -1,5 +1,3 @@ -import _ from "lodash"; - const successMp3Url = require("file!../../resources/success.mp3"); const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); let audioBuffer; @@ -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); } ); }; @@ -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); } }; diff --git a/app/scripts/services/rhythm_checker.js b/app/scripts/services/rhythm_checker.js index 7120c96..0577cb2 100644 --- a/app/scripts/services/rhythm_checker.js +++ b/app/scripts/services/rhythm_checker.js @@ -1,5 +1,3 @@ -import _ from "lodash"; - export default { convertDurationsToTimes: function(durations, barDuration) { const times = []; @@ -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 })) ); } diff --git a/app/scripts/services/rhythm_statistic_service.js b/app/scripts/services/rhythm_statistic_service.js index e2d956e..bdf829b 100644 --- a/app/scripts/services/rhythm_statistic_service.js +++ b/app/scripts/services/rhythm_statistic_service.js @@ -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 = []; } diff --git a/app/scripts/services/stat_evolver.js b/app/scripts/services/stat_evolver.js index 8212578..282886a 100644 --- a/app/scripts/services/stat_evolver.js +++ b/app/scripts/services/stat_evolver.js @@ -1,3 +1,4 @@ +import _ from "lodash"; // Runs evolutions on statistic objects, so that we can update the schema const evolutions = [ diff --git a/app/scripts/views/animated_number.js b/app/scripts/views/animated_number.js index d4dd867..294ebc8 100644 --- a/app/scripts/views/animated_number.js +++ b/app/scripts/views/animated_number.js @@ -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; diff --git a/app/scripts/views/beat_visualization.js b/app/scripts/views/beat_visualization.js index 55bc6ec..ce31ea2 100644 --- a/app/scripts/views/beat_visualization.js +++ b/app/scripts/views/beat_visualization.js @@ -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, diff --git a/app/scripts/views/claviature_view.js b/app/scripts/views/claviature_view.js index e042745..f101a46 100644 --- a/app/scripts/views/claviature_view.js +++ b/app/scripts/views/claviature_view.js @@ -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, diff --git a/app/scripts/views/collapsable_container.js b/app/scripts/views/collapsable_container.js index aa78743..5b022e1 100644 --- a/app/scripts/views/collapsable_container.js +++ b/app/scripts/views/collapsable_container.js @@ -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, diff --git a/app/scripts/views/game_button.js b/app/scripts/views/game_button.js index 611bc92..b41bb44 100644 --- a/app/scripts/views/game_button.js +++ b/app/scripts/views/game_button.js @@ -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, @@ -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); diff --git a/app/scripts/views/level_view.js b/app/scripts/views/level_view.js index de9545d..b13eed3 100644 --- a/app/scripts/views/level_view.js +++ b/app/scripts/views/level_view.js @@ -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 }; diff --git a/app/scripts/views/metronome_view.js b/app/scripts/views/metronome_view.js index 05bc8f3..3adbf8b 100644 --- a/app/scripts/views/metronome_view.js +++ b/app/scripts/views/metronome_view.js @@ -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 }; @@ -59,7 +60,7 @@ export default class MetronomeView extends Component { render() { return ( diff --git a/app/scripts/views/range_setting_component.js b/app/scripts/views/range_setting_component.js index b1ae609..48794d7 100644 --- a/app/scripts/views/range_setting_component.js +++ b/app/scripts/views/range_setting_component.js @@ -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, diff --git a/app/scripts/views/rhythm_reading_view.js b/app/scripts/views/rhythm_reading_view.js index 376cf55..536ba5b 100644 --- a/app/scripts/views/rhythm_reading_view.js +++ b/app/scripts/views/rhythm_reading_view.js @@ -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"; @@ -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 @@ -204,10 +202,6 @@ export default class RhythmReadingView extends Component { } render() { - const messageContainerClasses = classNames({ - hide: this.state.errorMessage === null - }); - const welcomeText = (

Welcome to this rhythm training!

diff --git a/app/scripts/views/rhythm_settings_view.js b/app/scripts/views/rhythm_settings_view.js index 94c1a48..dfcac1a 100644 --- a/app/scripts/views/rhythm_settings_view.js +++ b/app/scripts/views/rhythm_settings_view.js @@ -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); diff --git a/app/scripts/views/rhythm_statistic_view.js b/app/scripts/views/rhythm_statistic_view.js index 896353e..e6a71e9 100644 --- a/app/scripts/views/rhythm_statistic_view.js +++ b/app/scripts/views/rhythm_statistic_view.js @@ -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 }; diff --git a/app/scripts/views/setting_line.js b/app/scripts/views/setting_line.js index 5de21a4..16fc93c 100644 --- a/app/scripts/views/setting_line.js +++ b/app/scripts/views/setting_line.js @@ -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 }; diff --git a/app/scripts/views/star_animation.js b/app/scripts/views/star_animation.js index 7cc8ca2..2f678f4 100644 --- a/app/scripts/views/star_animation.js +++ b/app/scripts/views/star_animation.js @@ -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 = { diff --git a/app/scripts/views/stave_renderer.js b/app/scripts/views/stave_renderer.js index 35db0d0..36a2fc5 100644 --- a/app/scripts/views/stave_renderer.js +++ b/app/scripts/views/stave_renderer.js @@ -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"; @@ -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,