Skip to content

Commit

Permalink
apply linting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
philippotto committed Mar 2, 2016
1 parent 2e33f74 commit 641c75b
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 59 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
@@ -1,3 +1,4 @@
dist/*
node_modules/*
**/node_modules/*
**/node_modules/*
app/scripts/vexflow-min.js
4 changes: 2 additions & 2 deletions .eslintrc
Expand Up @@ -29,7 +29,7 @@
"react/react-in-jsx-scope": 2,
"react/self-closing-comp": 2,
"react/wrap-multilines": 2,
"quotes": [2, "single"],
"quotes": [2, "double"],
"space-before-function-paren": [2, {
"anonymous": "always",
"named": "never"
Expand All @@ -39,4 +39,4 @@
"plugins": [
"react"
]
}
}
6 changes: 3 additions & 3 deletions app/scripts/App.js
@@ -1,8 +1,8 @@
require("../styles/index.less");

import React, {Component} from 'react';
import MainView from './views/main_view';
import StatisticService from './services/statistic_service.js';
import React, {Component} from "react";
import MainView from "./views/main_view";
import StatisticService from "./services/statistic_service.js";


export default class App extends Component {
Expand Down
8 changes: 4 additions & 4 deletions app/scripts/index.js
@@ -1,8 +1,8 @@
import React from 'react';
import {render} from 'react-dom';
import App from './App';
import React from "react";
import {render} from "react-dom";
import App from "./App";

render(
<App />,
document.getElementById('root')
document.getElementById("root")
);
8 changes: 4 additions & 4 deletions app/scripts/services/key_converter.js
@@ -1,4 +1,4 @@
import _ from 'lodash';
import _ from "lodash";

export default class KeyConverter {

Expand All @@ -11,7 +11,7 @@ export default class KeyConverter {

getNumberForCanonicalKeyString(keyString) {

return parseInt(_.findKey(this.keyMap, function(key) { return key === keyString; }), 10);
return parseInt(_.findKey(this.keyMap, function (key) { return key === keyString; }), 10);
}


Expand Down Expand Up @@ -47,7 +47,7 @@ export default class KeyConverter {

getCanonicalForm(key) {

const stripKey = function(keyToStrip, modifier) {
const stripKey = function (keyToStrip, modifier) {

const regexp = new RegExp(modifier, "g");
// ignore the first character because of b notes
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class KeyConverter {
"c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "b"
];

var claviature = baseScale.slice(-3).concat(_.flatten(_.times(7, function() { return baseScale; }))).concat([baseScale[0]]);
var claviature = baseScale.slice(-3).concat(_.flatten(_.times(7, function () { return baseScale; }))).concat([baseScale[0]]);


var keyMap = {};
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/services/midi_service.js
@@ -1,4 +1,4 @@
import KeyConverter from '../services/key_converter.js';
import KeyConverter from "../services/key_converter.js";

export default class MidiService {

Expand Down Expand Up @@ -38,7 +38,7 @@ export default class MidiService {

const debugMode = true;
if (debugMode) {
document.addEventListener('keyup', (event) => {
document.addEventListener("keyup", (event) => {
const trueKeyCode = 84;
const falseKeyCode = 70;
if (event.keyCode === trueKeyCode) {
Expand Down
6 changes: 3 additions & 3 deletions app/scripts/services/statistic_service.js
@@ -1,4 +1,4 @@
import _ from 'lodash';
import _ from "lodash";

export default class StatisticService {

Expand Down Expand Up @@ -42,7 +42,7 @@ export default class StatisticService {
}

getSuccessCount() {
return _(this.stats).filter(function(el) { return el.success; }).value().length;
return _(this.stats).filter(function (el) { return el.success; }).value().length;
}


Expand Down Expand Up @@ -97,7 +97,7 @@ export default class StatisticService {


getLastDays(n = 10) {
return _(this.stats).filter(function(el) { return el.success; }).map(function(el) {
return _(this.stats).filter(function (el) { return el.success; }).map(function (el) {
el.formattedDate = [
el.date.getUTCFullYear(),
("0" + el.date.getMonth()).slice(-2),
Expand Down
14 changes: 7 additions & 7 deletions app/scripts/spec/key_converter_spec.js
@@ -1,11 +1,11 @@
import KeyConverter from '../services/key_converter.js';
import _ from 'lodash';
import KeyConverter from "../services/key_converter.js";
import _ from "lodash";

describe("KeyConverter", function() {
describe("KeyConverter", function () {

var keyConverter = new KeyConverter();

it("resolves a simple note", function() {
it("resolves a simple note", function () {

var numberA0 = keyConverter.getNumberForKeyString("a/0");
expect(numberA0).toBe(21);
Expand All @@ -16,7 +16,7 @@ describe("KeyConverter", function() {

);

it("gets key strings for a number", function() {
it("gets key strings for a number", function () {

var aSharp0 = keyConverter.getKeyStringForNumber("22");
expect(aSharp0).toBe("a#/0");
Expand All @@ -27,7 +27,7 @@ describe("KeyConverter", function() {

);

it("gets scales for an arbitrary base", function() {
it("gets scales for an arbitrary base", function () {

var cScale = keyConverter.getScaleForBase("c/4");
expect(cScale).toEqual(["c/4", "d/4", "e/4", "f/4", "g/4", "a/4", "b/4"]);
Expand All @@ -42,7 +42,7 @@ describe("KeyConverter", function() {

);

return it("gets the canonical form of a key", function() {
return it("gets the canonical form of a key", function () {

var c4 = keyConverter.getCanonicalForm("c/4");
expect(c4).toBe("c/4");
Expand Down
30 changes: 15 additions & 15 deletions app/scripts/spec/midi_service_spec.js
@@ -1,16 +1,16 @@
import KeyConverter from '../services/key_converter.js';
import _ from 'lodash';
import KeyConverter from "../services/key_converter.js";
import _ from "lodash";

describe("MidiService", function() {
describe("MidiService", function () {

var onKeyStatus = MidiService.onKeyStatus;
var offKeyStatus = MidiService.offKeyStatus;

it("notifies about a simple desired key state (midi implementation 1)", function() {
it("notifies about a simple desired key state (midi implementation 1)", function () {

var [successCounter, failedCounter] = [0, 0];
var successCallback = function() { return successCounter++; };
var failureCallback = function() { return failedCounter++; };
var successCallback = function () { return successCounter++; };
var failureCallback = function () { return failedCounter++; };

var midiService = new MidiService(successCallback, failureCallback, null, null, true);
midiService.setDesiredKeys(["a/0"]);
Expand All @@ -31,11 +31,11 @@ describe("MidiService", function() {

);

it("notifies about a simple desired key state (midi implementation 2)", function() {
it("notifies about a simple desired key state (midi implementation 2)", function () {

var [successCounter, failedCounter] = [0, 0];
var successCallback = function() { return successCounter++; };
var failureCallback = function() { return failedCounter++; };
var successCallback = function () { return successCounter++; };
var failureCallback = function () { return failedCounter++; };

var midiService = new MidiService(successCallback, failureCallback, null, null, true);
midiService.setDesiredKeys(["a/0"]);
Expand All @@ -56,11 +56,11 @@ describe("MidiService", function() {

);

it("notifies about a complex desired key state", function() {
it("notifies about a complex desired key state", function () {

var [successCounter, failedCounter] = [0, 0];
var successCallback = function() { return successCounter++; };
var failureCallback = function() { return failedCounter++; };
var successCallback = function () { return successCounter++; };
var failureCallback = function () { return failedCounter++; };

var midiService = new MidiService(successCallback, failureCallback, null, null, true);
midiService.setDesiredKeys(["a/0", "c/8"]);
Expand All @@ -82,11 +82,11 @@ describe("MidiService", function() {
}
);

return it("notifies once about a wrong desired key state", function() {
return it("notifies once about a wrong desired key state", function () {

var [successCounter, failedCounter] = [0, 0];
var successCallback = function() { return successCounter++; };
var failureCallback = function() { return failedCounter++; };
var successCallback = function () { return successCounter++; };
var failureCallback = function () { return failedCounter++; };

var midiService = new MidiService(successCallback, failureCallback, null, null, true);
midiService.setDesiredKeys(["a/0", "c/8"]);
Expand Down
6 changes: 3 additions & 3 deletions app/scripts/test_config.js
Expand Up @@ -3,7 +3,7 @@ for (var file in window.__karma__.files) {
if (/spec\.js$/.test(file)) {
// remove absolute path elements so that all dependencies
// will be fetched with file extension
file = file.replace(/^\/base\/|\.js$/g,'');
file = file.replace(/^\/base\/|\.js$/g,"");
tests.push(file);
}
}
Expand All @@ -13,9 +13,9 @@ requirejs.config({
// baseUrl: '/base',

// ask Require.js to load the application Require.js configuration
deps: ['base/scripts/require_config'],
deps: ["base/scripts/require_config"],

callback: function() {
callback: function () {
// overwrite the baseUrl (was set by require_config.js)
require.config({baseUrl : "/base"});

Expand Down
18 changes: 9 additions & 9 deletions app/scripts/views/main_view.js
@@ -1,11 +1,11 @@
import Vex from 'vexflow';
import React, {Component} from 'react';
import StatisticsView from '../views/statistics_view.js';
import MidiService from '../services/midi_service.js';
import KeyConverter from '../services/key_converter.js';
import classNames from 'classnames';
import Vex from "vexflow";
import React, {Component} from "react";
import StatisticsView from "../views/statistics_view.js";
import MidiService from "../services/midi_service.js";
import KeyConverter from "../services/key_converter.js";
import classNames from "classnames";

const successMp3Url = require('file!../../resources/success.mp3');
const successMp3Url = require("file!../../resources/success.mp3");

export default class MainView extends Component {

Expand Down Expand Up @@ -136,7 +136,7 @@ export default class MainView extends Component {


playSuccessSound() {
return document.getElementById('success-player').play();
return document.getElementById("success-player").play();
}


Expand Down Expand Up @@ -233,7 +233,7 @@ export default class MainView extends Component {
var generatedChords = _.range(0, options.notesPerBar).map( () => {
var randomLevel = _.sample(options.levels[clef]);

var generateNote = function(baseNotes) {
var generateNote = function (baseNotes) {
var randomNoteIndex = _.random(0, baseNotes.length - 1);
var note = baseNotes.splice(randomNoteIndex, 1)[0];

Expand Down
10 changes: 5 additions & 5 deletions app/scripts/views/statistics_view.js
@@ -1,7 +1,7 @@
import Chartist from 'Chartist';
import React, {Component} from 'react';
import StatisticService from '../services/statistic_service.js';
import KeyConverter from '../services/key_converter.js';
import Chartist from "Chartist";
import React, {Component} from "react";
import StatisticService from "../services/statistic_service.js";
import KeyConverter from "../services/key_converter.js";

export default class StatisticsView extends Component {

Expand All @@ -17,7 +17,7 @@ export default class StatisticsView extends Component {
<h4>The last days you trained:</h4>
<ul>
{
statistics.getLastDays(10).map(function(el){
statistics.getLastDays(10).map(function (el){
<li>
{ (el.averageTime / 1000).toFixed(2) }s average
({ (el.totalTime / 1000 / 60).toFixed(2) } min)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -32,7 +32,7 @@
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"css-loader": "^0.23.1",
"eslint": "^0.21.2",
"eslint": "^2.2.0",
"eslint-plugin-react": "^2.3.0",
"karma": "^0.12.23",
"karma-beep-reporter": "^0.1.4",
Expand Down

0 comments on commit 641c75b

Please sign in to comment.