Skip to content

Commit

Permalink
Merge pull request #12 from Graham42/autoformat_code
Browse files Browse the repository at this point in the history
Autoformat code and fix all linting errors
  • Loading branch information
philippotto authored Jun 30, 2017
2 parents 9d33745 + ca3e22a commit 5de3656
Show file tree
Hide file tree
Showing 45 changed files with 1,088 additions and 1,267 deletions.
53 changes: 8 additions & 45 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
},
"parser": "babel-eslint",
"rules": {
"prettier/prettier": [
"error",
{
"printWidth": 120
}
],
// Possible Errors
"comma-dangle": [2, "never"],
"no-cond-assign": 2,
"no-console": 0,
"no-constant-condition": 2,
Expand All @@ -24,12 +29,9 @@
"no-empty-character-class": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 0,
"no-extra-semi": 2,
"no-func-assign": 2,
"no-inner-declarations": 2,
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-regex-spaces": 2,
Expand All @@ -45,7 +47,6 @@
"consistent-return": 2,
"curly": 2,
"default-case": 2,
"dot-notation": 2,
"eqeqeq": 2,
"guard-for-in": 2,
"no-alert": 2,
Expand All @@ -63,10 +64,8 @@
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 0,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-wrappers": 2,
"no-octal": 2,
Expand All @@ -80,7 +79,7 @@
"no-sequences": 2,
"no-unused-expressions": 2,
"no-void": 0,
"no-warning-comments": 2,
"no-warning-comments": 1,
"no-with": 2,
"radix": 2,
"vars-on-top": 0,
Expand All @@ -92,71 +91,35 @@
"no-catch-shadow": 2,
"no-delete-var": 2,
"no-label-var": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-undefined": 2,
"no-unused-vars": 2,
"no-use-before-define": 2,
// Stylistic Issues
"indent": [2, 2, {
"SwitchCase": 1
}],
"brace-style": 2,
"camelcase": 0,
"comma-spacing": 2,
"comma-style": 2,
"consistent-this": 0,
"eol-last": 2,
"func-names": 0,
"func-style": 0,
"key-spacing": [2, {
"beforeColon": false,
"afterColon": true
}],
"max-nested-callbacks": 0,
"new-cap": 0,
"new-parens": 2,
"no-array-constructor": 2,
"no-inline-comments": 0,
"no-lonely-if": 2,
"no-mixed-spaces-and-tabs": 2,
"no-nested-ternary": 2,
"no-new-object": 2,
"semi-spacing": [2, {
"before": false,
"after": true
}],
"no-spaced-func": 2,
"no-ternary": 0,
"no-trailing-spaces": 2,
"no-multiple-empty-lines": 2,
"no-underscore-dangle": 0,
"one-var": 0,
"operator-assignment": [2, "always"],
"padded-blocks": 0,
"quotes": [2, "double"],
"quote-props": [2, "as-needed"],
"semi": [2, "always"],
"sort-vars": [2, {"ignoreCase": true}],
"keyword-spacing": 2,
"space-before-blocks": 2,
"object-curly-spacing": [2, "never"],
"array-bracket-spacing": [2, "never"],
"space-in-parens": 2,
"space-infix-ops": 2,
"space-unary-ops": 2,
"spaced-comment": 2,
"wrap-regex": 0,
// Legacy
"max-depth": 0,
"max-len": [2, 120],
"max-params": 0,
"max-statements": 0,
"no-plusplus": 0
},
"plugins": [
"prettier",
"react"
],
"extends": ["plugin:react/recommended"]
Expand Down
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
language: node_js
node_js:
- 4.4.0
before_script:
- 'npm install -g karma-cli'
- stable
install:
- npm install
script:
- npm run lint
- npm run test
77 changes: 37 additions & 40 deletions app/scripts/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require("html!../index.html");
require("../styles/index.less");
require("font-awesome-webpack");

import React, {Component} from "react";
import React, { Component } from "react";
import PitchReadingView from "./views/pitch_reading_view";
import RhythmReadingView from "./views/rhythm_reading_view";
import PrivacyPolicyModal from "./views/privacy_policy_modal";
Expand All @@ -11,19 +11,16 @@ 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");


export default class App extends Component {

constructor(props, context) {
super(props, context);
this.state = {
activeGame: "pitch",
showPrivacyPolicy: false,
showPrivacyPolicy: false
};
}

Expand All @@ -32,7 +29,7 @@ export default class App extends Component {
activeGame: newGame
});

AnalyticsService.sendEvent('GameSelection', newGame);
AnalyticsService.sendEvent("GameSelection", newGame);
}

