From 1cdc41a5d9ee0f0cceeb918182f524d4ebfd1552 Mon Sep 17 00:00:00 2001 From: sveisvei Date: Sat, 18 Jun 2016 22:23:19 +0200 Subject: [PATCH] manual fix lint errors --- packages/unleash-api/app.js | 2 +- packages/unleash-api/lib/db/event.js | 2 +- packages/unleash-api/lib/eventDiffer.js | 11 +- packages/unleash-api/lib/eventStore.js | 3 +- .../unleash-api/scripts/migration-runner.js | 4 +- .../components/feature/FeatureList-test.js | 23 ++-- .../public/js/components/ErrorMessages.jsx | 2 +- .../public/js/components/Menu.jsx | 105 +++++++++--------- .../public/js/components/feature/Feature.jsx | 2 +- .../js/components/feature/FeatureForm.jsx | 7 +- .../js/components/feature/FeatureList.jsx | 3 +- .../public/js/components/log/LogEntry.jsx | 3 +- .../js/components/strategy/Strategy.jsx | 2 +- .../js/components/strategy/StrategyForm.jsx | 4 +- .../public/js/stores/ErrorStore.js | 2 +- .../public/js/stores/UserStore.js | 2 +- .../unleash-frontend/public/js/utils/Timer.js | 8 +- 17 files changed, 90 insertions(+), 95 deletions(-) diff --git a/packages/unleash-api/app.js b/packages/unleash-api/app.js index cc3da3642c..12bdaaa0aa 100644 --- a/packages/unleash-api/app.js +++ b/packages/unleash-api/app.js @@ -11,7 +11,7 @@ const path = require('path'); module.exports = function(config) { const app = express(); - const router = express.Router(); + const router = express.Router(); // eslint-disable-line new-cap const baseUriPath = config.baseUriPath || ''; const publicFolder = config.publicFolder; diff --git a/packages/unleash-api/lib/db/event.js b/packages/unleash-api/lib/db/event.js index 8196d1cb89..78b2218d7d 100644 --- a/packages/unleash-api/lib/db/event.js +++ b/packages/unleash-api/lib/db/event.js @@ -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); } diff --git a/packages/unleash-api/lib/eventDiffer.js b/packages/unleash-api/lib/eventDiffer.js index 91fd9ddcd4..e3980aecdb 100644 --- a/packages/unleash-api/lib/eventDiffer.js +++ b/packages/unleash-api/lib/eventDiffer.js @@ -19,9 +19,8 @@ function baseTypeFor(event) { return 'features'; } else if (strategyTypes.indexOf(event.type) !== -1) { return 'strategies'; - } else { - throw new Error(`unknown event type: ${JSON.stringify(event)}`); } + throw new Error(`unknown event type: ${JSON.stringify(event)}`); } function groupByBaseTypeAndName(events) { @@ -46,14 +45,14 @@ function eachConsecutiveEvent(events, callback) { const group = groups[baseType]; Object.keys(group).forEach(name => { - const events = group[name]; + const currentEvents = group[name]; let left; let right; let i; let l; - for (i = 0, l = events.length; i < l; i++) { - left = events[i]; - right = events[i + 1]; + for (i = 0, l = currentEvents.length; i < l; i++) { + left = currentEvents[i]; + right = currentEvents[i + 1]; callback(left, right); } diff --git a/packages/unleash-api/lib/eventStore.js b/packages/unleash-api/lib/eventStore.js index 588d31bee4..2a99167aa4 100644 --- a/packages/unleash-api/lib/eventStore.js +++ b/packages/unleash-api/lib/eventStore.js @@ -9,9 +9,8 @@ function EventStore(eventDb) { util.inherits(EventStore, EventEmitter); EventStore.prototype.create = function (event) { - const that = this; return this.eventDb.store(event).then(() => { - that.emit(event.type, event); + this.emit(event.type, event); }); }; diff --git a/packages/unleash-api/scripts/migration-runner.js b/packages/unleash-api/scripts/migration-runner.js index 3696e5b6e4..85a9adc44f 100644 --- a/packages/unleash-api/scripts/migration-runner.js +++ b/packages/unleash-api/scripts/migration-runner.js @@ -3,8 +3,8 @@ const fs = require('fs'); const util = require('util'); const path = require('path'); -const runMigration = function(path, db, callback) { - db.runSql(fs.readFileSync(path, { encoding: 'utf8' }), callback); +const runMigration = function(migrationPath, db, callback) { + db.runSql(fs.readFileSync(migrationPath, { encoding: 'utf8' }), callback); }; module.exports = { diff --git a/packages/unleash-frontend/public/js/__tests__/components/feature/FeatureList-test.js b/packages/unleash-frontend/public/js/__tests__/components/feature/FeatureList-test.js index 0a01a20cb3..0ae93048e3 100644 --- a/packages/unleash-frontend/public/js/__tests__/components/feature/FeatureList-test.js +++ b/packages/unleash-frontend/public/js/__tests__/components/feature/FeatureList-test.js @@ -8,10 +8,9 @@ const FeatureList = require('../../../components/feature/FeatureList'); describe('FeatureList', () => { let Component; - let features; beforeEach(() => { - features = [ + const features = [ { name: 'featureX', strategy: 'other' }, { name: 'group.featureY', strategy: 'default' }, ]; @@ -26,25 +25,25 @@ describe('FeatureList', () => { }); it('should render all features', () => { - const features = Component.getDOMNode().querySelectorAll('.feature'); - expect(features.length).toEqual(2); + const featuresElement = Component.getDOMNode().querySelectorAll('.feature'); + expect(featuresElement.length).toEqual(2); }); it('should filter list of features', () => { const filterNode = Component.refs.filter.getDOMNode(); TestUtils.Simulate.change(filterNode, { target: { value: 'group' } }); - const features = Component.getDOMNode().querySelectorAll('.feature'); - expect(features.length).toEqual(1); + const featuresElement = Component.getDOMNode().querySelectorAll('.feature'); + expect(featuresElement.length).toEqual(1); }); it('should filter list of features ignoring case', () => { const filterNode = Component.refs.filter.getDOMNode(); TestUtils.Simulate.change(filterNode, { target: { value: 'GROUP' } }); - const features = Component.getDOMNode().querySelectorAll('.feature'); - expect(features.length).toEqual(1); - expect(features[0].textContent).toMatch('group'); + const featuresElement = Component.getDOMNode().querySelectorAll('.feature'); + expect(featuresElement.length).toEqual(1); + expect(featuresElement[0].textContent).toMatch('group'); }); it('should filter list of features by strategy name', () => { @@ -52,8 +51,8 @@ describe('FeatureList', () => { const filterNode = Component.refs.filter.getDOMNode(); TestUtils.Simulate.change(filterNode, { target: { value: searchString } }); - const features = Component.getDOMNode().querySelectorAll('.feature'); - expect(features.length).toEqual(1); - expect(features[0].textContent).toMatch(searchString); + const featuresElement = Component.getDOMNode().querySelectorAll('.feature'); + expect(featuresElement.length).toEqual(1); + expect(featuresElement[0].textContent).toMatch(searchString); }); }); diff --git a/packages/unleash-frontend/public/js/components/ErrorMessages.jsx b/packages/unleash-frontend/public/js/components/ErrorMessages.jsx index 742d873231..07924d1d8c 100644 --- a/packages/unleash-frontend/public/js/components/ErrorMessages.jsx +++ b/packages/unleash-frontend/public/js/components/ErrorMessages.jsx @@ -31,7 +31,7 @@ const ErrorMessages = React.createClass({ render() { return ( - + ); }, }); diff --git a/packages/unleash-frontend/public/js/components/Menu.jsx b/packages/unleash-frontend/public/js/components/Menu.jsx index 60a748edeb..9cd187ad0d 100644 --- a/packages/unleash-frontend/public/js/components/Menu.jsx +++ b/packages/unleash-frontend/public/js/components/Menu.jsx @@ -3,59 +3,60 @@ const React = require('react'); const User = require('./User'); const Menu = React.createClass({ - render() { return ( -
-
-
-
- -
-
- - - - + render() { + return ( + + + unleash admin + + + {this.props.children} +
+
+
+
); }, }); diff --git a/packages/unleash-frontend/public/js/components/feature/Feature.jsx b/packages/unleash-frontend/public/js/components/feature/Feature.jsx index 0cfb80266e..420f60a32b 100644 --- a/packages/unleash-frontend/public/js/components/feature/Feature.jsx +++ b/packages/unleash-frontend/public/js/components/feature/Feature.jsx @@ -33,7 +33,7 @@ const Feature = React.createClass({ }, archiveFeature() { - if (window.confirm(`Are you sure you want to delete ${this.props.feature.name}?`)) { + if (window.confirm(`Are you sure you want to delete ${this.props.feature.name}?`)) { // eslint-disable-line no-alert this.props.onArchive(this.props.feature); } }, diff --git a/packages/unleash-frontend/public/js/components/feature/FeatureForm.jsx b/packages/unleash-frontend/public/js/components/feature/FeatureForm.jsx index f9de996473..a697bc87a8 100644 --- a/packages/unleash-frontend/public/js/components/feature/FeatureForm.jsx +++ b/packages/unleash-frontend/public/js/components/feature/FeatureForm.jsx @@ -25,9 +25,8 @@ const FeatureForm = React.createClass({ getParameterValue(name) { if (this.props.feature && this.props.feature.parameters) { return this.props.feature.parameters[name]; - } else { - return ''; } + return ''; }, setSelectedStrategy(name) { @@ -47,7 +46,9 @@ const FeatureForm = React.createClass({ const requiredParams = []; let key; for (key in strategy.parametersTemplate) { - requiredParams.push({ name: key, value: this.getParameterValue(key) }); + if (Object.hasOwnProperty.call(strategy.parametersTemplate, key)) { + requiredParams.push({ name: key, value: this.getParameterValue(key) }); + } } this.setState({ requiredParams }); }, diff --git a/packages/unleash-frontend/public/js/components/feature/FeatureList.jsx b/packages/unleash-frontend/public/js/components/feature/FeatureList.jsx index e97ac23191..ecdd29e294 100644 --- a/packages/unleash-frontend/public/js/components/feature/FeatureList.jsx +++ b/packages/unleash-frontend/public/js/components/feature/FeatureList.jsx @@ -33,9 +33,8 @@ const FeatureList = React.createClass({ const regex = new RegExp(this.state.filter, 'i'); return this.props.features.filter(item => regex.test(item.name) || regex.test(item.strategy)); - } else { - return this.props.features; } + return this.props.features; }, render() { diff --git a/packages/unleash-frontend/public/js/components/log/LogEntry.jsx b/packages/unleash-frontend/public/js/components/log/LogEntry.jsx index 7df458de5c..75e643da0e 100644 --- a/packages/unleash-frontend/public/js/components/log/LogEntry.jsx +++ b/packages/unleash-frontend/public/js/components/log/LogEntry.jsx @@ -57,9 +57,8 @@ const LogEntry = React.createClass({ return ( {changes.length === 0 ? '(no changes)' : changes} ); - } else { - return this.renderFullEventData(); } + return this.renderFullEventData(); }, buildDiff(diff, idx) { diff --git a/packages/unleash-frontend/public/js/components/strategy/Strategy.jsx b/packages/unleash-frontend/public/js/components/strategy/Strategy.jsx index 277460e538..57de34430d 100644 --- a/packages/unleash-frontend/public/js/components/strategy/Strategy.jsx +++ b/packages/unleash-frontend/public/js/components/strategy/Strategy.jsx @@ -8,7 +8,7 @@ const Strategy = React.createClass({ onRemove(event) { event.preventDefault(); - if (window.confirm(`Are you sure you want to delete strategy '${this.props.strategy.name}'?`)) { + 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 0d67de27f0..720ae63d89 100644 --- a/packages/unleash-frontend/public/js/components/strategy/StrategyForm.jsx +++ b/packages/unleash-frontend/public/js/components/strategy/StrategyForm.jsx @@ -24,10 +24,8 @@ const StrategyForm = React.createClass({ strategy.description = this.refs.description.getValue(); strategy.parametersTemplate = {}; - const that = this; - this.state.parameters.forEach(parameter => { - const name = that.refs[parameter.name].getDOMNode().value.trim(); + const name = this.refs[parameter.name].getDOMNode().value.trim(); if (name) { strategy.parametersTemplate[name] = 'string'; } diff --git a/packages/unleash-frontend/public/js/stores/ErrorStore.js b/packages/unleash-frontend/public/js/stores/ErrorStore.js index 90188aa88a..9052cbc046 100644 --- a/packages/unleash-frontend/public/js/stores/ErrorStore.js +++ b/packages/unleash-frontend/public/js/stores/ErrorStore.js @@ -52,7 +52,7 @@ const FeatureStore = Reflux.createStore({ } catch (e) { if (e instanceof SyntaxError) { // fall through; - console.log('Syntax error!'); + console.log('Syntax error!'); // eslint-disable-line no-console } else { throw e; } diff --git a/packages/unleash-frontend/public/js/stores/UserStore.js b/packages/unleash-frontend/public/js/stores/UserStore.js index 39bdac8942..ed2978fcc5 100644 --- a/packages/unleash-frontend/public/js/stores/UserStore.js +++ b/packages/unleash-frontend/public/js/stores/UserStore.js @@ -7,7 +7,7 @@ function readCookie(name) { const ca = document.cookie.split(';'); for (let i=0;i < ca.length;i++) { let c = ca[i]; - while (c.charAt(0)==' ') { + while (c.charAt(0)==' ') { // eslint-disable-line eqeqeq c = c.substring(1, c.length); } if (c.indexOf(nameEQ) === 0) { diff --git a/packages/unleash-frontend/public/js/utils/Timer.js b/packages/unleash-frontend/public/js/utils/Timer.js index 84fc779037..f5db3fd9a6 100644 --- a/packages/unleash-frontend/public/js/utils/Timer.js +++ b/packages/unleash-frontend/public/js/utils/Timer.js @@ -7,19 +7,19 @@ const Timer = function(cb, interval) { Timer.prototype.start = function() { if (this.timerId != null) { - console.warn('timer already started'); + console.warn('timer already started'); // eslint-disable-line no-console } - console.log('starting timer'); + console.log('starting timer'); // eslint-disable-line no-console this.timerId = setInterval(this.cb, this.interval); this.cb(); }; Timer.prototype.stop = function() { if (this.timerId == null) { - console.warn('no timer running'); + console.warn('no timer running'); // eslint-disable-line no-console } else { - console.log('stopping timer'); + console.log('stopping timer'); // eslint-disable-line no-console clearInterval(this.timerId); this.timerId = null; }