diff --git a/README.md b/README.md index fd0aa2d8bb..485ee8b4c9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,11 @@ __Warning: We are in the process of splitting up unleash into multiple packages in this repository, if you want to test the previous package see [previous tag](https://github.com/finn-no/unleash/tree/v1.0.0-alpha.2) __ -[![Build Status](https://travis-ci.org/finn-no/unleash.svg?branch=master)](https://travis-ci.org/finn-no/unleash) [![Code Climate](https://codeclimate.com/github/finn-no/unleash/badges/gpa.svg)](https://codeclimate.com/github/finn-no/unleash) [![Coverage Status](https://coveralls.io/repos/finn-no/unleash/badge.png?branch=master)](https://coveralls.io/r/finn-no/unleash?branch=master) [![Dependency Status](https://david-dm.org/finn-no/unleash.png)](https://david-dm.org/finn-no/unleash) [![devDependency Status](https://david-dm.org/finn-no/unleash/dev-status.png)](https://david-dm.org/finn-no/unleash#info=devD) +[![Build Status](https://travis-ci.org/finn-no/unleash.svg?branch=master)](https://travis-ci.org/finn-no/unleash) +[![Code Climate](https://codeclimate.com/github/finn-no/unleash/badges/gpa.svg)](https://codeclimate.com/github/finn-no/unleash) +[![Coverage Status](https://coveralls.io/repos/finn-no/unleash/badge.svg?branch=master)](https://coveralls.io/r/finn-no/unleash?branch=master) +[![Dependency Status](https://david-dm.org/finn-no/unleash.svg)](https://david-dm.org/finn-no/unleash) +[![devDependency Status](https://david-dm.org/finn-no/unleash/dev-status.svg)](https://david-dm.org/finn-no/unleash#info=devD) ![Admin UI](https://cloud.githubusercontent.com/assets/572/5873775/3ddc1a66-a2fa-11e4-923c-0a9569605dad.png) diff --git a/package.json b/package.json index 77e09f0d0c..61dea0b26f 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,11 @@ "engines": { "node": "6" }, + "license": "Apache-2.0", "scripts": { "bootstrap": "lerna bootstrap", "prepublish": "npm run bootstrap", - "lint": "node node_modules/eslint/bin/eslint.js packages --fix --ignore-pattern=node_modules --ext=js,jsx", + "lint": "eslint . --ext=js,jsx", "test": "npm run lint && lerna --concurrency=1 exec npm run test", "test:ci": "npm run lint && lerna --concurrency=1 exec npm run test:ci", "nsp": "lerna exec nsp check", @@ -33,8 +34,8 @@ }, "dependencies": {}, "devDependencies": { - "eslint": "^2.12.0", - "eslint-config-finn": "^1.0.0-alpha.4", + "eslint": "^2.13.1", + "eslint-config-finn": "1.0.0-alpha.8", "eslint-plugin-react": "^4.3.0", "lerna": "2.0.0-beta.20", "nsp": "^2.3.2" diff --git a/packages/unleash-api/lib/error/validateRequest.js b/packages/unleash-api/lib/error/validateRequest.js index ad2a21e528..921c5bed29 100644 --- a/packages/unleash-api/lib/error/validateRequest.js +++ b/packages/unleash-api/lib/error/validateRequest.js @@ -1,9 +1,9 @@ 'use strict'; -const Promise = require('bluebird'); +const BPromise = require('bluebird'); const ValidationError = require('./ValidationError'); function validateRequest (req) { - return new Promise((resolve, reject) => { + return new BPromise((resolve, reject) => { if (req.validationErrors()) { reject(new ValidationError('Invalid syntax')); } else { diff --git a/packages/unleash-api/lib/routes/feature.js b/packages/unleash-api/lib/routes/feature.js index 634aae34dc..59252b8f4e 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 BPromise = require('bluebird'); const logger = require('../logger'); const eventType = require('../eventType'); const NameExistsError = require('../error/NameExistsError'); @@ -107,7 +107,7 @@ module.exports = function (app, config) { }); function validateUniqueName (req) { - return new Promise((resolve, reject) => { + return new BPromise((resolve, reject) => { featureDb.getFeature(req.body.name) .then(() => { reject(new NameExistsError('Feature name already exist')); diff --git a/packages/unleash-api/lib/routes/strategy.js b/packages/unleash-api/lib/routes/strategy.js index b47636fc59..2ee50387b4 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 BPromise = require('bluebird'); const eventType = require('../eventType'); const logger = require('../logger'); const NameExistsError = require('../error/NameExistsError'); @@ -78,7 +78,7 @@ module.exports = function (app, config) { }); function validateStrategyName (req) { - return new Promise((resolve, reject) => { + return new BPromise((resolve, reject) => { strategyDb.getStrategy(req.body.name) .then(() => { reject(new NameExistsError('Feature name already exist')); diff --git a/packages/unleash-api/test/eventDifferTest.js b/packages/unleash-api/test/eventDifferTest.js index 9d13c954b2..be3c66436f 100644 --- a/packages/unleash-api/test/eventDifferTest.js +++ b/packages/unleash-api/test/eventDifferTest.js @@ -16,17 +16,17 @@ describe('eventDiffer', () => { }); it('diffs a feature-update event', () => { - const name = 'foo'; + const feature = 'foo'; const desc = 'bar'; const events = [ { type: eventType.featureUpdated, - data: { name, description: desc, strategy: 'default', enabled: true, parameters: { value: 2 } }, + data: { name: feature, 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: feature, description: desc, strategy: 'default', enabled: false, parameters: { value: 1 } }, }, ]; diff --git a/packages/unleash-api/test/specHelper.js b/packages/unleash-api/test/specHelper.js index a9118b7fb8..ebbd17abba 100644 --- a/packages/unleash-api/test/specHelper.js +++ b/packages/unleash-api/test/specHelper.js @@ -1,7 +1,7 @@ 'use strict'; process.env.NODE_ENV = 'test'; -const Promise = require('bluebird'); +const BPromise = require('bluebird'); let request = require('supertest'); const databaseUri = require('./databaseConfig').getDatabaseUri(); const knex = require('../lib/db/dbPool')(databaseUri); @@ -20,11 +20,11 @@ const app = require('../app')({ strategyDb, }); -Promise.promisifyAll(request); +BPromise.promisifyAll(request); request = request(app); function createStrategies () { - return Promise.map([ + return BPromise.map([ { name: 'default', description: 'Default on or off Strategy.', @@ -41,7 +41,7 @@ function createStrategies () { } function createFeatures () { - return Promise.map([ + return BPromise.map([ { name: 'featureX', description: 'the #1 feature', @@ -105,11 +105,11 @@ function destroyFeatures () { } function resetDatabase () { - return Promise.all([destroyStrategies(), destroyFeatures()]); + return BPromise.all([destroyStrategies(), destroyFeatures()]); } function setupDatabase () { - return Promise.all([createStrategies(), createFeatures()]); + return BPromise.all([createStrategies(), createFeatures()]); } module.exports = { diff --git a/packages/unleash-frontend/public/js/__tests__/components/feature/FeatureForm-test.js b/packages/unleash-frontend/public/js/__tests__/components/feature/FeatureForm-test.js index 785c8bd5e2..9b88d6a8aa 100644 --- a/packages/unleash-frontend/public/js/__tests__/components/feature/FeatureForm-test.js +++ b/packages/unleash-frontend/public/js/__tests__/components/feature/FeatureForm-test.js @@ -17,8 +17,8 @@ describe('FeatureForm', () => { describe('new', () => { it('should render empty form', () => { Component = TestUtils .renderIntoDocument(); - const name = Component.getDOMNode().querySelectorAll('input'); - expect(name[0].value).toEqual(''); + const value = Component.getDOMNode().querySelectorAll('input'); + expect(value[0].value).toEqual(''); }); }); diff --git a/packages/unleash-frontend/public/js/components/feature/FeatureForm.jsx b/packages/unleash-frontend/public/js/components/feature/FeatureForm.jsx index 36a3f51941..84a00e4582 100644 --- a/packages/unleash-frontend/public/js/components/feature/FeatureForm.jsx +++ b/packages/unleash-frontend/public/js/components/feature/FeatureForm.jsx @@ -22,15 +22,15 @@ const FeatureForm = React.createClass({ this.setState({ currentStrategy: e.target.value }); }, - getParameterValue (name) { + getParameterValue (feature) { if (this.props.feature && this.props.feature.parameters) { - return this.props.feature.parameters[name]; + return this.props.feature.parameters[feature]; } return ''; }, - setSelectedStrategy (name) { - const selectedStrategy = this.props.strategies.filter(strategy => strategy.name === name)[0]; + setSelectedStrategy (strategyName) { + const selectedStrategy = this.props.strategies.filter(strategy => strategy.name === strategyName)[0]; if (selectedStrategy) { this.setStrategyParams(selectedStrategy); diff --git a/packages/unleash-frontend/public/js/components/log/LogEntryList.jsx b/packages/unleash-frontend/public/js/components/log/LogEntryList.jsx index d492fcf5d5..22ded86a6a 100644 --- a/packages/unleash-frontend/public/js/components/log/LogEntryList.jsx +++ b/packages/unleash-frontend/public/js/components/log/LogEntryList.jsx @@ -14,8 +14,8 @@ const LogEntryList = React.createClass({ }, render () { - const logEntryNodes = this.props.events.map(event => - ); + const logEntryNodes = this.props.events.map(evt => + ); return (
diff --git a/packages/unleash-frontend/public/js/components/strategy/Strategy.jsx b/packages/unleash-frontend/public/js/components/strategy/Strategy.jsx index 70733ec23d..a7d8a56ce2 100644 --- a/packages/unleash-frontend/public/js/components/strategy/Strategy.jsx +++ b/packages/unleash-frontend/public/js/components/strategy/Strategy.jsx @@ -6,8 +6,8 @@ const Strategy = React.createClass({ strategy: React.PropTypes.object.isRequired, }, - onRemove (event) { - event.preventDefault(); + onRemove (evt) { + evt.preventDefault(); if (window.confirm(`Are you sure you want to delete strategy '${this.props.strategy.name}'?`)) { // eslint-disable-line no-alert this.props.onRemove(this.props.strategy); } diff --git a/packages/unleash-frontend/public/js/components/strategy/StrategyForm.jsx b/packages/unleash-frontend/public/js/components/strategy/StrategyForm.jsx index 0903e58ca4..81f3d8ddfa 100644 --- a/packages/unleash-frontend/public/js/components/strategy/StrategyForm.jsx +++ b/packages/unleash-frontend/public/js/components/strategy/StrategyForm.jsx @@ -16,8 +16,8 @@ const StrategyForm = React.createClass({ }; }, - onSubmit (event) { - event.preventDefault(); + onSubmit (evt) { + evt.preventDefault(); const strategy = {}; strategy.name = this.refs.name.getValue(); @@ -25,30 +25,30 @@ const StrategyForm = React.createClass({ strategy.parametersTemplate = {}; this.state.parameters.forEach(parameter => { - const name = this.refs[parameter.name].getDOMNode().value.trim(); - if (name) { - strategy.parametersTemplate[name] = 'string'; + const value = this.refs[parameter.name].getDOMNode().value.trim(); + if (value) { + strategy.parametersTemplate[value] = 'string'; } }); this.props.onSave(strategy); }, - onCancel (event) { - event.preventDefault(); + onCancel (evt) { + evt.preventDefault(); this.props.onCancelNewStrategy(); }, - onAddParam (event) { - event.preventDefault(); + onAddParam (evt) { + evt.preventDefault(); const id = this.state.parameters.length + 1; const params = this.state.parameters.concat([{ id, name: `param_${id}`, label: `Parameter ${id}` }]); this.setState({ parameters: params }); }, - onRemoveParam (event) { - event.preventDefault(); + onRemoveParam (evt) { + evt.preventDefault(); const params = this.state.parameters.slice(0, -1); this.setState({ parameters: params }); diff --git a/packages/unleash-frontend/public/js/stores/EventStore.js b/packages/unleash-frontend/public/js/stores/EventStore.js index 65b397d021..685726e113 100644 --- a/packages/unleash-frontend/public/js/stores/EventStore.js +++ b/packages/unleash-frontend/public/js/stores/EventStore.js @@ -12,9 +12,9 @@ const EventStore = { }); }, - getEventsByName (name) { + getEventsByName (eventName) { return reqwest({ - url: `events/${name}`, + url: `events/${eventName}`, method: 'get', type: TYPE, }); diff --git a/packages/unleash-frontend/public/js/stores/UserStore.js b/packages/unleash-frontend/public/js/stores/UserStore.js index 04b60e4838..e62856dfd2 100644 --- a/packages/unleash-frontend/public/js/stores/UserStore.js +++ b/packages/unleash-frontend/public/js/stores/UserStore.js @@ -2,8 +2,8 @@ let _username; // Ref: http://stackoverflow.com/questions/10730362/get-cookie-by-name -function readCookie (name) { - const nameEQ = `${name}=`; +function readCookie (cookieName) { + const nameEQ = `${cookieName}=`; const ca = document.cookie.split(';'); for (let i = 0;i < ca.length;i++) { let c = ca[i]; diff --git a/packages/unleash-frontend/webpack.config.js b/packages/unleash-frontend/webpack.config.js index d74a1ee510..27feb4132b 100644 --- a/packages/unleash-frontend/webpack.config.js +++ b/packages/unleash-frontend/webpack.config.js @@ -3,8 +3,8 @@ 'use strict'; const path = require('path'); -const root = path.normalize(path.join(__dirname, '.')); -const jsroot = path.join(root, 'public', 'js'); +const publicRoot = path.join(__dirname, 'public'); +const jsroot = path.join(publicRoot, 'js'); module.exports = { @@ -12,7 +12,7 @@ module.exports = { entry: './app.jsx', output: { - path: path.join(root, 'public'), + path: publicRoot, filename: 'bundle.js', publicPath: '/js/', },