Skip to content

Commit

Permalink
Switch to ESLint for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
stewart committed Jun 11, 2015
1 parent 30b18a1 commit 3ea6840
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 65 deletions.
46 changes: 46 additions & 0 deletions .eslintrc
@@ -0,0 +1,46 @@
env:
node: true

globals:
every: true
after: true
constantly: true

rules:
camelcase: [2, {properties: "always"}]
comma-dangle: "always-multiline"
comma-spacing: [2, {before: false, after: true}]
comma-style: [2, "last"]
handle-callback-err: [2, "^.*(e|E)rr" ]
indent: [2, 2]
key-spacing: [2, { beforeColon: false, afterColon: true }]
max-depth: [1, 3]
max-len: [1, 80, 4]
max-nested-callbacks: [1, 3]
no-cond-assign: 2
no-constant-condition: 2
no-dupe-args: 2
no-dupe-keys: 2
no-else-return: 2
no-empty: 2
no-lonely-if: 2
no-multiple-empty-lines: 2
no-nested-ternary: 2
no-reserved-keys: 2
no-self-compare: 2
no-sync: 1
no-throw-literal: 2
no-underscore-dangle: 0
quote-props: [2, "as-needed"]
quotes: [2, "double", "avoid-escape"]
radix: 2
semi-spacing: [2, {before: false, after: true}]
semi: [2, "always"]
space-after-keywords: [2, "always"]
space-before-blocks: [2, "always"]
space-before-function-paren: [1, "never"]
space-in-parens: [2, "never"]
spaced-line-comment: [1, "always"]
strict: [2, "global"]
valid-jsdoc: 2
yoda: [2, "never"]
38 changes: 0 additions & 38 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -18,7 +18,7 @@ cover:
@istanbul cover $(BIN)/_mocha $(TEST_FILES) --report lcovonly -- -R spec

lint:
@jshint $(FILES)
@$(BIN)/eslint lib spec examples

ci: lint cover

