1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-04 00:18:40 +01:00

manual fix lint errors

This commit is contained in:
sveisvei 2016-06-18 22:23:19 +02:00
parent 61532301fb
commit acc46c6221
17 changed files with 90 additions and 95 deletions

View File

@ -11,7 +11,7 @@ const path = require('path');
module.exports = function(config) { module.exports = function(config) {
const app = express(); const app = express();
const router = express.Router(); const router = express.Router(); // eslint-disable-line new-cap
const baseUriPath = config.baseUriPath || ''; const baseUriPath = config.baseUriPath || '';
const publicFolder = config.publicFolder; const publicFolder = config.publicFolder;

View File

@ -22,7 +22,7 @@ module.exports = function(db) {
return db return db
.select(EVENT_COLUMNS) .select(EVENT_COLUMNS)
.from('events') .from('events')
.whereRaw('data ->> \'name\' = ?', [name]) .whereRaw('data ->> "name" = ?', [name])
.orderBy('created_at', 'desc') .orderBy('created_at', 'desc')
.map(rowToEvent); .map(rowToEvent);
} }

View File

@ -19,9 +19,8 @@ function baseTypeFor(event) {
return 'features'; return 'features';
} else if (strategyTypes.indexOf(event.type) !== -1) { } else if (strategyTypes.indexOf(event.type) !== -1) {
return 'strategies'; return 'strategies';
} else {
throw new Error(`unknown event type: ${JSON.stringify(event)}`);
} }
throw new Error(`unknown event type: ${JSON.stringify(event)}`);
} }
function groupByBaseTypeAndName(events) { function groupByBaseTypeAndName(events) {
@ -46,14 +45,14 @@ function eachConsecutiveEvent(events, callback) {
const group = groups[baseType]; const group = groups[baseType];
Object.keys(group).forEach(name => { Object.keys(group).forEach(name => {
const events = group[name]; const currentEvents = group[name];
let left; let left;
let right; let right;
let i; let i;
let l; let l;
for (i = 0, l = events.length; i < l; i++) { for (i = 0, l = currentEvents.length; i < l; i++) {
left = events[i]; left = currentEvents[i];
right = events[i + 1]; right = currentEvents[i + 1];
callback(left, right); callback(left, right);
} }

View File

@ -9,9 +9,8 @@ function EventStore(eventDb) {
util.inherits(EventStore, EventEmitter); util.inherits(EventStore, EventEmitter);
EventStore.prototype.create = function (event) { EventStore.prototype.create = function (event) {
const that = this;
return this.eventDb.store(event).then(() => { return this.eventDb.store(event).then(() => {
that.emit(event.type, event); this.emit(event.type, event);
}); });
}; };

View File

@ -3,8 +3,8 @@ const fs = require('fs');
const util = require('util'); const util = require('util');
const path = require('path'); const path = require('path');
const runMigration = function(path, db, callback) { const runMigration = function(migrationPath, db, callback) {
db.runSql(fs.readFileSync(path, { encoding: 'utf8' }), callback); db.runSql(fs.readFileSync(migrationPath, { encoding: 'utf8' }), callback);
}; };
module.exports = { module.exports = {

View File

@ -8,10 +8,9 @@ const FeatureList = require('../../../components/feature/FeatureList');
describe('FeatureList', () => { describe('FeatureList', () => {
let Component; let Component;
let features;
beforeEach(() => { beforeEach(() => {
features = [ const features = [
{ name: 'featureX', strategy: 'other' }, { name: 'featureX', strategy: 'other' },
{ name: 'group.featureY', strategy: 'default' }, { name: 'group.featureY', strategy: 'default' },
]; ];
@ -26,25 +25,25 @@ describe('FeatureList', () => {
}); });
it('should render all features', () => { it('should render all features', () => {
const features = Component.getDOMNode().querySelectorAll('.feature'); const featuresElement = Component.getDOMNode().querySelectorAll('.feature');
expect(features.length).toEqual(2); expect(featuresElement.length).toEqual(2);
}); });
it('should filter list of features', () => { it('should filter list of features', () => {
const filterNode = Component.refs.filter.getDOMNode(); const filterNode = Component.refs.filter.getDOMNode();
TestUtils.Simulate.change(filterNode, { target: { value: 'group' } }); TestUtils.Simulate.change(filterNode, { target: { value: 'group' } });
const features = Component.getDOMNode().querySelectorAll('.feature'); const featuresElement = Component.getDOMNode().querySelectorAll('.feature');
expect(features.length).toEqual(1); expect(featuresElement.length).toEqual(1);
}); });
it('should filter list of features ignoring case', () => { it('should filter list of features ignoring case', () => {
const filterNode = Component.refs.filter.getDOMNode(); const filterNode = Component.refs.filter.getDOMNode();
TestUtils.Simulate.change(filterNode, { target: { value: 'GROUP' } }); TestUtils.Simulate.change(filterNode, { target: { value: 'GROUP' } });
const features = Component.getDOMNode().querySelectorAll('.feature'); const featuresElement = Component.getDOMNode().querySelectorAll('.feature');
expect(features.length).toEqual(1); expect(featuresElement.length).toEqual(1);
expect(features[0].textContent).toMatch('group'); expect(featuresElement[0].textContent).toMatch('group');
}); });
it('should filter list of features by strategy name', () => { it('should filter list of features by strategy name', () => {
@ -52,8 +51,8 @@ describe('FeatureList', () => {
const filterNode = Component.refs.filter.getDOMNode(); const filterNode = Component.refs.filter.getDOMNode();
TestUtils.Simulate.change(filterNode, { target: { value: searchString } }); TestUtils.Simulate.change(filterNode, { target: { value: searchString } });
const features = Component.getDOMNode().querySelectorAll('.feature'); const featuresElement = Component.getDOMNode().querySelectorAll('.feature');
expect(features.length).toEqual(1); expect(featuresElement.length).toEqual(1);
expect(features[0].textContent).toMatch(searchString); expect(featuresElement[0].textContent).toMatch(searchString);
}); });
}); });

View File

@ -31,7 +31,7 @@ const ErrorMessages = React.createClass({
render() { render() {
return ( return (
<Ui errors={this.state.errors} onClearErrors={this.onClearErrors}></Ui> <Ui errors={this.state.errors} onClearErrors={this.onClearErrors} />
); );
}, },
}); });

View File

@ -3,59 +3,60 @@ const React = require('react');
const User = require('./User'); const User = require('./User');
const Menu = React.createClass({ const Menu = React.createClass({
render() { return ( render() {
<div className="topbar mbl"> return (
<div className="container"> <div className="topbar mbl">
<div className="page"> <div className="container">
<div className="fright-ht768"> <div className="page">
<User /> <div className="fright-ht768">
</div> <User />
<div className="nav-level1 h4"> </div>
<a href="#" className="homelink pln"> <div className="nav-level1 h4">
<span className="topbar-nav-svg-home"> <a href="#" className="homelink pln">
<img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53M <span className="topbar-nav-svg-home">
y5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MjcuNDExIiBoZWlnaHQ9IjE2OS4z <img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53M
OTgiIHZpZXdCb3g9IjAgMCA1MjcuNDExIDE2OS4zOTgiPjxwYXRoIGZpbGw y5vcmcvMjAwMC9zdmciIHdpZHRoPSI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0aC0zOS44MjNsLS4wMSA1M2gxOS42MzN2LTM3LjM4N3 OSAzNC4xNTJoMTkuNjM0di00MS45OTZjMC01LjUyNy0zLjgxNS0xMS4wMDQ
oiLz48L3N2Zz4%3D" width="106" height="34" /> tMTMuMDctMTEuMDA0aC0zOS44MjNsLS4wMSA1M2gxOS42MzN2LTM3LjM4N3
</span> oiLz48L3N2Zz4%3D" width="106" height="34" />
</span>
<span <span
className="topbar-nav-svg-caption caption showbydefault hide-lt900"> className="topbar-nav-svg-caption caption showbydefault hide-lt900">
unleash admin unleash admin
</span> </span>
</a> </a>
{this.props.children} {this.props.children}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
); );
}, },
}); });

View File

@ -33,7 +33,7 @@ const Feature = React.createClass({
}, },
archiveFeature() { 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); this.props.onArchive(this.props.feature);
} }
}, },

View File

@ -25,9 +25,8 @@ const FeatureForm = React.createClass({
getParameterValue(name) { getParameterValue(name) {
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[name];
} else {
return '';
} }
return '';
}, },
setSelectedStrategy(name) { setSelectedStrategy(name) {
@ -47,7 +46,9 @@ const FeatureForm = React.createClass({
const requiredParams = []; const requiredParams = [];
let key; let key;
for (key in strategy.parametersTemplate) { 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 }); this.setState({ requiredParams });
}, },

View File

@ -33,9 +33,8 @@ const FeatureList = React.createClass({
const regex = new RegExp(this.state.filter, 'i'); const regex = new RegExp(this.state.filter, 'i');
return this.props.features.filter(item => regex.test(item.name) || regex.test(item.strategy)); return this.props.features.filter(item => regex.test(item.name) || regex.test(item.strategy));
} else {
return this.props.features;
} }
return this.props.features;
}, },
render() { render() {

View File

@ -57,9 +57,8 @@ const LogEntry = React.createClass({
return ( return (
<code className="smalltext man">{changes.length === 0 ? '(no changes)' : changes}</code> <code className="smalltext man">{changes.length === 0 ? '(no changes)' : changes}</code>
); );
} else {
return this.renderFullEventData();
} }
return this.renderFullEventData();
}, },
buildDiff(diff, idx) { buildDiff(diff, idx) {

View File

@ -8,7 +8,7 @@ const Strategy = React.createClass({
onRemove(event) { onRemove(event) {
event.preventDefault(); 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); this.props.onRemove(this.props.strategy);
} }
}, },

View File

@ -24,10 +24,8 @@ const StrategyForm = React.createClass({
strategy.description = this.refs.description.getValue(); strategy.description = this.refs.description.getValue();
strategy.parametersTemplate = {}; strategy.parametersTemplate = {};
const that = this;
this.state.parameters.forEach(parameter => { 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) { if (name) {
strategy.parametersTemplate[name] = 'string'; strategy.parametersTemplate[name] = 'string';
} }

View File

@ -52,7 +52,7 @@ const FeatureStore = Reflux.createStore({
} catch (e) { } catch (e) {
if (e instanceof SyntaxError) { if (e instanceof SyntaxError) {
// fall through; // fall through;
console.log('Syntax error!'); console.log('Syntax error!'); // eslint-disable-line no-console
} else { } else {
throw e; throw e;
} }

View File

@ -7,7 +7,7 @@ function readCookie(name) {
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];
while (c.charAt(0)==' ') { while (c.charAt(0)==' ') { // eslint-disable-line eqeqeq
c = c.substring(1, c.length); c = c.substring(1, c.length);
} }
if (c.indexOf(nameEQ) === 0) { if (c.indexOf(nameEQ) === 0) {

View File

@ -7,19 +7,19 @@ const Timer = function(cb, interval) {
Timer.prototype.start = function() { Timer.prototype.start = function() {
if (this.timerId != null) { 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.timerId = setInterval(this.cb, this.interval);
this.cb(); this.cb();
}; };
Timer.prototype.stop = function() { Timer.prototype.stop = function() {
if (this.timerId == null) { if (this.timerId == null) {
console.warn('no timer running'); console.warn('no timer running'); // eslint-disable-line no-console
} else { } else {
console.log('stopping timer'); console.log('stopping timer'); // eslint-disable-line no-console
clearInterval(this.timerId); clearInterval(this.timerId);
this.timerId = null; this.timerId = null;
} }