diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000000..d67abcd0d2
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,24 @@
+{
+ "extends": [
+ "spt",
+ "spt/env-node",
+ "spt/env-es6-false",
+ "spt/env-react"
+ ],
+ "env": {
+ "browser": true
+ },
+ "rules": {
+ "quotes": 0,
+ "strict": 0,
+ "vars-on-top": 0,
+ "no-use-before-define": 0,
+ "dot-notation": 0,
+ "eqeqeq": 0,
+ "no-eq-null": 0,
+ "no-undefined": 0,
+ "no-else-return": 0,
+ "no-shadow": 0,
+ "consistent-this": 0
+ }
+}
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 14c2070177..0000000000
--- a/.jshintrc
+++ /dev/null
@@ -1,83 +0,0 @@
-{
- "globals": {
- "jQuery" : false,
- "$" : false,
- "sinon" : false,
- "describe" : false,
- "it" : false,
- "xit" : false,
- "expect" : false,
- "before" : false,
- "after" : false,
- "beforeEach": false,
- "afterEach" : false,
- "contain" : false
- },
-
- "bitwise" : true,
- "camelcase" : true,
- "curly" : true,
- "eqeqeq" : false,
- "es3" : false,
- "forin" : false,
- "freeze" : false,
- "immed" : true,
- "indent" : 4,
- "latedef" : "nofunc",
- "newcap" : false,
- "noarg" : true,
- "noempty" : true,
- "nonbsp" : true,
- "nonew" : true,
- "plusplus" : false,
- "quotmark" : false,
- "undef" : true,
- "unused" : true,
- "strict" : false,
- "trailing" : true,
- "maxparams" : 3,
- "maxdepth" : 4,
- "maxstatements" : 20,
- "maxcomplexity" : 10,
- "maxlen" : 120,
- "predef": [ "-Promise" ],
-
- "asi" : false,
- "boss" : false,
- "debug" : false,
- "eqnull" : true,
- "esnext" : false,
- "evil" : false,
- "expr" : false,
- "funcscope" : false,
- "globalstrict" : false,
- "iterator" : false,
- "lastsemic" : false,
- "laxbreak" : false,
- "laxcomma" : false,
- "loopfunc" : false,
- "maxerr" : 100,
- "moz" : false,
- "multistr" : true,
- "notypeof" : false,
- "proto" : false,
- "scripturl" : false,
- "smarttabs" : false,
- "shadow" : false,
- "sub" : false,
- "supernew" : false,
- "validthis" : false,
- "noyield" : false,
-
- "browser" : true,
- "devel" : false,
- "node" : true,
- "jquery" : false,
- "nonstandard" : false,
- "prototypejs" : false,
-
- "nomen" : false,
- "onevar" : false,
- "passfail" : false,
- "white" : false
-}
diff --git a/app.js b/app.js
index 7523d8344c..a67fc63655 100644
--- a/app.js
+++ b/app.js
@@ -10,10 +10,10 @@ var express = require('express'),
strategyApi = require('./lib/strategyApi'),
validator = require('express-validator'),
app = express(),
- router = express.Router(),
+ router = express.Router(), // eslint-disable-line
baseUriPath = process.env.BASE_URI_PATH || '';
-if(app.get('env') === 'development') {
+if (app.get('env') === 'development') {
app.use(require('errorhandler')());
var webpack = require('webpack'),
@@ -41,7 +41,7 @@ app.use(log4js.connectLogger(logger, {
app.set('port', process.env.HTTP_PORT || process.env.PORT || 4242);
app.use(baseUriPath, express.static(__dirname + '/public'));
-app.use(bodyParser.json({strict: false}));
+app.use(bodyParser.json({ strict: false }));
app.use(cookieParser());
diff --git a/jest-preprocessor.js b/jest-preprocessor.js
index 2637772f52..e869fa1b7f 100644
--- a/jest-preprocessor.js
+++ b/jest-preprocessor.js
@@ -4,4 +4,4 @@ module.exports = {
process: function(src) {
return ReactTools.transform(src);
}
-};
\ No newline at end of file
+};
diff --git a/lib/dbPool.js b/lib/dbPool.js
index 0d77a601eb..2ef8ffc5a9 100644
--- a/lib/dbPool.js
+++ b/lib/dbPool.js
@@ -42,8 +42,8 @@ function createDbPool() {
return knex({
client: 'pg',
connection: isTestEnv() ? getTestDatabaseUrl() : getDatabaseUrl(),
- pool: {min: 2, max: 20}
+ pool: { min: 2, max: 20 }
});
}
-module.exports = createDbPool();
\ No newline at end of file
+module.exports = createDbPool();
diff --git a/lib/error/NameExistsError.js b/lib/error/NameExistsError.js
index ecee9feedf..6529783487 100644
--- a/lib/error/NameExistsError.js
+++ b/lib/error/NameExistsError.js
@@ -10,4 +10,4 @@ function NameExistsError(message) {
util.inherits(NameExistsError, Error);
-module.exports = NameExistsError;
\ No newline at end of file
+module.exports = NameExistsError;
diff --git a/lib/error/NotFoundError.js b/lib/error/NotFoundError.js
index 235cb85313..066b595818 100644
--- a/lib/error/NotFoundError.js
+++ b/lib/error/NotFoundError.js
@@ -10,4 +10,4 @@ function NotFoundError(message) {
util.inherits(NotFoundError, Error);
-module.exports = NotFoundError;
\ No newline at end of file
+module.exports = NotFoundError;
diff --git a/lib/error/ValidationError.js b/lib/error/ValidationError.js
index a1f624de49..7e2e41f8cc 100644
--- a/lib/error/ValidationError.js
+++ b/lib/error/ValidationError.js
@@ -10,4 +10,4 @@ function ValidationError(message) {
util.inherits(ValidationError, Error);
-module.exports = ValidationError;
\ No newline at end of file
+module.exports = ValidationError;
diff --git a/lib/error/validateRequest.js b/lib/error/validateRequest.js
index 58819b0730..4fd213af01 100644
--- a/lib/error/validateRequest.js
+++ b/lib/error/validateRequest.js
@@ -11,4 +11,4 @@ function validateRequest(req) {
});
}
-module.exports = validateRequest;
\ No newline at end of file
+module.exports = validateRequest;
diff --git a/lib/eventApi.js b/lib/eventApi.js
index 2b41f37158..6c8e2b33e6 100644
--- a/lib/eventApi.js
+++ b/lib/eventApi.js
@@ -2,11 +2,10 @@ var eventDb = require('./eventDb');
var eventDiffer = require('./eventDiffer');
module.exports = function (app) {
-
app.get('/events', function (req, res) {
eventDb.getEvents().then(function (events) {
eventDiffer.addDiffs(events);
- res.json({events: events});
+ res.json({ events: events });
});
});
@@ -16,9 +15,8 @@ module.exports = function (app) {
eventDiffer.addDiffs(events);
res.json(events);
} else {
- res.status(404).json({error: 'Could not find events'});
+ res.status(404).json({ error: 'Could not find events' });
}
});
});
-
-};
\ No newline at end of file
+};
diff --git a/lib/eventDb.js b/lib/eventDb.js
index 14c9d6fc0e..5dea161375 100644
--- a/lib/eventDb.js
+++ b/lib/eventDb.js
@@ -4,7 +4,7 @@ var EVENT_COLUMNS = ['id', 'type', 'created_by', 'created_at', 'data'];
function storeEvent(event) {
return knex('events').insert({
type: event.type,
- created_by: event.createdBy, // jshint ignore:line
+ created_by: event.createdBy, // eslint-disable-line
data: event.data
});
}
@@ -30,8 +30,8 @@ function rowToEvent(row) {
return {
id: row.id,
type: row.type,
- createdBy: row.created_by, // jshint ignore:line
- createdAt: row.created_at, // jshint ignore:line
+ createdBy: row.created_by,
+ createdAt: row.created_at,
data: row.data
};
}
@@ -40,4 +40,4 @@ module.exports = {
store: storeEvent,
getEvents: getEvents,
getEventsFilterByName: getEventsFilterByName
-};
\ No newline at end of file
+};
diff --git a/lib/eventDiffer.js b/lib/eventDiffer.js
index eb2662cb6d..f23427f461 100644
--- a/lib/eventDiffer.js
+++ b/lib/eventDiffer.js
@@ -71,4 +71,4 @@ function addDiffs(events) {
module.exports = {
addDiffs: addDiffs
-};
\ No newline at end of file
+};
diff --git a/lib/eventStore.js b/lib/eventStore.js
index 0c4207c08f..f8e24072c0 100644
--- a/lib/eventStore.js
+++ b/lib/eventStore.js
@@ -14,4 +14,4 @@ EventStore.prototype.create = function (event) {
});
};
-module.exports = new EventStore();
\ No newline at end of file
+module.exports = new EventStore();
diff --git a/lib/eventType.js b/lib/eventType.js
index dce3b67bbf..d6c57b71bf 100644
--- a/lib/eventType.js
+++ b/lib/eventType.js
@@ -1,8 +1,8 @@
module.exports = {
- featureCreated : 'feature-created',
- featureUpdated : 'feature-updated',
- featureArchived : 'feature-archived',
- featureRevived : 'feature-revived',
+ featureCreated: 'feature-created',
+ featureUpdated: 'feature-updated',
+ featureArchived: 'feature-archived',
+ featureRevived: 'feature-revived',
strategyCreated: 'strategy-created',
strategyDeleted: 'strategy-deleted'
-};
\ No newline at end of file
+};
diff --git a/lib/extractUser.js b/lib/extractUser.js
index 2da29b954e..7411633381 100644
--- a/lib/extractUser.js
+++ b/lib/extractUser.js
@@ -1,4 +1,4 @@
function extractUsername(req) {
- return req.cookies.username || "unknown";
+ return req.cookies.username || "unknown";
}
module.exports = extractUsername;
diff --git a/lib/featureApi.js b/lib/featureApi.js
index 1be1f84116..5a4ba8a817 100644
--- a/lib/featureApi.js
+++ b/lib/featureApi.js
@@ -10,18 +10,19 @@ var validateRequest = require('./error/validateRequest');
var extractUser = require('./extractUser');
module.exports = function (app) {
-
app.get('/features', function (req, res) {
featureDb.getFeatures().then(function (features) {
- res.json({features: features});
+ res.json({ features: features });
});
});
app.get('/features/:featureName', function (req, res) {
featureDb.getFeature(req.params.featureName)
- .then(function (feature) { res.json(feature); })
+ .then(function (feature) {
+ res.json(feature);
+ })
.catch(function () {
- res.status(404).json({error: 'Could not find feature'});
+ res.status(404).json({ error: 'Could not find feature' });
});
});
@@ -53,7 +54,7 @@ module.exports = function (app) {
logger.error("Could not create feature toggle", err);
res.status(500).end();
});
- });
+ });
app.put('/features/:featureName', function (req, res) {
var featureName = req.params.featureName;
diff --git a/lib/featureArchiveApi.js b/lib/featureArchiveApi.js
index a4b8752c41..430b0c82a7 100644
--- a/lib/featureArchiveApi.js
+++ b/lib/featureArchiveApi.js
@@ -6,10 +6,9 @@ var ValidationError = require('./error/ValidationError');
var validateRequest = require('./error/validateRequest');
module.exports = function (app) {
-
app.get('/archive/features', function (req, res) {
featureDb.getArchivedFeatures().then(function (archivedFeatures) {
- res.json({'features': archivedFeatures});
+ res.json({ 'features': archivedFeatures });
});
});
@@ -34,4 +33,3 @@ module.exports = function (app) {
});
});
};
-
diff --git a/lib/featureDb.js b/lib/featureDb.js
index 100c13aeb0..21b6d55bb4 100644
--- a/lib/featureDb.js
+++ b/lib/featureDb.js
@@ -25,7 +25,7 @@ function getFeatures() {
return knex
.select(FEATURE_COLUMNS)
.from('features')
- .where({archived: 0})
+ .where({ archived: 0 })
.orderBy('name', 'asc')
.map(rowToFeature);
}
@@ -34,7 +34,7 @@ function getFeature(name) {
return knex
.first(FEATURE_COLUMNS)
.from('features')
- .where({name: name})
+ .where({ name: name })
.then(rowToFeature);
}
@@ -42,7 +42,7 @@ function getArchivedFeatures() {
return knex
.select(FEATURE_COLUMNS)
.from('features')
- .where({archived: 1})
+ .where({ archived: 1 })
.orderBy('name', 'asc')
.map(rowToFeature);
}
@@ -57,7 +57,7 @@ function rowToFeature(row) {
name: row.name,
description: row.description,
enabled: row.enabled > 0,
- strategy: row.strategy_name, // jshint ignore: line
+ strategy: row.strategy_name, // eslint-disable-line
parameters: row.parameters
};
}
@@ -68,7 +68,7 @@ function eventDataToRow(data) {
description: data.description,
enabled: data.enabled ? 1 : 0,
archived: data.archived ? 1 :0,
- strategy_name: data.strategy, // jshint ignore: line
+ strategy_name: data.strategy, // eslint-disable-line
parameters: data.parameters
};
}
@@ -83,7 +83,7 @@ function createFeature(data) {
function updateFeature(data) {
return knex('features')
- .where({name: data.name})
+ .where({ name: data.name })
.update(eventDataToRow(data))
.catch(function (err) {
logger.error('Could not update feature, error was: ', err);
@@ -92,8 +92,8 @@ function updateFeature(data) {
function archiveFeature(data) {
return knex('features')
- .where({name: data.name})
- .update({archived: 1})
+ .where({ name: data.name })
+ .update({ archived: 1 })
.catch(function (err) {
logger.error('Could not archive feature, error was: ', err);
});
@@ -101,8 +101,8 @@ function archiveFeature(data) {
function reviveFeature(data) {
return knex('features')
- .where({name: data.name})
- .update({archived: 0, enabled: 0})
+ .where({ name: data.name })
+ .update({ archived: 0, enabled: 0 })
.catch(function (err) {
logger.error('Could not archive feature, error was: ', err);
});
diff --git a/lib/migrationRunner.js b/lib/migrationRunner.js
index f8145f8a2c..9822a09d24 100644
--- a/lib/migrationRunner.js
+++ b/lib/migrationRunner.js
@@ -3,7 +3,7 @@ var util = require('util');
var path = require('path');
var runMigration = function(path, db, callback) {
- db.runSql(fs.readFileSync(path, {encoding: 'utf8'}), callback);
+ db.runSql(fs.readFileSync(path, { encoding: 'utf8' }), callback);
};
module.exports = {
diff --git a/lib/routes.js b/lib/routes.js
index 66206416dd..f354178c10 100644
--- a/lib/routes.js
+++ b/lib/routes.js
@@ -2,17 +2,15 @@ var knex = require('./dbPool');
var logger = require('./logger');
module.exports = function (app) {
-
app.get('/health', function (req, res) {
knex.select(1)
.from('features')
.then(function() {
- res.json({health: 'GOOD'});
+ res.json({ health: 'GOOD' });
})
.catch(function(err) {
logger.error('Could not select from features, error was: ', err);
- res.status(500).json({health: 'BAD'});
+ res.status(500).json({ health: 'BAD' });
});
});
-
};
diff --git a/lib/strategyApi.js b/lib/strategyApi.js
index 460889640c..2837f3ff89 100644
--- a/lib/strategyApi.js
+++ b/lib/strategyApi.js
@@ -10,17 +10,20 @@ var validateRequest = require('./error/validateRequest');
var extractUser = require('./extractUser');
module.exports = function (app) {
-
app.get('/strategies', function (req, res) {
strategyDb.getStrategies().then(function (strategies) {
- res.json({strategies: strategies});
+ res.json({ strategies: strategies });
});
});
app.get('/strategies/:name', function (req, res) {
strategyDb.getStrategy(req.params.name)
- .then(function (strategy) { res.json(strategy); })
- .catch(function () { res.status(404).json({error: 'Could not find strategy'}); });
+ .then(function (strategy) {
+ res.json(strategy);
+ })
+ .catch(function () {
+ res.status(404).json({ error: 'Could not find strategy' });
+ });
});
app.delete('/strategies/:name', function (req, res) {
@@ -67,7 +70,7 @@ module.exports = function (app) {
res.status(201).end();
})
.catch(NameExistsError, function() {
- res.status(403).json([{msg: "A strategy named '" + req.body.name + "' already exists."}]).end();
+ res.status(403).json([{ msg: "A strategy named '" + req.body.name + "' already exists." }]).end();
})
.catch(ValidationError, function() {
res.status(400).json(req.validationErrors());
@@ -88,5 +91,4 @@ module.exports = function (app) {
});
});
}
-
};
diff --git a/lib/strategyDb.js b/lib/strategyDb.js
index 8a0bec2d9b..daa7241a82 100644
--- a/lib/strategyDb.js
+++ b/lib/strategyDb.js
@@ -30,7 +30,7 @@ function getStrategy(name) {
return knex
.first(STRATEGY_COLUMNS)
.from('strategies')
- .where({name: name})
+ .where({ name: name })
.then(rowToStrategy);
}
@@ -42,7 +42,7 @@ function rowToStrategy(row) {
return {
name: row.name,
description: row.description,
- parametersTemplate: row.parameters_template // jshint ignore: line
+ parametersTemplate: row.parameters_template
};
}
@@ -50,7 +50,7 @@ function eventDataToRow(data) {
return {
name: data.name,
description: data.description,
- parameters_template: data.parametersTemplate // jshint ignore: line
+ parameters_template: data.parametersTemplate // eslint-disable-line
};
}
diff --git a/migrations/20141020151056-initial-schema.js b/migrations/20141020151056-initial-schema.js
index 3859a6a6dc..b1d5b3f5f0 100644
--- a/migrations/20141020151056-initial-schema.js
+++ b/migrations/20141020151056-initial-schema.js
@@ -1 +1 @@
-module.exports = require('../lib/migrationRunner').create('001-initial-schema');
\ No newline at end of file
+module.exports = require('../lib/migrationRunner').create('001-initial-schema');
diff --git a/migrations/20141110144153-add-description-to-features.js b/migrations/20141110144153-add-description-to-features.js
index 7ff1b2734a..fd90440779 100644
--- a/migrations/20141110144153-add-description-to-features.js
+++ b/migrations/20141110144153-add-description-to-features.js
@@ -1,2 +1 @@
module.exports = require('../lib/migrationRunner').create('002-add-description-to-features');
-
diff --git a/migrations/20141117200435-add-parameters-template-to-strategies.js b/migrations/20141117200435-add-parameters-template-to-strategies.js
index fefd06f514..e8068b7a53 100644
--- a/migrations/20141117200435-add-parameters-template-to-strategies.js
+++ b/migrations/20141117200435-add-parameters-template-to-strategies.js
@@ -1 +1,2 @@
module.exports = require('../lib/migrationRunner').create('003-add-parameters-template-to-strategies');
+
diff --git a/migrations/20141117202209-insert-default-strategy.js b/migrations/20141117202209-insert-default-strategy.js
index 7b6adc789b..2023e55488 100644
--- a/migrations/20141117202209-insert-default-strategy.js
+++ b/migrations/20141117202209-insert-default-strategy.js
@@ -1 +1 @@
-module.exports = require('../lib/migrationRunner').create('004-insert-default-strategy');
\ No newline at end of file
+module.exports = require('../lib/migrationRunner').create('004-insert-default-strategy');
diff --git a/migrations/20141118071458-default-strategy-event.js b/migrations/20141118071458-default-strategy-event.js
index 2fb4203eec..8157598e8c 100644
--- a/migrations/20141118071458-default-strategy-event.js
+++ b/migrations/20141118071458-default-strategy-event.js
@@ -1 +1 @@
-module.exports = require('../lib/migrationRunner').create('004-insert-default-strategy-event');
\ No newline at end of file
+module.exports = require('../lib/migrationRunner').create('004-insert-default-strategy-event');
diff --git a/migrations/20150210152531-006-rename-eventtype.js b/migrations/20150210152531-006-rename-eventtype.js
index cdd0b89518..d184ba32f7 100644
--- a/migrations/20150210152531-006-rename-eventtype.js
+++ b/migrations/20150210152531-006-rename-eventtype.js
@@ -1 +1 @@
-module.exports = require('../lib/migrationRunner').create('006-rename-eventtype');
\ No newline at end of file
+module.exports = require('../lib/migrationRunner').create('006-rename-eventtype');
diff --git a/package.json b/package.json
index ba8e7aaa3d..12ff4e0316 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
"coverage-report": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"postinstall": "npm run build",
"jest": "jest",
- "lint": "jshint server.js lib test && jsxhint public/js/**/*.jsx"
+ "lint": "eslint . --ignore-path .gitignore"
},
"dependencies": {
"bluebird": "2.9.14",
@@ -65,9 +65,11 @@
"devDependencies": {
"chai": "2.1.2",
"coveralls": "^2.11.2",
+ "eslint": "^2.7.0",
+ "eslint-config-spt": "^2.0.0",
+ "eslint-plugin-react": "^4.3.0",
"istanbul": "^0.3.5",
"jest-cli": "0.5.4",
- "jshint": "^2.6.0",
"mocha": "^2.1.0",
"mocha-lcov-reporter": "0.0.2",
"nsp": "^1.0.0",
diff --git a/public/js/__tests__/.eslintrc b/public/js/__tests__/.eslintrc
new file mode 100644
index 0000000000..7d89fc81f0
--- /dev/null
+++ b/public/js/__tests__/.eslintrc
@@ -0,0 +1,25 @@
+{
+ "extends": [
+ "spt",
+ "spt/env-node",
+ "spt/env-es6-false"
+ ],
+ "env": {
+ "browser": true
+ },
+ "globals": {
+ "it": false,
+ "jest": false,
+ "beforeEach": false,
+ "expect": false,
+ "describe": false,
+ "afterEach": false
+ },
+ "rules": {
+ "quotes": 0,
+ "strict": 0,
+ "vars-on-top": 0,
+ "no-undefined": 0,
+ "no-shadow": 0
+ }
+}
\ No newline at end of file
diff --git a/public/js/__tests__/components/Menu-test.js b/public/js/__tests__/components/Menu-test.js
index 59f8024856..a49cb5869d 100644
--- a/public/js/__tests__/components/Menu-test.js
+++ b/public/js/__tests__/components/Menu-test.js
@@ -11,4 +11,4 @@ describe('Menu test', function () {
var Compononent = TestUtils .renderIntoDocument(
);
expect(Compononent.getDOMNode().textContent).toMatch('unleash');
});
-});
\ No newline at end of file
+});
diff --git a/public/js/__tests__/components/feature/ArchiveFeatureComponent-test.js b/public/js/__tests__/components/feature/ArchiveFeatureComponent-test.js
index 110013aed3..af849db9f9 100644
--- a/public/js/__tests__/components/feature/ArchiveFeatureComponent-test.js
+++ b/public/js/__tests__/components/feature/ArchiveFeatureComponent-test.js
@@ -6,7 +6,6 @@ var React = require("react/addons");
var TestUtils = React.addons.TestUtils;
var FeatureArchive = require("../../../components/feature/ArchiveFeatureComponent");
var FeatureActions = require("../../../stores/FeatureToggleActions");
-var FeatureToggleStore = require("../../../stores/ArchivedToggleStore");
describe("FeatureForm", function () {
var Component;
@@ -31,10 +30,10 @@ describe("FeatureForm", function () {
});
it("should revive archived feature toggle", function() {
- var button = Component.getDOMNode().querySelector("tbody button");
- TestUtils.Simulate.click(button);
+ var button = Component.getDOMNode().querySelector("tbody button");
+ TestUtils.Simulate.click(button);
- jest.runAllTimers();
- expect(FeatureActions.revive.triggerPromise).toBeCalled();
+ jest.runAllTimers();
+ expect(FeatureActions.revive.triggerPromise).toBeCalled();
});
});
diff --git a/public/js/__tests__/components/feature/FeatureForm-test.js b/public/js/__tests__/components/feature/FeatureForm-test.js
index 581d062fbd..fea56b73dd 100644
--- a/public/js/__tests__/components/feature/FeatureForm-test.js
+++ b/public/js/__tests__/components/feature/FeatureForm-test.js
@@ -7,7 +7,7 @@ var FeatureForm = require("../../../components/feature/FeatureForm");
describe("FeatureForm", function () {
var Component;
var strategies = [
- { name: "default"}
+ { name: "default" }
];
afterEach(function() {
React.unmountComponentAtNode(document.body);
@@ -22,7 +22,7 @@ describe("FeatureForm", function () {
});
describe("edit", function () {
- var feature = {name: "Test", strategy: "unknown"};
+ var feature = { name: "Test", strategy: "unknown" };
it("should show unknown strategy as default", function () {
Component = TestUtils .renderIntoDocument();
@@ -31,5 +31,4 @@ describe("FeatureForm", function () {
expect(strategySelect.value).toEqual("default");
});
});
-
});
diff --git a/public/js/__tests__/components/feature/FeatureList-test.js b/public/js/__tests__/components/feature/FeatureList-test.js
index 7c970c66fd..d39a558215 100644
--- a/public/js/__tests__/components/feature/FeatureList-test.js
+++ b/public/js/__tests__/components/feature/FeatureList-test.js
@@ -14,7 +14,7 @@ describe("FeatureList", function () {
{ name: "group.featureY", strategy: "default" }
];
var strategies=[
- { name: "default"}
+ { name: "default" }
];
Component = TestUtils .renderIntoDocument();
});
@@ -30,7 +30,7 @@ describe("FeatureList", function () {
it("should filter list of features", function() {
var filterNode = Component.refs.filter.getDOMNode();
- TestUtils.Simulate.change(filterNode, {target: {value: "group"}});
+ TestUtils.Simulate.change(filterNode, { target: { value: "group" } });
var features = Component.getDOMNode().querySelectorAll(".feature");
expect(features.length).toEqual(1);
@@ -38,7 +38,7 @@ describe("FeatureList", function () {
it("should filter list of features ignoring case", function() {
var filterNode = Component.refs.filter.getDOMNode();
- TestUtils.Simulate.change(filterNode, {target: {value: "GROUP"}});
+ TestUtils.Simulate.change(filterNode, { target: { value: "GROUP" } });
var features = Component.getDOMNode().querySelectorAll(".feature");
expect(features.length).toEqual(1);
@@ -48,11 +48,10 @@ describe("FeatureList", function () {
it("should filter list of features by strategy name", function() {
var searchString = "other";
var filterNode = Component.refs.filter.getDOMNode();
- TestUtils.Simulate.change(filterNode, {target: {value: searchString}});
+ TestUtils.Simulate.change(filterNode, { target: { value: searchString } });
var features = Component.getDOMNode().querySelectorAll(".feature");
expect(features.length).toEqual(1);
expect(features[0].textContent).toMatch(searchString);
});
-
});
diff --git a/public/js/__tests__/stores/FeatureToggleStore-test.js b/public/js/__tests__/stores/FeatureToggleStore-test.js
index ba2b62ff8d..bd569be796 100644
--- a/public/js/__tests__/stores/FeatureToggleStore-test.js
+++ b/public/js/__tests__/stores/FeatureToggleStore-test.js
@@ -1,16 +1,15 @@
-jest.autoMockOff()
+jest.autoMockOff();
jest.dontMock('../../stores/FeatureToggleActions');
jest.dontMock('../../stores/FeatureToggleStore');
describe('FeatureToggleStore', function() {
-
var Actions, Store, toggles;
beforeEach(function() {
Actions = require('../../stores/FeatureToggleActions');
Store = require('../../stores/FeatureToggleStore');
toggles = [
- {name: "app.feature", enabled: true, strategy: "default"}
+ { name: "app.feature", enabled: true, strategy: "default" }
];
});
@@ -29,7 +28,7 @@ describe('FeatureToggleStore', function() {
it('should add a another toggle', function() {
Actions.init.completed(toggles);
- var newToggle = {name: "app.featureB", enabled: true, strategy: "default"};
+ var newToggle = { name: "app.featureB", enabled: true, strategy: "default" };
Actions.create.completed(newToggle);
@@ -47,15 +46,14 @@ describe('FeatureToggleStore', function() {
expect(Store.getFeatureToggles().length).toBe(0);
});
-
it('should keep toggles in sorted order', function() {
Actions.init.completed([
- {name: "A"},
- {name: "B"},
- {name: "C"}
+ { name: "A" },
+ { name: "B" },
+ { name: "C" }
]);
- Actions.create.completed({name: "AA"});
+ Actions.create.completed({ name: "AA" });
jest.runAllTimers();
expect(Store.getFeatureToggles()[0].name).toEqual("A");
@@ -74,8 +72,4 @@ describe('FeatureToggleStore', function() {
jest.runAllTimers();
expect(Store.getFeatureToggles()[0].enabled).toEqual(false);
});
-
-
-
-
});
diff --git a/public/js/stores/ArchivedToggleStore.js b/public/js/stores/ArchivedToggleStore.js
index 607f24ca31..343ff5d852 100644
--- a/public/js/stores/ArchivedToggleStore.js
+++ b/public/js/stores/ArchivedToggleStore.js
@@ -13,7 +13,6 @@ var FeatureStore = Reflux.createStore({
this.listenTo(FeatureActions.initArchive.completed, this.onInit);
this.listenTo(FeatureActions.archive.completed, this.onArchive);
this.listenTo(FeatureActions.revive.completed, this.onRevive);
-
},
onInit: function(toggles) {
diff --git a/public/js/stores/ErrorStore.js b/public/js/stores/ErrorStore.js
index f3734663a8..609e0ebb5e 100644
--- a/public/js/stores/ErrorStore.js
+++ b/public/js/stores/ErrorStore.js
@@ -16,10 +16,12 @@ var FeatureStore = Reflux.createStore({
this.errors = [];
},
- onError: function (error) {
+ onError: function (error) {
if (this.isClientError(error)) {
var errors = JSON.parse(error.responseText);
- errors.forEach(function(e) { this.addError(e.msg); }.bind(this));
+ errors.forEach(function(e) {
+ this.addError(e.msg);
+ }.bind(this));
} else if (error.status === 0) {
this.addError("server unreachable");
} else {
diff --git a/public/js/stores/EventStore.js b/public/js/stores/EventStore.js
index 696fb66c22..6dd1f7af09 100644
--- a/public/js/stores/EventStore.js
+++ b/public/js/stores/EventStore.js
@@ -1,7 +1,6 @@
var reqwest = require('reqwest');
var TYPE = 'json';
-var CONTENT_TYPE = 'application/json';
var EventStore = {
getEvents: function () {
diff --git a/public/js/stores/FeatureToggleActions.js b/public/js/stores/FeatureToggleActions.js
index f41f071057..d746f06d95 100644
--- a/public/js/stores/FeatureToggleActions.js
+++ b/public/js/stores/FeatureToggleActions.js
@@ -2,71 +2,71 @@ var Reflux = require("reflux");
var Server = require('./FeatureToggleServerFacade');
var FeatureToggleActions = Reflux.createActions({
- 'init': { asyncResult: true },
- 'initArchive':{ asyncResult: true },
- 'create': { asyncResult: true },
- 'update': { asyncResult: true },
- 'archive': { asyncResult: true },
- 'revive': { asyncResult: true }
+ 'init': { asyncResult: true },
+ 'initArchive': { asyncResult: true },
+ 'create': { asyncResult: true },
+ 'update': { asyncResult: true },
+ 'archive': { asyncResult: true },
+ 'revive': { asyncResult: true }
});
-FeatureToggleActions.init.listen(function(){
+FeatureToggleActions.init.listen(function() {
Server.getFeatures(function(error, features) {
- if(error) {
- this.failed(error);
- } else {
- this.completed(features);
- }
+ if (error) {
+ this.failed(error);
+ } else {
+ this.completed(features);
+ }
}.bind(this));
});
-FeatureToggleActions.initArchive.listen(function(){
+FeatureToggleActions.initArchive.listen(function() {
Server.getArchivedFeatures(function(error, archivedToggles) {
- if(error) {
- this.failed(error);
- } else {
- this.completed(archivedToggles);
- }
+ if (error) {
+ this.failed(error);
+ } else {
+ this.completed(archivedToggles);
+ }
}.bind(this));
});
-FeatureToggleActions.create.listen(function(feature){
+FeatureToggleActions.create.listen(function(feature) {
Server.createFeature(feature, function(error) {
- if(error) {
- this.failed(error);
- } else {
- this.completed(feature);
- }
+ if (error) {
+ this.failed(error);
+ } else {
+ this.completed(feature);
+ }
}.bind(this));
});
-FeatureToggleActions.update.listen(function(feature){
+FeatureToggleActions.update.listen(function(feature) {
Server.updateFeature(feature, function(error) {
- if(error) {
- this.failed(error);
- } else {
- this.completed(feature);
- }
+ if (error) {
+ this.failed(error);
+ } else {
+ this.completed(feature);
+ }
}.bind(this));
});
-FeatureToggleActions.archive.listen(function(feature){
+FeatureToggleActions.archive.listen(function(feature) {
Server.archiveFeature(feature, function(error) {
- if(error) {
- this.failed(error);
- } else {
- this.completed(feature);
- }
+ if (error) {
+ this.failed(error);
+ } else {
+ this.completed(feature);
+ }
}.bind(this));
});
-FeatureToggleActions.revive.listen(function(feature){
+FeatureToggleActions.revive.listen(function(feature) {
Server.reviveFeature(feature, function(error) {
- if(error) {
- this.failed(error);
- } else {
- this.completed(feature);
- }
+ if (error) {
+ this.failed(error);
+ } else {
+ this.completed(feature);
+ }
}.bind(this));
});
diff --git a/public/js/stores/FeatureToggleServerFacade.js b/public/js/stores/FeatureToggleServerFacade.js
index 20b2452b20..69a438f630 100644
--- a/public/js/stores/FeatureToggleServerFacade.js
+++ b/public/js/stores/FeatureToggleServerFacade.js
@@ -12,10 +12,10 @@ var FeatureToggleServerFacade = {
contentType: CONTENT_TYPE,
data: JSON.stringify(feature),
error: function(error) {
- cb(error);
+ cb(error);
},
success: function() {
- cb();
+ cb();
}
});
},
@@ -28,10 +28,10 @@ var FeatureToggleServerFacade = {
contentType: CONTENT_TYPE,
data: JSON.stringify(feature),
error: function(error) {
- cb(error);
+ cb(error);
},
success: function() {
- cb();
+ cb();
}
});
},
@@ -42,10 +42,10 @@ var FeatureToggleServerFacade = {
method: 'delete',
type: TYPE,
error: function(error) {
- cb(error);
+ cb(error);
},
success: function() {
- cb();
+ cb();
}
});
},
@@ -56,10 +56,10 @@ var FeatureToggleServerFacade = {
method: 'get',
type: TYPE,
error: function(error) {
- cb(error);
+ cb(error);
},
success: function(data) {
- cb(null, data.features);
+ cb(null, data.features);
}
});
},
@@ -70,10 +70,10 @@ var FeatureToggleServerFacade = {
method: 'get',
type: TYPE,
error: function(error) {
- cb(error);
+ cb(error);
},
success: function(data) {
- cb(null, data.features);
+ cb(null, data.features);
}
});
},
@@ -86,10 +86,10 @@ var FeatureToggleServerFacade = {
contentType: CONTENT_TYPE,
data: JSON.stringify(feature),
error: function(error) {
- cb(error);
+ cb(error);
},
success: function() {
- cb();
+ cb();
}
});
}
diff --git a/public/js/stores/FeatureToggleStore.js b/public/js/stores/FeatureToggleStore.js
index 383e0a5274..6499643ee7 100644
--- a/public/js/stores/FeatureToggleStore.js
+++ b/public/js/stores/FeatureToggleStore.js
@@ -9,49 +9,49 @@ var _featureToggles = [];
var FeatureStore = Reflux.createStore({
// Initial setup
- init: function() {
- this.listenTo(FeatureActions.init.completed, this.setToggles);
- this.listenTo(FeatureActions.create.completed, this.onCreate);
- this.listenTo(FeatureActions.update.completed, this.onUpdate);
- this.listenTo(FeatureActions.archive.completed, this.onArchive);
- this.listenTo(FeatureActions.revive.completed, this.onRevive);
- },
+ init: function() {
+ this.listenTo(FeatureActions.init.completed, this.setToggles);
+ this.listenTo(FeatureActions.create.completed, this.onCreate);
+ this.listenTo(FeatureActions.update.completed, this.onUpdate);
+ this.listenTo(FeatureActions.archive.completed, this.onArchive);
+ this.listenTo(FeatureActions.revive.completed, this.onRevive);
+ },
- onCreate: function(feature) {
- this.setToggles([feature].concat(_featureToggles));
- },
+ onCreate: function(feature) {
+ this.setToggles([feature].concat(_featureToggles));
+ },
- setToggles: function(toggles) {
- _featureToggles = sortBy(toggles, 'name');
- this.trigger();
- },
+ setToggles: function(toggles) {
+ _featureToggles = sortBy(toggles, 'name');
+ this.trigger();
+ },
- onUpdate: function(feature) {
- var idx = findIndex(_featureToggles, 'name', feature.name);
- _featureToggles[idx] = feature;
- this.trigger();
- },
+ onUpdate: function(feature) {
+ var idx = findIndex(_featureToggles, 'name', feature.name);
+ _featureToggles[idx] = feature;
+ this.trigger();
+ },
- onArchive: function(feature) {
- var featureToggles = filter(_featureToggles, function(item) {
- return item.name !== feature.name;
- });
- this.setToggles(featureToggles);
- this.trigger();
- },
+ onArchive: function(feature) {
+ var featureToggles = filter(_featureToggles, function(item) {
+ return item.name !== feature.name;
+ });
+ this.setToggles(featureToggles);
+ this.trigger();
+ },
- onRevive: function(item) {
- this.setToggles(_featureToggles.concat([item]));
- this.trigger();
- },
+ onRevive: function(item) {
+ this.setToggles(_featureToggles.concat([item]));
+ this.trigger();
+ },
- getFeatureToggles: function() {
- return _featureToggles;
- },
+ getFeatureToggles: function() {
+ return _featureToggles;
+ },
- initStore: function(toggles) {
- _featureToggles = toggles;
- }
+ initStore: function(toggles) {
+ _featureToggles = toggles;
+ }
});
module.exports = FeatureStore;
diff --git a/public/js/stores/StrategyAPI.js b/public/js/stores/StrategyAPI.js
index 9ddbcb5ca8..41c0e811f5 100644
--- a/public/js/stores/StrategyAPI.js
+++ b/public/js/stores/StrategyAPI.js
@@ -12,10 +12,10 @@ var StrategyAPI = {
contentType: CONTENT_TYPE,
data: JSON.stringify(strategy),
error: function(error) {
- cb(error);
+ cb(error);
},
success: function() {
- cb(null, strategy);
+ cb(null, strategy);
}
});
},
@@ -26,10 +26,10 @@ var StrategyAPI = {
method: 'delete',
type: TYPE,
error: function(error) {
- cb(error);
+ cb(error);
},
success: function() {
- cb(null, strategy);
+ cb(null, strategy);
}
});
},
@@ -40,10 +40,10 @@ var StrategyAPI = {
method: 'get',
type: TYPE,
error: function(error) {
- cb(error);
+ cb(error);
},
success: function(data) {
- cb(null, data.strategies);
+ cb(null, data.strategies);
}
});
}
diff --git a/public/js/stores/StrategyActions.js b/public/js/stores/StrategyActions.js
index aa135cf1f1..0c95b3f1a7 100644
--- a/public/js/stores/StrategyActions.js
+++ b/public/js/stores/StrategyActions.js
@@ -2,14 +2,14 @@ var Reflux = require("reflux");
var StrategyAPI = require('./StrategyAPI');
var StrategyActions = Reflux.createActions({
- 'init': { asyncResult: true },
- 'create': { asyncResult: true },
- 'remove': { asyncResult: true },
+ 'init': { asyncResult: true },
+ 'create': { asyncResult: true },
+ 'remove': { asyncResult: true },
});
-StrategyActions.init.listen(function(){
+StrategyActions.init.listen(function() {
StrategyAPI.getStrategies(function(err, strategies) {
- if(err) {
+ if (err) {
this.failed(err);
} else {
this.completed(strategies);
@@ -17,9 +17,9 @@ StrategyActions.init.listen(function(){
}.bind(this));
});
-StrategyActions.create.listen(function(feature){
+StrategyActions.create.listen(function(feature) {
StrategyAPI.createStrategy(feature, function(err) {
- if(err) {
+ if (err) {
this.failed(err);
} else {
this.completed(feature);
@@ -27,9 +27,9 @@ StrategyActions.create.listen(function(feature){
}.bind(this));
});
-StrategyActions.remove.listen(function(feature){
+StrategyActions.remove.listen(function(feature) {
StrategyAPI.removeStrategy(feature, function(err) {
- if(err) {
+ if (err) {
this.failed(err);
} else {
this.completed(feature);
diff --git a/public/js/stores/UserStore.js b/public/js/stores/UserStore.js
index 93421e2660..03cff88f27 100644
--- a/public/js/stores/UserStore.js
+++ b/public/js/stores/UserStore.js
@@ -1,16 +1,16 @@
var _username;
-//Ref: http://stackoverflow.com/questions/10730362/get-cookie-by-name
+// Ref: http://stackoverflow.com/questions/10730362/get-cookie-by-name
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
- for(var i=0;i < ca.length;i++) {
+ for (var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
- c = c.substring(1,c.length);
+ c = c.substring(1, c.length);
}
if (c.indexOf(nameEQ) === 0) {
- return c.substring(nameEQ.length,c.length);
+ return c.substring(nameEQ.length, c.length);
}
}
return null;
@@ -18,16 +18,16 @@ function readCookie(name) {
var UserStore = {
init: function init() {
- _username = readCookie("username");
+ _username = readCookie("username");
},
set: function set(username) {
- _username=username;
- document.cookie="username="+_username+"; expires=Thu, 18 Dec 2099 12:00:00 UTC";
+ _username=username;
+ document.cookie="username="+_username+"; expires=Thu, 18 Dec 2099 12:00:00 UTC";
},
get: function get() {
- return _username;
+ return _username;
}
};
diff --git a/public/js/utils/Timer.js b/public/js/utils/Timer.js
index 162e4d77e7..c723e50d6f 100644
--- a/public/js/utils/Timer.js
+++ b/public/js/utils/Timer.js
@@ -24,4 +24,4 @@ Timer.prototype.stop = function() {
}
};
-module.exports = Timer;
\ No newline at end of file
+module.exports = Timer;
diff --git a/scripts/generate-liquibase-artifact.js b/scripts/generate-liquibase-artifact.js
index b1affd6a9f..fd29d3f9a5 100755
--- a/scripts/generate-liquibase-artifact.js
+++ b/scripts/generate-liquibase-artifact.js
@@ -20,7 +20,9 @@ changeLog.att('xsi:schemaLocation',
'http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd');
fs.readdir(sqlRoot, function (err, files) {
- if (err) { throw err; }
+ if (err) {
+ throw err;
+ }
var changes = {};
@@ -37,23 +39,23 @@ fs.readdir(sqlRoot, function (err, files) {
var direction = match[2];
changes[name] = changes[name] || {};
- changes[name][direction] = fs.readFileSync(path.resolve(sqlRoot, sqlFile), {encoding: encoding});
+ changes[name][direction] = fs.readFileSync(path.resolve(sqlRoot, sqlFile), { encoding: encoding });
});
Object.keys(changes).forEach(function (name) {
var change = changes[name];
- var el = changeLog.ele('changeSet', {id: name, author: 'unleash'});
+ var el = changeLog.ele('changeSet', { id: name, author: 'unleash' });
el.ele('sql', {}, change.up);
el.ele('rollback', {}, change.down);
});
- util.puts(changeLog.end({pretty: true}));
+ util.puts(changeLog.end({ pretty: true }));
});
function initialInit(changes) {
changes["init-prepare"] = {};
- changes["init-prepare"]["up"] = fs.readFileSync(path.resolve(__dirname, './init.up.sql'), {encoding: encoding});
- changes["init-prepare"]["down"] = fs.readFileSync(path.resolve(__dirname, './init.down.sql'), {encoding: encoding});
+ changes["init-prepare"]["up"] = fs.readFileSync(path.resolve(__dirname, './init.up.sql'), { encoding: encoding });
+ changes["init-prepare"]["down"] = fs.readFileSync(path.resolve(__dirname, './init.down.sql'), { encoding: encoding });
}
diff --git a/test/.eslintrc b/test/.eslintrc
new file mode 100644
index 0000000000..57f8cbb6a3
--- /dev/null
+++ b/test/.eslintrc
@@ -0,0 +1,20 @@
+{
+ "extends": [
+ "spt",
+ "spt/env-node",
+ "spt/env-es6-false"
+ ],
+ "env": {
+ "browser": true
+ },
+ "globals": {
+ "it": false,
+ "beforeEach": false,
+ "describe": false
+ },
+ "rules": {
+ "quotes": 0,
+ "vars-on-top": 0,
+ "max-nested-callbacks": 0
+ }
+}
\ No newline at end of file
diff --git a/test/eventApiSpec.js b/test/eventApiSpec.js
index 76baa50d68..ceebaa23d4 100644
--- a/test/eventApiSpec.js
+++ b/test/eventApiSpec.js
@@ -1,3 +1,4 @@
+'use strict';
var request = require('./specHelper').request;
describe('The event api', function () {
@@ -14,5 +15,4 @@ describe('The event api', function () {
.expect('Content-Type', /json/)
.expect(200, done);
});
-
-});
\ No newline at end of file
+});
diff --git a/test/eventDifferTest.js b/test/eventDifferTest.js
index b00603474f..e85b62b8c9 100644
--- a/test/eventDifferTest.js
+++ b/test/eventDifferTest.js
@@ -1,3 +1,4 @@
+'use strict';
var eventDiffer = require('../lib/eventDiffer');
var eventType = require('../lib/eventType');
var assert = require('assert');
@@ -5,8 +6,8 @@ var assert = require('assert');
describe('eventDiffer', function () {
it('fails if events include an unknown event type', function () {
var events = [
- {type: eventType.featureCreated, data: {}},
- {type: 'unknown-type', data: {}}
+ { type: eventType.featureCreated, data: {} },
+ { type: 'unknown-type', data: {} }
];
assert.throws(function () {
@@ -21,19 +22,19 @@ describe('eventDiffer', function () {
var events = [
{
type: eventType.featureUpdated,
- data: {name: name, description: desc, strategy: 'default', enabled: true, parameters: {value: 2 }}
+ data: { name: name, description: desc, strategy: 'default', enabled: true, parameters: { value: 2 } }
},
{
type: eventType.featureCreated,
- data: {name: name, description: desc, strategy: 'default', enabled: false, parameters: {value: 1}}
+ data: { name: name, description: desc, strategy: 'default', enabled: false, parameters: { value: 1 } }
}
];
eventDiffer.addDiffs(events);
assert.deepEqual(events[0].diffs, [
- {kind: 'E', path: ["enabled"], lhs: false, rhs: true},
- {kind: 'E', path: ["parameters", "value"], lhs: 1, rhs: 2}
+ { kind: 'E', path: ["enabled"], lhs: false, rhs: true },
+ { kind: 'E', path: ["parameters", "value"], lhs: 1, rhs: 2 }
]);
assert.strictEqual(events[1].diffs, null);
@@ -43,19 +44,19 @@ describe('eventDiffer', function () {
var events = [
{
type: eventType.featureUpdated,
- data: {name: 'bar', description: 'desc', strategy: 'default', enabled: true, parameters: {}}
+ data: { name: 'bar', description: 'desc', strategy: 'default', enabled: true, parameters: {} }
},
{
type: eventType.featureUpdated,
- data: {name: 'foo', description: 'desc', strategy: 'default', enabled: false, parameters: {}}
+ data: { name: 'foo', description: 'desc', strategy: 'default', enabled: false, parameters: {} }
},
{
type: eventType.featureCreated,
- data: {name: 'bar', description: 'desc', strategy: 'default', enabled: false, parameters: {}}
+ data: { name: 'bar', description: 'desc', strategy: 'default', enabled: false, parameters: {} }
},
{
type: eventType.featureCreated,
- data: {name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {}}
+ data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} }
}
];
@@ -71,11 +72,11 @@ describe('eventDiffer', function () {
var events = [
{
type: eventType.featureUpdated,
- data: {name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {}}
+ data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} }
},
{
type: eventType.featureCreated,
- data: {name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {}}
+ data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} }
}
];
@@ -87,11 +88,11 @@ describe('eventDiffer', function () {
var events = [
{
type: eventType.featureUpdated,
- data: {name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {}}
+ data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} }
}
];
eventDiffer.addDiffs(events);
assert.strictEqual(events[0].diffs, null);
});
-});
\ No newline at end of file
+});
diff --git a/test/featureApiSpec.js b/test/featureApiSpec.js
index 931eba6bf5..39d473429d 100644
--- a/test/featureApiSpec.js
+++ b/test/featureApiSpec.js
@@ -1,7 +1,10 @@
+'use strict';
var assert = require('assert');
var specHelper = require('./specHelper');
var request = specHelper.request;
-var stringify = function (o) { return JSON.stringify(o, null, ' '); };
+var stringify = function (o) {
+ return JSON.stringify(o, null, ' ');
+};
describe('The features api', function () {
beforeEach(function (done) {
@@ -38,7 +41,7 @@ describe('The features api', function () {
it('creates new feature toggle', function (done) {
request
.post('/features')
- .send({name: 'com.test.feature', enabled: false})
+ .send({ name: 'com.test.feature', enabled: false })
.set('Content-Type', 'application/json')
.expect(201, done);
});
@@ -46,23 +49,23 @@ describe('The features api', function () {
it('creates new feature toggle with createdBy', function (done) {
request
.post('/features')
- .send({name: 'com.test.Username', enabled: false})
+ .send({ name: 'com.test.Username', enabled: false })
.set('Cookie', ['username=ivaosthu'])
.set('Content-Type', 'application/json')
- .end(function(){
- request
- .get('/events')
- .end(function (err, res) {
- assert.equal(res.body.events[0].createdBy, 'ivaosthu');
- done();
- });
+ .end(function() {
+ request
+ .get('/events')
+ .end(function (err, res) {
+ assert.equal(res.body.events[0].createdBy, 'ivaosthu');
+ done();
+ });
});
});
it('require new feature toggle to have a name', function (done) {
request
.post('/features')
- .send({name: ''})
+ .send({ name: '' })
.set('Content-Type', 'application/json')
.expect(400, done);
});
@@ -70,7 +73,7 @@ describe('The features api', function () {
it('can not change status of feature toggle that does not exist', function (done) {
request
.put('/features/should-not-exist')
- .send({name: 'should-not-exist', enabled: false})
+ .send({ name: 'should-not-exist', enabled: false })
.set('Content-Type', 'application/json')
.expect(404, done);
});
@@ -78,7 +81,7 @@ describe('The features api', function () {
it('can change status of feature toggle that does exist', function (done) {
request
.put('/features/featureY')
- .send({name: 'featureY', enabled: true})
+ .send({ name: 'featureY', enabled: true })
.set('Content-Type', 'application/json')
.expect(200, done);
});
@@ -98,9 +101,8 @@ describe('The features api', function () {
it('refuses to create a feature with an existing name', function (done) {
request
.post('/features')
- .send({name: 'featureX'})
+ .send({ name: 'featureX' })
.set('Content-Type', 'application/json')
.expect(403, done);
});
-
});
diff --git a/test/featureArchiveApiSpec.js b/test/featureArchiveApiSpec.js
index cb4e637d86..cc1af0b493 100644
--- a/test/featureArchiveApiSpec.js
+++ b/test/featureArchiveApiSpec.js
@@ -1,7 +1,10 @@
+'use strict';
var assert = require('assert');
var specHelper = require('./specHelper');
var request = specHelper.request;
-var stringify = function (o) { return JSON.stringify(o, null, ' '); };
+var stringify = function (o) {
+ return JSON.stringify(o, null, ' ');
+};
describe('The archive features api', function () {
beforeEach(function (done) {
@@ -24,7 +27,7 @@ describe('The archive features api', function () {
it('revives a feature by name', function (done) {
request
.post('/archive/revive')
- .send({name: 'featureArchivedX'})
+ .send({ name: 'featureArchivedX' })
.set('Content-Type', 'application/json')
.expect(200, done);
});
@@ -34,5 +37,4 @@ describe('The archive features api', function () {
.post('/archive/revive')
.expect(400, done);
});
-
-});
\ No newline at end of file
+});
diff --git a/test/routerSpec.js b/test/routerSpec.js
index d66e897c65..13c1e8e9e3 100644
--- a/test/routerSpec.js
+++ b/test/routerSpec.js
@@ -1,8 +1,8 @@
+'use strict';
var specHelper = require('./specHelper');
var request = specHelper.request;
describe('The routes', function () {
-
describe('healthcheck', function () {
it('returns health good', function (done) {
request.get('/health')
@@ -11,5 +11,4 @@ describe('The routes', function () {
.expect('{"health":"GOOD"}', done);
});
});
-
-});
\ No newline at end of file
+});
diff --git a/test/specHelper.js b/test/specHelper.js
index f91a36a1f1..a7f23cf8fc 100644
--- a/test/specHelper.js
+++ b/test/specHelper.js
@@ -1,3 +1,4 @@
+'use strict';
process.env.NODE_ENV = 'test';
var Promise = require('bluebird');
@@ -23,7 +24,9 @@ function createStrategies() {
emails: "String"
}
}
- ], function (strategy) { return strategyDb._createStrategy(strategy); });
+ ], function (strategy) {
+ return strategyDb._createStrategy(strategy);
+ });
}
function createFeatures() {
@@ -79,7 +82,9 @@ function createFeatures() {
"foo": "rab"
}
}
- ], function (feature) { return featureDb._createFeature(feature); });
+ ], function (feature) {
+ return featureDb._createFeature(feature);
+ });
}
function destroyStrategies() {
@@ -103,6 +108,8 @@ module.exports = {
db: {
reset: resetDatabase,
setup: setupDatabase,
- resetAndSetup: function () { return resetDatabase().then(setupDatabase); }
+ resetAndSetup: function () {
+ return resetDatabase().then(setupDatabase);
+ }
}
-};
\ No newline at end of file
+};
diff --git a/test/strategyApiSpec.js b/test/strategyApiSpec.js
index 7882ec64d5..7a742d58ec 100644
--- a/test/strategyApiSpec.js
+++ b/test/strategyApiSpec.js
@@ -1,3 +1,4 @@
+'use strict';
var specHelper = require('./specHelper');
var request = specHelper.request;
@@ -32,7 +33,7 @@ describe('The strategy api', function () {
it('creates a new strategy', function (done) {
request
.post('/strategies')
- .send({name: 'myCustomStrategy', description: 'Best strategy ever.'})
+ .send({ name: 'myCustomStrategy', description: 'Best strategy ever.' })
.set('Content-Type', 'application/json')
.expect(201, done);
});
@@ -40,7 +41,7 @@ describe('The strategy api', function () {
it('requires new strategies to have a name', function (done) {
request
.post('/strategies')
- .send({name: ''})
+ .send({ name: '' })
.set('Content-Type', 'application/json')
.expect(400, done);
});
@@ -48,7 +49,7 @@ describe('The strategy api', function () {
it('refuses to create a strategy with an existing name', function (done) {
request
.post('/strategies')
- .send({name: 'default'})
+ .send({ name: 'default' })
.set('Content-Type', 'application/json')
.expect(403, done);
});
@@ -64,5 +65,4 @@ describe('The strategy api', function () {
.delete('/strategies/unknown')
.expect(404, done);
});
-
-});
\ No newline at end of file
+});
diff --git a/webpack.config.js b/webpack.config.js
index efbae1e6d8..1859024655 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -2,21 +2,21 @@
var path = require('path');
var root = path.normalize(path.join(__dirname, '.'));
-var js_root = path.join(path.join(root, 'public'), 'js');
+var jsroot = path.join(path.join(root, 'public'), 'js');
module.exports = {
- context: js_root,
+ context: jsroot,
entry: 'app',
output: {
- path: js_root,
+ path: jsroot,
filename: 'bundle.js',
publicPath: '/js/'
},
resolve: {
- root: [js_root],
+ root: [jsroot],
extensions: ['', '.js', '.jsx'],
modulesDirectories: ["web_modules", "node_modules"]
},