Expand Down
2 changes: 2 additions & 0 deletions examples/.eslintrc
@@ -0,0 +1,2 @@
rules:
camelcase: 0
2 changes: 1 addition & 1 deletion examples/audio-sample/audio-sample.js
Expand Up @@ -12,7 +12,7 @@ Cylon.robot({
},

work: function(my) {
my.jukebox.on("playing", function(song){
my.jukebox.on("playing", function(song) {
console.log("Playing this nice tune: \"" + song + "\"");
});

Expand Down
2 changes: 1 addition & 1 deletion examples/audio-sample/fluent-audio-sample.js
Expand Up @@ -9,7 +9,7 @@ Cylon
})
.device("jukebox", { driver: "audio" })
.on("ready", function(robot) {
robot.jukebox.on("playing", function(song){
robot.jukebox.on("playing", function(song) {
console.log("Playing this nice tune: \"" + song + "\"");
});

Expand Down
2 changes: 1 addition & 1 deletion examples/simple-playback/fluent-simple-playback.js
Expand Up @@ -8,7 +8,7 @@ Cylon
.device("audio", { driver: "audio" })

.on("ready", function(bot) {
bot.audio.on("playing", function(song){
bot.audio.on("playing", function(song) {
console.log("Playing this nice tune: \"" + song + "\"");
});

Expand Down
2 changes: 1 addition & 1 deletion examples/simple-playback/simple-playback.js
Expand Up @@ -13,7 +13,7 @@ Cylon.robot({

work: function(my) {

my.audio.on("playing", function(song){
my.audio.on("playing", function(song) {
console.log("Playing this nice tune: \"" + song + "\"");
});

Expand Down
8 changes: 4 additions & 4 deletions lib/adaptor.js
Expand Up @@ -49,7 +49,7 @@ Adaptor.prototype.commands = ["play"];
* Connects
*
* @param {Function} callback to be triggered when connected
* @return {null}
* @return {void}
*/
Adaptor.prototype.connect = function(callback) {
this.decoder.on("format", function(err, data) {
Expand All @@ -65,7 +65,7 @@ Adaptor.prototype.connect = function(callback) {
* Disconnects
*
* @param {Function} callback to be triggered when disconnected
* @return {null}
* @return {void}
*/
Adaptor.prototype.disconnect = function(callback) {
callback();
Expand All @@ -77,11 +77,11 @@ Adaptor.prototype.disconnect = function(callback) {
*
* @param {String|Number} track path to track to be played, or index of
* `this.tracks` to play
* @return {null}
* @return {void}
* @publish
*/
Adaptor.prototype.play = function(track) {
var trackPath = (typeof(track) === "number") ? this.tracks[track] : track;
var trackPath = (typeof track === "number") ? this.tracks[track] : track;
var readStream = fs.createReadStream(trackPath);

this.emit("playing", trackPath);
Expand Down
6 changes: 3 additions & 3 deletions lib/driver.js
Expand Up @@ -33,7 +33,7 @@ Cylon.Utils.subclass(Driver, Cylon.Driver);
* Starts
*
* @param {Function} callback to be triggered when connected
* @return {null}
* @return {void}
*/
Driver.prototype.start = function(callback) {
this.defineDriverEvent("playing");
Expand All @@ -44,7 +44,7 @@ Driver.prototype.start = function(callback) {
* Stops
*
* @param {Function} callback to be triggered when halted
* @return {null}
* @return {void}
*/
Driver.prototype.halt = function(callback) {
callback();
Expand All @@ -55,7 +55,7 @@ Driver.prototype.halt = function(callback) {
*
* @param {String|Number} track path to track to be played, or index of
* `this.tracks` to play
* @return {null}
* @return {void}
* @publish
*/
Driver.prototype.play = function(track) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -31,7 +31,7 @@
"chai": "1.9.1",
"mocha": "1.18.2",
"sinon": "1.9.1",
"jshint": "2.5.0"
"eslint": "0.22.1"
},

"dependencies": {
Expand Down
15 changes: 15 additions & 0 deletions spec/.eslintrc
@@ -0,0 +1,15 @@
env:
mocha: true

globals:
expect: true
lib: true
stub: true
spy: true
chai: true
sinon: true

rules:
no-unused-expressions: 0
max-nested-callbacks: 0
camelcase: 0
18 changes: 9 additions & 9 deletions spec/helper.js
@@ -1,12 +1,12 @@
'use strict';
"use strict";

process.env.NODE_ENV = 'test';
process.env.NODE_ENV = "test";

var path = require('path');
var path = require("path");

var chai = require('chai'),
sinon = require('sinon'),
sinonChai = require('sinon-chai');
var chai = require("chai"),
sinon = require("sinon"),
sinonChai = require("sinon-chai");

chai.use(sinonChai);

Expand All @@ -22,9 +22,9 @@ global.spy = sinon.spy;
global.stub = sinon.stub;

// convenience function to require modules in lib directory
global.source = function(module) {
return require(path.normalize('./../lib/' + module));
global.lib = function(module) {
return require(path.normalize("./../lib/" + module));
};

var Cylon = require('cylon');
var Cylon = require("cylon");
Cylon.config({ logging: { logger: false } });
2 changes: 1 addition & 1 deletion spec/lib/adaptor.spec.js
@@ -1,6 +1,6 @@
"use strict";

var Audio = source("adaptor");
var Audio = lib("adaptor");

describe("Cylon.Adaptors.Audio", function() {
var audio = new Audio();
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/cylon-audio.spec.js
@@ -1,9 +1,9 @@
"use strict";

var audio = source("cylon-audio");
var audio = lib("cylon-audio");

var Adaptor = source("adaptor"),
Driver = source("driver");
var Adaptor = lib("adaptor"),
Driver = lib("driver");

describe("Cylon.Audio", function() {
describe("#adaptors", function() {
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/driver.spec.js
@@ -1,6 +1,6 @@
"use strict";

var Driver = source("driver");
var Driver = lib("driver");

describe("Driver", function() {
var driver;
Expand Down

0 comments on commit 3ea6840

Please sign in to comment.