diff --git a/packages/unleash-api/app.js b/packages/unleash-api/app.js index f8733969d5..cc3da3642c 100644 --- a/packages/unleash-api/app.js +++ b/packages/unleash-api/app.js @@ -32,7 +32,7 @@ module.exports = function(config) { app.use(bodyParser.json({ strict: false })); app.use(log4js.connectLogger(logger, { format: ':remote-addr :status :method :url :response-timems', - level: 'auto' // 3XX=WARN, 4xx/5xx=ERROR + level: 'auto', // 3XX=WARN, 4xx/5xx=ERROR })); // Setup API routes diff --git a/packages/unleash-api/lib/db/dbPool.js b/packages/unleash-api/lib/db/dbPool.js index dd376dfd66..761657c71b 100644 --- a/packages/unleash-api/lib/db/dbPool.js +++ b/packages/unleash-api/lib/db/dbPool.js @@ -5,6 +5,6 @@ module.exports = function(databaseConnection) { return knex({ client: 'pg', connection: databaseConnection, - pool: { min: 2, max: 20 } + pool: { min: 2, max: 20 }, }); }; diff --git a/packages/unleash-api/lib/db/event.js b/packages/unleash-api/lib/db/event.js index 147f9c25c7..8196d1cb89 100644 --- a/packages/unleash-api/lib/db/event.js +++ b/packages/unleash-api/lib/db/event.js @@ -6,7 +6,7 @@ module.exports = function(db) { return db('events').insert({ type: event.type, created_by: event.createdBy, // eslint-disable-line - data: event.data + data: event.data, }); } @@ -22,7 +22,7 @@ module.exports = function(db) { return db .select(EVENT_COLUMNS) .from('events') - .whereRaw("data ->> 'name' = ?", [name]) + .whereRaw('data ->> \'name\' = ?', [name]) .orderBy('created_at', 'desc') .map(rowToEvent); } @@ -33,14 +33,14 @@ module.exports = function(db) { type: row.type, createdBy: row.created_by, createdAt: row.created_at, - data: row.data + data: row.data, }; } return { store: storeEvent, getEvents, - getEventsFilterByName + getEventsFilterByName, }; }; diff --git a/packages/unleash-api/lib/db/feature.js b/packages/unleash-api/lib/db/feature.js index 4df93d3f9b..2de1185ca9 100644 --- a/packages/unleash-api/lib/db/feature.js +++ b/packages/unleash-api/lib/db/feature.js @@ -50,7 +50,7 @@ module.exports = function(db, eventStore) { description: row.description, enabled: row.enabled > 0, strategy: row.strategy_name, // eslint-disable-line - parameters: row.parameters + parameters: row.parameters, }; } @@ -61,7 +61,7 @@ module.exports = function(db, eventStore) { enabled: data.enabled ? 1 : 0, archived: data.archived ? 1 :0, strategy_name: data.strategy, // eslint-disable-line - parameters: data.parameters + parameters: data.parameters, }; } @@ -106,6 +106,6 @@ module.exports = function(db, eventStore) { getFeature, getArchivedFeatures, _createFeature: createFeature, // visible for testing - _updateFeature: updateFeature // visible for testing + _updateFeature: updateFeature, // visible for testing }; }; diff --git a/packages/unleash-api/lib/db/strategy.js b/packages/unleash-api/lib/db/strategy.js index 7aeebf7cd7..5fafe7fd6e 100644 --- a/packages/unleash-api/lib/db/strategy.js +++ b/packages/unleash-api/lib/db/strategy.js @@ -40,7 +40,7 @@ module.exports = function(db, eventStore) { return { name: row.name, description: row.description, - parametersTemplate: row.parameters_template + parametersTemplate: row.parameters_template, }; } @@ -63,7 +63,7 @@ module.exports = function(db, eventStore) { return { getStrategies, getStrategy, - _createStrategy: createStrategy // visible for testing + _createStrategy: createStrategy, // visible for testing }; }; diff --git a/packages/unleash-api/lib/error/validateRequest.js b/packages/unleash-api/lib/error/validateRequest.js index 990fd7f659..a09691b309 100644 --- a/packages/unleash-api/lib/error/validateRequest.js +++ b/packages/unleash-api/lib/error/validateRequest.js @@ -1,11 +1,11 @@ 'use strict'; -const Promise = require("bluebird"); +const Promise = require('bluebird'); const ValidationError = require('./ValidationError'); function validateRequest(req) { return new Promise((resolve, reject) => { if (req.validationErrors()) { - reject(new ValidationError("Invalid syntax")); + reject(new ValidationError('Invalid syntax')); } else { resolve(req); } diff --git a/packages/unleash-api/lib/eventDiffer.js b/packages/unleash-api/lib/eventDiffer.js index 6364399151..91fd9ddcd4 100644 --- a/packages/unleash-api/lib/eventDiffer.js +++ b/packages/unleash-api/lib/eventDiffer.js @@ -4,14 +4,14 @@ const diff = require('deep-diff').diff; const strategyTypes = [ eventType.strategyCreated, - eventType.strategyDeleted + eventType.strategyDeleted, ]; const featureTypes = [ eventType.featureCreated, eventType.featureUpdated, eventType.featureArchived, - eventType.featureRevived + eventType.featureRevived, ]; function baseTypeFor(event) { @@ -74,5 +74,5 @@ function addDiffs(events) { module.exports = { - addDiffs + addDiffs, }; diff --git a/packages/unleash-api/lib/eventType.js b/packages/unleash-api/lib/eventType.js index 1c2aee856e..267405c64b 100644 --- a/packages/unleash-api/lib/eventType.js +++ b/packages/unleash-api/lib/eventType.js @@ -5,5 +5,5 @@ module.exports = { featureArchived: 'feature-archived', featureRevived: 'feature-revived', strategyCreated: 'strategy-created', - strategyDeleted: 'strategy-deleted' + strategyDeleted: 'strategy-deleted', }; diff --git a/packages/unleash-api/lib/extractUser.js b/packages/unleash-api/lib/extractUser.js index 3471ac6093..69006970ad 100644 --- a/packages/unleash-api/lib/extractUser.js +++ b/packages/unleash-api/lib/extractUser.js @@ -1,5 +1,5 @@ 'use strict'; function extractUsername(req) { - return req.cookies.username || "unknown"; + return req.cookies.username || 'unknown'; } module.exports = extractUsername; diff --git a/packages/unleash-api/lib/routes/feature-archive.js b/packages/unleash-api/lib/routes/feature-archive.js index 873d03df15..33cc47e1f0 100644 --- a/packages/unleash-api/lib/routes/feature-archive.js +++ b/packages/unleash-api/lib/routes/feature-archive.js @@ -19,16 +19,16 @@ module.exports = function (app, config) { validateRequest(req) .then(() => eventStore.create({ - type: eventType.featureRevived, - createdBy: req.connection.remoteAddress, - data: req.body - })).then(() => { + type: eventType.featureRevived, + createdBy: req.connection.remoteAddress, + data: req.body, + })).then(() => { res.status(200).end(); }).catch(ValidationError, () => { res.status(400).json(req.validationErrors()); }) .catch(err => { - logger.error("Could not revive feature toggle", err); + logger.error('Could not revive feature toggle', err); res.status(500).end(); }); }); diff --git a/packages/unleash-api/lib/routes/feature.js b/packages/unleash-api/lib/routes/feature.js index acd028f5dd..508aa5fc53 100644 --- a/packages/unleash-api/lib/routes/feature.js +++ b/packages/unleash-api/lib/routes/feature.js @@ -1,5 +1,5 @@ 'use strict'; -const Promise = require("bluebird"); +const Promise = require('bluebird'); const logger = require('../logger'); const eventType = require('../eventType'); const NameExistsError = require('../error/NameExistsError'); @@ -35,23 +35,23 @@ module.exports = function (app, config) { validateRequest(req) .then(validateUniqueName) .then(() => eventStore.create({ - type: eventType.featureCreated, - createdBy: extractUser(req), - data: req.body - })) + type: eventType.featureCreated, + createdBy: extractUser(req), + data: req.body, + })) .then(() => { res.status(201).end(); }) .catch(NameExistsError, () => { res.status(403).json([{ - msg: `A feature named '${req.body.name}' already exists. It could be archived.` + msg: `A feature named '${req.body.name}' already exists. It could be archived.`, }]).end(); }) .catch(ValidationError, () => { res.status(400).json(req.validationErrors()); }) .catch(err => { - logger.error("Could not create feature toggle", err); + logger.error('Could not create feature toggle', err); res.status(500).end(); }); }); @@ -65,10 +65,10 @@ module.exports = function (app, config) { featureDb.getFeature(featureName) .then(() => eventStore.create({ - type: eventType.featureUpdated, - createdBy: userName, - data: updatedFeature - })) + type: eventType.featureUpdated, + createdBy: userName, + data: updatedFeature, + })) .then(() => { res.status(200).end(); }) @@ -87,12 +87,12 @@ module.exports = function (app, config) { featureDb.getFeature(featureName) .then(() => eventStore.create({ - type: eventType.featureArchived, - createdBy: userName, - data: { - name: featureName - } - })) + type: eventType.featureArchived, + createdBy: userName, + data: { + name: featureName, + }, + })) .then(() => { res.status(200).end(); }) @@ -109,7 +109,7 @@ module.exports = function (app, config) { return new Promise((resolve, reject) => { featureDb.getFeature(req.body.name) .then(() => { - reject(new NameExistsError("Feature name already exist")); + reject(new NameExistsError('Feature name already exist')); }, () => { resolve(req); }); diff --git a/packages/unleash-api/lib/routes/strategy.js b/packages/unleash-api/lib/routes/strategy.js index 4ea217ddcc..ec9abd5b0b 100644 --- a/packages/unleash-api/lib/routes/strategy.js +++ b/packages/unleash-api/lib/routes/strategy.js @@ -1,5 +1,5 @@ 'use strict'; -const Promise = require("bluebird"); +const Promise = require('bluebird'); const eventType = require('../eventType'); const logger = require('../logger'); const NameExistsError = require('../error/NameExistsError'); @@ -33,12 +33,12 @@ module.exports = function (app, config) { strategyDb.getStrategy(strategyName) .then(() => eventStore.create({ - type: eventType.strategyDeleted, - createdBy: extractUser(req), - data: { - name: strategyName - } - })) + type: eventType.strategyDeleted, + createdBy: extractUser(req), + data: { + name: strategyName, + }, + })) .then(() => { res.status(200).end(); }) @@ -60,10 +60,10 @@ module.exports = function (app, config) { validateRequest(req) .then(validateStrategyName) .then(() => eventStore.create({ - type: eventType.strategyCreated, - createdBy: extractUser(req), - data: newStrategy - })) + type: eventType.strategyCreated, + createdBy: extractUser(req), + data: newStrategy, + })) .then(() => { res.status(201).end(); }) @@ -74,7 +74,7 @@ module.exports = function (app, config) { res.status(400).json(req.validationErrors()); }) .catch(err => { - logger.error("Could not create strategy", err); + logger.error('Could not create strategy', err); res.status(500).end(); }); }); @@ -83,7 +83,7 @@ module.exports = function (app, config) { return new Promise((resolve, reject) => { strategyDb.getStrategy(req.body.name) .then(() => { - reject(new NameExistsError("Feature name already exist")); + reject(new NameExistsError('Feature name already exist')); }, () => { resolve(req); }); diff --git a/packages/unleash-api/scripts/migration-runner.js b/packages/unleash-api/scripts/migration-runner.js index d4594251ac..3696e5b6e4 100644 --- a/packages/unleash-api/scripts/migration-runner.js +++ b/packages/unleash-api/scripts/migration-runner.js @@ -13,7 +13,7 @@ module.exports = { return { up: runMigration.bind(null, util.format(format, name, 'up')), - down: runMigration.bind(null, util.format(format, name, 'down')) + down: runMigration.bind(null, util.format(format, name, 'down')), }; - } + }, }; diff --git a/packages/unleash-api/server-impl.js b/packages/unleash-api/server-impl.js index 35e4d2a0ff..d06e6f3acd 100644 --- a/packages/unleash-api/server-impl.js +++ b/packages/unleash-api/server-impl.js @@ -21,7 +21,7 @@ function start(options) { eventStore, featureDb, strategyDb, - publicFolder: options.publicFolder + publicFolder: options.publicFolder, }; const app = require('./app')(config); @@ -33,7 +33,7 @@ function start(options) { return { app, server, - config + config, }; } @@ -43,5 +43,5 @@ process.on('uncaughtException', err => { }); module.exports = { - start + start, }; diff --git a/packages/unleash-api/test/databaseConfig.js b/packages/unleash-api/test/databaseConfig.js index 2f4ecc03e7..430438fe87 100644 --- a/packages/unleash-api/test/databaseConfig.js +++ b/packages/unleash-api/test/databaseConfig.js @@ -7,5 +7,5 @@ function getDatabaseUri() { } } module.exports = { - getDatabaseUri + getDatabaseUri, }; diff --git a/packages/unleash-api/test/eventDifferTest.js b/packages/unleash-api/test/eventDifferTest.js index e0bd5e9dc0..9d13c954b2 100644 --- a/packages/unleash-api/test/eventDifferTest.js +++ b/packages/unleash-api/test/eventDifferTest.js @@ -7,7 +7,7 @@ describe('eventDiffer', () => { it('fails if events include an unknown event type', () => { const events = [ { type: eventType.featureCreated, data: {} }, - { type: 'unknown-type', data: {} } + { type: 'unknown-type', data: {} }, ]; assert.throws(() => { @@ -22,19 +22,19 @@ describe('eventDiffer', () => { const events = [ { type: eventType.featureUpdated, - data: { name, description: desc, strategy: 'default', enabled: true, parameters: { value: 2 } } + data: { name, description: desc, strategy: 'default', enabled: true, parameters: { value: 2 } }, }, { type: eventType.featureCreated, - data: { name, description: desc, strategy: 'default', enabled: false, parameters: { value: 1 } } - } + data: { 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); @@ -44,20 +44,20 @@ describe('eventDiffer', () => { const 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: {} }, + }, ]; eventDiffer.addDiffs(events); @@ -72,12 +72,12 @@ describe('eventDiffer', () => { const 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: {} }, + }, ]; eventDiffer.addDiffs(events); @@ -88,8 +88,8 @@ describe('eventDiffer', () => { const 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); diff --git a/packages/unleash-api/test/specHelper.js b/packages/unleash-api/test/specHelper.js index bcb61ee5e4..716e18da00 100644 --- a/packages/unleash-api/test/specHelper.js +++ b/packages/unleash-api/test/specHelper.js @@ -17,7 +17,7 @@ const app = require('../app')({ eventDb, eventStore, featureDb, - strategyDb + strategyDb, }); Promise.promisifyAll(request); @@ -26,73 +26,73 @@ request = request(app); function createStrategies() { return Promise.map([ { - name: "default", - description: "Default on or off Strategy.", - parametersTemplate: {} + name: 'default', + description: 'Default on or off Strategy.', + parametersTemplate: {}, }, { - name: "usersWithEmail", - description: "Active for users defined in the comma-separated emails-parameter.", + name: 'usersWithEmail', + description: 'Active for users defined in the comma-separated emails-parameter.', parametersTemplate: { - emails: "String" - } - } + emails: 'String', + }, + }, ], strategy => strategyDb._createStrategy(strategy)); } function createFeatures() { return Promise.map([ { - name: "featureX", - description: "the #1 feature", + name: 'featureX', + description: 'the #1 feature', enabled: true, - strategy: "default" + strategy: 'default', }, { - name: "featureY", - description: "soon to be the #1 feature", + name: 'featureY', + description: 'soon to be the #1 feature', enabled: false, - strategy: "baz", + strategy: 'baz', parameters: { - foo: "bar" - } + foo: 'bar', + }, }, { - name: "featureZ", - description: "terrible feature", + name: 'featureZ', + description: 'terrible feature', enabled: true, - strategy: "baz", + strategy: 'baz', parameters: { - foo: "rab" - } + foo: 'rab', + }, }, { - name: "featureArchivedX", - description: "the #1 feature", + name: 'featureArchivedX', + description: 'the #1 feature', enabled: true, archived: true, - strategy: "default" + strategy: 'default', }, { - name: "featureArchivedY", - description: "soon to be the #1 feature", + name: 'featureArchivedY', + description: 'soon to be the #1 feature', enabled: false, archived: true, - strategy: "baz", + strategy: 'baz', parameters: { - foo: "bar" - } + foo: 'bar', + }, }, { - name: "featureArchivedZ", - description: "terrible feature", + name: 'featureArchivedZ', + description: 'terrible feature', enabled: true, archived: true, - strategy: "baz", + strategy: 'baz', parameters: { - foo: "rab" - } - } + foo: 'rab', + }, + }, ], feature => featureDb._createFeature(feature)); } @@ -119,6 +119,6 @@ module.exports = { setup: setupDatabase, resetAndSetup() { return resetDatabase().then(setupDatabase); - } - } + }, + }, }; diff --git a/packages/unleash-frontend/jest-preprocessor.js b/packages/unleash-frontend/jest-preprocessor.js index 6379efc14b..d16cc2c3c9 100644 --- a/packages/unleash-frontend/jest-preprocessor.js +++ b/packages/unleash-frontend/jest-preprocessor.js @@ -5,5 +5,5 @@ const ReactTools = require('react-tools'); module.exports = { process(src) { return ReactTools.transform(src); - } + }, }; diff --git a/packages/unleash-frontend/lib/index.js b/packages/unleash-frontend/lib/index.js index 84cd000395..1a26e24151 100644 --- a/packages/unleash-frontend/lib/index.js +++ b/packages/unleash-frontend/lib/index.js @@ -2,5 +2,5 @@ const path = require('path'); module.exports = { - publicFolder: path.join(__dirname, '..', 'public') + publicFolder: path.join(__dirname, '..', 'public'), }; diff --git a/packages/unleash-frontend/lib/server-dev.js b/packages/unleash-frontend/lib/server-dev.js index 7f2a0855ba..f4e6106e3e 100644 --- a/packages/unleash-frontend/lib/server-dev.js +++ b/packages/unleash-frontend/lib/server-dev.js @@ -12,5 +12,5 @@ const compiler = webpack(webpackConfig); app.use(config.baseUriPath, webpackDevMiddleware(compiler, { publicPath: '/js', - noInfo: true + noInfo: true, })); diff --git a/packages/unleash-frontend/public/js/UnleashApp.jsx b/packages/unleash-frontend/public/js/UnleashApp.jsx index e0a85d9a12..5d0c42587c 100644 --- a/packages/unleash-frontend/public/js/UnleashApp.jsx +++ b/packages/unleash-frontend/public/js/UnleashApp.jsx @@ -12,32 +12,32 @@ const RouteHandler = Router.RouteHandler; const UnleashApp = React.createClass({ contextTypes: { - router: React.PropTypes.func + router: React.PropTypes.func, }, getInitialState() { return { - features: FeatureToggleStore.getFeatureToggles(), - strategies: StrategyStore.getStrategies(), - archivedFeatures: ArchiveStore.getArchivedToggles() + features: FeatureToggleStore.getFeatureToggles(), + strategies: StrategyStore.getStrategies(), + archivedFeatures: ArchiveStore.getArchivedToggles(), }; }, onFeatureToggleChange() { this.setState({ - features: FeatureToggleStore.getFeatureToggles() + features: FeatureToggleStore.getFeatureToggles(), }); }, onStrategiesChange() { this.setState({ - strategies: StrategyStore.getStrategies() + strategies: StrategyStore.getStrategies(), }); }, onArchiveChange() { this.setState({ - archivedFeatures: ArchiveStore.getArchivedToggles() + archivedFeatures: ArchiveStore.getArchivedToggles(), }); }, @@ -68,10 +68,10 @@ const UnleashApp = React.createClass({ return (