render() {
Expand All @@ -49,33 +46,38 @@ export default class App extends Component {
<div className="row center-xs">
<div className="col-xs">
<Nav
bsStyle="pills" activeKey={this.state.activeGame}
onSelect={this.selectGame.bind(this)}
className="inlineBlock">
<NavItem eventKey="pitch" className="modeNavItem">Pitch training</NavItem>
<NavItem eventKey="rhythm" className="modeNavItem">Rhythm training</NavItem>
bsStyle="pills"
activeKey={this.state.activeGame}
onSelect={this.selectGame.bind(this)}
className="inlineBlock"
>
<NavItem eventKey="pitch" className="modeNavItem">
Pitch training
</NavItem>
<NavItem eventKey="rhythm" className="modeNavItem">
Rhythm training
</NavItem>
</Nav>
</div>
</div>
</div>

<div className="gameContainer">
<PitchReadingView
statisticService={PitchStatisticService}
settings={appState.settings.pitchReading}
key="pitch_game"
isActive={this.state.activeGame === "pitch"}
statisticService={PitchStatisticService}
settings={appState.settings.pitchReading}
key="pitch_game"
isActive={this.state.activeGame === "pitch"}
/>
<RhythmReadingView
statisticService={RhythmStatisticService}
settings={appState.settings.rhythmReading}
key="rhythm_game"
isActive={this.state.activeGame !== "pitch"}
statisticService={RhythmStatisticService}
settings={appState.settings.rhythmReading}
key="rhythm_game"
isActive={this.state.activeGame !== "pitch"}
/>
</div>
</div>
<footer>

<div className="subscribe-follow-section row around-md">
<div className="col-md-4 col-xs-12 left">
<div className="row">
Expand All @@ -85,11 +87,8 @@ export default class App extends Component {
</div>
<div className="row">
<div className="col-md-12 col-xs-12">
<p>
Sheet Music Tutor is still under development.
Be first to find out when it gets updates.
</p>
</div>
<p>Sheet Music Tutor is still under development. Be first to find out when it gets updates.</p>
</div>
</div>
<NewsletterForm />
</div>
Expand All @@ -101,42 +100,40 @@ export default class App extends Component {
</div>
<div className="row">
<div className="col-md-12 col-xs-12">
<p>
Follow us on social media to stay up to date on new features or to give us feedback.
</p>
</div>
<p>Follow us on social media to stay up to date on new features or to give us feedback.</p>
</div>
</div>
<div className="row">
<div className="col-md-12 col-xs-12">
<a href="http://facebook.com/SheetMusicTutor" target="_blank" className="btn btn-primary">
<i className="fa fa-facebook"></i>
<i className="fa fa-facebook" />
</a>
<a href="http://twitter.com/SheetMusicTutor" target="_blank" className="btn btn-primary">
<i className="fa fa-twitter"></i>
<i className="fa fa-twitter" />
</a>
<a href="http://github.com/philippotto/piano-trainer" target="_blank" className="btn btn-primary">
<i className="fa fa-github"></i>
<i className="fa fa-github" />
</a>
</div>
</div>
</div>
</div>
Created and maintained by <a href="http://github.com/philippotto/">Philipp Otto</a>
&nbsp;|&nbsp;
<a href="#" onClick={()=>this.setState({ showPrivacyPolicy: true })}>
<a href="#" onClick={() => this.setState({ showPrivacyPolicy: true })}>
Privacy Policy
</a>
&nbsp;|&nbsp;
&copy; {(new Date()).getFullYear()}

<PrivacyPolicyModal show={this.state.showPrivacyPolicy} onHide={() => this.setState({showPrivacyPolicy : false})} />
&nbsp;|&nbsp; &copy; {new Date().getFullYear()}
<PrivacyPolicyModal
show={this.state.showPrivacyPolicy}
onHide={() => this.setState({ showPrivacyPolicy: false })}
/>
</footer>
</div>

);
}

componentDidMount() {
AppFreezer.on('update', () => this.forceUpdate());
AppFreezer.on("update", () => this.forceUpdate());
}
}
10 changes: 5 additions & 5 deletions app/scripts/AppFreezer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ let defaultSettings = {
accuracyGoal: 0.85,
timeGoal: 2000,
amount: 5,
newNotesShare: 0.6,
newNotesShare: 0.6
},
chordSizeRanges: {
treble: [1, 3],
bass: [1, 3],
bass: [1, 3]
},
keySignature: [7, 7],
useAccidentals: false,
midi: {
inputs: Freezer.createLeaf([]),
activeInputIndex: 0,
activeInputIndex: 0
}
},
rhythmReading: {
Expand All @@ -29,7 +29,7 @@ let defaultSettings = {
eighthNotes: true,
sixteenthNotes: false,
dottedNotes: false,
triplets: false,
triplets: false
}
};

Expand All @@ -44,7 +44,7 @@ const AppFreezer = new Freezer({
settings: defaultSettings
});

AppFreezer.on('update', () => {
AppFreezer.on("update", () => {
const settingsJson = JSON.stringify(AppFreezer.get().settings.toJS());
localStorage.setItem("SheetMusicTutor-settings", settingsJson);
});
Expand Down
7 changes: 2 additions & 5 deletions app/scripts/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React from "react";
import {render} from "react-dom";
import { render } from "react-dom";
import App from "./App";

render(
<App />,
document.getElementById("root")
);
render(<App />, document.getElementById("root"));
9 changes: 5 additions & 4 deletions app/scripts/services/analytics_service.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/* global ga */
export default {
sendEvent: function(eventCategory, eventAction, eventValue) {
if (window.location.hostname === "localhost" || typeof ga === "undefined") {
return;
}

ga('send', {
hitType: 'event',
ga("send", {
hitType: "event",
eventCategory,
eventAction,
eventValue,
eventValue
});
}
}
};
Loading

0 comments on commit 5de3656

Please sign in to comment.