From 81f73ee05720548ade20e8cb716f01a850eb379b Mon Sep 17 00:00:00 2001 From: Nicolas Perriault Date: Sat, 28 Feb 2015 18:24:04 +0100 Subject: [PATCH] Added eslint support. --- .eslintrc | 23 +++++++++++++++++++++++ package.json | 3 ++- test.js | 12 ++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..10c440a --- /dev/null +++ b/.eslintrc @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "node": true + }, + + "rules": { + "camelcase": [0], + "curly": [0], + "quotes": [1, "double"], + "eol-last": [0], + "key-spacing": [0], + "no-alert": [0], + "no-comma-dangle": [0], + "no-mixed-requires": [0], + "no-multi-spaces": [0], + "no-new": [0], + "no-shadow": [0], + "no-trailing-spaces": [2], + "no-underscore-dangle": [0], + "no-unused-vars": [1] + } +} diff --git a/package.json b/package.json index 59dd34f..63c1764 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "Flux experiment.", "main": "index.js", "scripts": { - "test": "istanbul cover node_modules/.bin/_mocha --report html --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" + "lint": "eslint index.js test.js", + "test": "npm run lint && istanbul cover node_modules/.bin/_mocha --report html --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" }, "devDependencies": { "bluebird": "^2.9.6", diff --git a/test.js b/test.js index 9f81514..edbc995 100644 --- a/test.js +++ b/test.js @@ -1,3 +1,6 @@ +/*global Promise:true, describe, it, beforeEach*/ +"use strict"; + var DocBrown = require("./"); var expect = require("chai").expect; var sinon = require("sinon"); @@ -138,12 +141,14 @@ describe("DocBrown.createActions()", function() { }); it("should require a dispatcher", function() { + /*eslint new-cap:0*/ expect(function() { DocBrown.createActions(); }).to.Throw(/Invalid dispatcher/); }); it("should require an actions array", function() { + /*eslint new-cap:0*/ expect(function() { DocBrown.createActions(dispatcher); }).to.Throw(/Invalid actions array/); @@ -213,6 +218,7 @@ describe("DocBrown.createStore()", function() { }); it("should require a store prototype", function() { + /*eslint new-cap:0*/ expect(function() { new (DocBrown.createStore())(); }).to.Throw(/Invalid store prototype/); @@ -223,12 +229,14 @@ describe("DocBrown.createStore()", function() { }); it("should ensure an actions array is provided", function() { + /*eslint new-cap:0*/ expect(function() { new (DocBrown.createStore({}))(); }).to.Throw(/non-empty actions array/); }); it("should ensure a non-empty actions array is provided", function() { + /*eslint new-cap:0*/ expect(function() { new (DocBrown.createStore({actions: []}))(); }).to.Throw(/non-empty actions array/); @@ -243,7 +251,7 @@ describe("DocBrown.createStore()", function() { it("should apply initialize with constructor args if defined", function() { var proto = {actions: [Actions], initialize: sinon.spy()}; var Store = DocBrown.createStore(proto); - var store = new Store(1, 2, 3); + new Store(1, 2, 3); sinon.assert.calledOnce(proto.initialize); sinon.assert.calledWithExactly(proto.initialize, 1, 2, 3); @@ -418,7 +426,7 @@ describe("DocBrown.createStore()", function() { return subscriber.getCall(0); } function expectNotUpdated(currentState, newState) { - if (!!setup(currentState, newState)) { + if (Boolean(setup(currentState, newState))) { throw new Error("state updated"); } }