1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00

Fix linting errors (#145)

* Use pretty (svg) badges

* Fix build
This commit is contained in:
Simen Bekkhus 2016-08-22 15:12:05 +02:00 committed by Ivar Conradi Østhus
parent ad3df75348
commit fb767f2b4a
15 changed files with 52 additions and 47 deletions

View File

@ -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) __ __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) ![Admin UI](https://cloud.githubusercontent.com/assets/572/5873775/3ddc1a66-a2fa-11e4-923c-0a9569605dad.png)

View File

@ -18,10 +18,11 @@
"engines": { "engines": {
"node": "6" "node": "6"
}, },
"license": "Apache-2.0",
"scripts": { "scripts": {
"bootstrap": "lerna bootstrap", "bootstrap": "lerna bootstrap",
"prepublish": "npm run 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": "npm run lint && lerna --concurrency=1 exec npm run test",
"test:ci": "npm run lint && lerna --concurrency=1 exec npm run test:ci", "test:ci": "npm run lint && lerna --concurrency=1 exec npm run test:ci",
"nsp": "lerna exec nsp check", "nsp": "lerna exec nsp check",
@ -33,8 +34,8 @@
}, },
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"eslint": "^2.12.0", "eslint": "^2.13.1",
"eslint-config-finn": "^1.0.0-alpha.4", "eslint-config-finn": "1.0.0-alpha.8",
"eslint-plugin-react": "^4.3.0", "eslint-plugin-react": "^4.3.0",
"lerna": "2.0.0-beta.20", "lerna": "2.0.0-beta.20",
"nsp": "^2.3.2" "nsp": "^2.3.2"

View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
const Promise = require('bluebird'); const BPromise = require('bluebird');
const ValidationError = require('./ValidationError'); const ValidationError = require('./ValidationError');
function validateRequest (req) { function validateRequest (req) {
return new Promise((resolve, reject) => { return new BPromise((resolve, reject) => {
if (req.validationErrors()) { if (req.validationErrors()) {
reject(new ValidationError('Invalid syntax')); reject(new ValidationError('Invalid syntax'));
} else { } else {

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
const Promise = require('bluebird'); const BPromise = require('bluebird');
const logger = require('../logger'); const logger = require('../logger');
const eventType = require('../eventType'); const eventType = require('../eventType');
const NameExistsError = require('../error/NameExistsError'); const NameExistsError = require('../error/NameExistsError');
@ -107,7 +107,7 @@ module.exports = function (app, config) {
}); });
function validateUniqueName (req) { function validateUniqueName (req) {
return new Promise((resolve, reject) => { return new BPromise((resolve, reject) => {
featureDb.getFeature(req.body.name) featureDb.getFeature(req.body.name)
.then(() => { .then(() => {
reject(new NameExistsError('Feature name already exist')); reject(new NameExistsError('Feature name already exist'));

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
const Promise = require('bluebird'); const BPromise = require('bluebird');
const eventType = require('../eventType'); const eventType = require('../eventType');
const logger = require('../logger'); const logger = require('../logger');
const NameExistsError = require('../error/NameExistsError'); const NameExistsError = require('../error/NameExistsError');
@ -78,7 +78,7 @@ module.exports = function (app, config) {
}); });
function validateStrategyName (req) { function validateStrategyName (req) {
return new Promise((resolve, reject) => { return new BPromise((resolve, reject) => {
strategyDb.getStrategy(req.body.name) strategyDb.getStrategy(req.body.name)
.then(() => { .then(() => {
reject(new NameExistsError('Feature name already exist')); reject(new NameExistsError('Feature name already exist'));

View File

@ -16,17 +16,17 @@ describe('eventDiffer', () => {
}); });
it('diffs a feature-update event', () => { it('diffs a feature-update event', () => {
const name = 'foo'; const feature = 'foo';
const desc = 'bar'; const desc = 'bar';
const events = [ const events = [
{ {
type: eventType.featureUpdated, 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, 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 } },
}, },
]; ];

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
process.env.NODE_ENV = 'test'; process.env.NODE_ENV = 'test';
const Promise = require('bluebird'); const BPromise = require('bluebird');
let request = require('supertest'); let request = require('supertest');
const databaseUri = require('./databaseConfig').getDatabaseUri(); const databaseUri = require('./databaseConfig').getDatabaseUri();
const knex = require('../lib/db/dbPool')(databaseUri); const knex = require('../lib/db/dbPool')(databaseUri);
@ -20,11 +20,11 @@ const app = require('../app')({
strategyDb, strategyDb,
}); });
Promise.promisifyAll(request); BPromise.promisifyAll(request);
request = request(app); request = request(app);
function createStrategies () { function createStrategies () {
return Promise.map([ return BPromise.map([
{ {
name: 'default', name: 'default',
description: 'Default on or off Strategy.', description: 'Default on or off Strategy.',
@ -41,7 +41,7 @@ function createStrategies () {
} }
function createFeatures () { function createFeatures () {
return Promise.map([ return BPromise.map([
{ {
name: 'featureX', name: 'featureX',
description: 'the #1 feature', description: 'the #1 feature',
@ -105,11 +105,11 @@ function destroyFeatures () {
} }
function resetDatabase () { function resetDatabase () {
return Promise.all([destroyStrategies(), destroyFeatures()]); return BPromise.all([destroyStrategies(), destroyFeatures()]);
} }
function setupDatabase () { function setupDatabase () {
return Promise.all([createStrategies(), createFeatures()]); return BPromise.all([createStrategies(), createFeatures()]);
} }
module.exports = { module.exports = {

View File

@ -17,8 +17,8 @@ describe('FeatureForm', () => {
describe('new', () => { describe('new', () => {
it('should render empty form', () => { it('should render empty form', () => {
Component = TestUtils .renderIntoDocument(<FeatureForm strategies={strategies} />); Component = TestUtils .renderIntoDocument(<FeatureForm strategies={strategies} />);
const name = Component.getDOMNode().querySelectorAll('input'); const value = Component.getDOMNode().querySelectorAll('input');
expect(name[0].value).toEqual(''); expect(value[0].value).toEqual('');
}); });
}); });

View File

@ -22,15 +22,15 @@ const FeatureForm = React.createClass({
this.setState({ currentStrategy: e.target.value }); this.setState({ currentStrategy: e.target.value });
}, },
getParameterValue (name) { getParameterValue (feature) {
if (this.props.feature && this.props.feature.parameters) { if (this.props.feature && this.props.feature.parameters) {
return this.props.feature.parameters[name]; return this.props.feature.parameters[feature];
} }
return ''; return '';
}, },
setSelectedStrategy (name) { setSelectedStrategy (strategyName) {
const selectedStrategy = this.props.strategies.filter(strategy => strategy.name === name)[0]; const selectedStrategy = this.props.strategies.filter(strategy => strategy.name === strategyName)[0];
if (selectedStrategy) { if (selectedStrategy) {
this.setStrategyParams(selectedStrategy); this.setStrategyParams(selectedStrategy);

View File

@ -14,8 +14,8 @@ const LogEntryList = React.createClass({
}, },
render () { render () {
const logEntryNodes = this.props.events.map(event => const logEntryNodes = this.props.events.map(evt =>
<LogEntry event={event} key={event.id} showFullEvents={this.state.showFullEvents} />); <LogEntry event={evt} key={evt.id} showFullEvents={this.state.showFullEvents} />);
return ( return (
<div> <div>

View File

@ -6,8 +6,8 @@ const Strategy = React.createClass({
strategy: React.PropTypes.object.isRequired, strategy: React.PropTypes.object.isRequired,
}, },
onRemove (event) { onRemove (evt) {
event.preventDefault(); evt.preventDefault();
if (window.confirm(`Are you sure you want to delete strategy '${this.props.strategy.name}'?`)) { // eslint-disable-line no-alert 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); this.props.onRemove(this.props.strategy);
} }

View File

@ -16,8 +16,8 @@ const StrategyForm = React.createClass({
}; };
}, },
onSubmit (event) { onSubmit (evt) {
event.preventDefault(); evt.preventDefault();
const strategy = {}; const strategy = {};
strategy.name = this.refs.name.getValue(); strategy.name = this.refs.name.getValue();
@ -25,30 +25,30 @@ const StrategyForm = React.createClass({
strategy.parametersTemplate = {}; strategy.parametersTemplate = {};
this.state.parameters.forEach(parameter => { this.state.parameters.forEach(parameter => {
const name = this.refs[parameter.name].getDOMNode().value.trim(); const value = this.refs[parameter.name].getDOMNode().value.trim();
if (name) { if (value) {
strategy.parametersTemplate[name] = 'string'; strategy.parametersTemplate[value] = 'string';
} }
}); });
this.props.onSave(strategy); this.props.onSave(strategy);
}, },
onCancel (event) { onCancel (evt) {
event.preventDefault(); evt.preventDefault();
this.props.onCancelNewStrategy(); this.props.onCancelNewStrategy();
}, },
onAddParam (event) { onAddParam (evt) {
event.preventDefault(); evt.preventDefault();
const id = this.state.parameters.length + 1; const id = this.state.parameters.length + 1;
const params = this.state.parameters.concat([{ id, name: `param_${id}`, label: `Parameter ${id}` }]); const params = this.state.parameters.concat([{ id, name: `param_${id}`, label: `Parameter ${id}` }]);
this.setState({ parameters: params }); this.setState({ parameters: params });
}, },
onRemoveParam (event) { onRemoveParam (evt) {
event.preventDefault(); evt.preventDefault();
const params = this.state.parameters.slice(0, -1); const params = this.state.parameters.slice(0, -1);
this.setState({ parameters: params }); this.setState({ parameters: params });

View File

@ -12,9 +12,9 @@ const EventStore = {
}); });
}, },
getEventsByName (name) { getEventsByName (eventName) {
return reqwest({ return reqwest({
url: `events/${name}`, url: `events/${eventName}`,
method: 'get', method: 'get',
type: TYPE, type: TYPE,
}); });

View File

@ -2,8 +2,8 @@
let _username; let _username;
// Ref: http://stackoverflow.com/questions/10730362/get-cookie-by-name // Ref: http://stackoverflow.com/questions/10730362/get-cookie-by-name
function readCookie (name) { function readCookie (cookieName) {
const nameEQ = `${name}=`; const nameEQ = `${cookieName}=`;
const ca = document.cookie.split(';'); const ca = document.cookie.split(';');
for (let i = 0;i < ca.length;i++) { for (let i = 0;i < ca.length;i++) {
let c = ca[i]; let c = ca[i];

View File

@ -3,8 +3,8 @@
'use strict'; 'use strict';
const path = require('path'); const path = require('path');
const root = path.normalize(path.join(__dirname, '.')); const publicRoot = path.join(__dirname, 'public');
const jsroot = path.join(root, 'public', 'js'); const jsroot = path.join(publicRoot, 'js');
module.exports = { module.exports = {
@ -12,7 +12,7 @@ module.exports = {
entry: './app.jsx', entry: './app.jsx',
output: { output: {
path: path.join(root, 'public'), path: publicRoot,
filename: 'bundle.js', filename: 'bundle.js',
publicPath: '/js/', publicPath: '/js/',
}, },