diff --git a/gulpfile.js b/gulpfile.js index feec71a8d..08654290f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,12 +20,12 @@ var PRODUCTION = process.argv.indexOf('--production') !== -1 // =================================================================== function src (patterns) { - return PRODUCTION ? - gulp.src(patterns, { + return PRODUCTION + ? gulp.src(patterns, { base: SRC_DIR, cwd: SRC_DIR - }) : - watch(patterns, { + }) + : watch(patterns, { base: SRC_DIR, cwd: SRC_DIR, ignoreInitial: false, diff --git a/package.json b/package.json index d52c0432a..5dff01d54 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "must": "^0.12.0", "node-inspector": "^0.12.2", "sinon": "^1.14.1", - "standard": "^5.1.0" + "standard": "^5.2.1" }, "scripts": { "build": "gulp build --production", diff --git a/src/api/session.js b/src/api/session.js index 214918631..e5ff93359 100644 --- a/src/api/session.js +++ b/src/api/session.js @@ -53,9 +53,9 @@ signOut.permission = '' export async function getUser () { const userId = this.session.get('user_id') - return userId === undefined ? - null : - this.getUserPublicProperties(await this.getUser(userId)) + return userId === undefined + ? null + : this.getUserPublicProperties(await this.getUser(userId)) } getUser.description = 'return the currently connected user' diff --git a/src/collection.js b/src/collection.js index b43e65216..db1f6af41 100644 --- a/src/collection.js +++ b/src/collection.js @@ -39,7 +39,6 @@ export default class Collection extends EventEmitter { const array = isArray(models) if (!array) { models = [models] - } const {Model} = this @@ -60,16 +59,16 @@ export default class Collection extends EventEmitter { models = await this._add(models, opts) this.emit('add', models) - return array ? - models : - new this.Model(models[0]) + return array + ? models + : new this.Model(models[0]) } async first (properties) { if (!isObject(properties)) { - properties = (properties !== undefined) ? - { id: properties } : - {} + properties = (properties !== undefined) + ? { id: properties } + : {} } const model = await this._first(properties) @@ -78,9 +77,9 @@ export default class Collection extends EventEmitter { async get (properties) { if (!isObject(properties)) { - properties = (properties !== undefined) ? - { id: properties } : - {} + properties = (properties !== undefined) + ? { id: properties } + : {} } return await this._get(properties) @@ -131,9 +130,9 @@ export default class Collection extends EventEmitter { models = await this._update(models) this.emit('update', models) - return array ? - models : - new this.Model(models[0]) + return array + ? models + : new this.Model(models[0]) } // Methods to override in implementations. @@ -168,8 +167,8 @@ export default class Collection extends EventEmitter { async _first (properties) { const models = await this.get(properties) - return models.length ? - models[0] : - null + return models.length + ? models[0] + : null } } diff --git a/src/collection/redis.js b/src/collection/redis.js index 954ebb0a3..55d413a19 100644 --- a/src/collection/redis.js +++ b/src/collection/redis.js @@ -123,10 +123,9 @@ export default class Redis extends Collection { if (id !== undefined) { delete properties.id return this._extract([id]).then(models => { - return (models.length && !isEmpty(properties)) ? - filter(models) : - models - + return (models.length && !isEmpty(properties)) + ? filter(models) + : models }) } diff --git a/src/index.js b/src/index.js index 2f22f3aeb..acde6bf24 100644 --- a/src/index.js +++ b/src/index.js @@ -402,7 +402,6 @@ const setUpApi = (webSocketServer, xo) => { socket.send(data, onSend) } }) - }) return api diff --git a/src/models/remote.js b/src/models/remote.js index 41910e487..4183f747a 100644 --- a/src/models/remote.js +++ b/src/models/remote.js @@ -30,7 +30,9 @@ export class Remotes extends Collection { async get (properties) { const remotes = await super.get(properties) - forEach(remotes, remote => {remote.enabled = (remote.enabled === 'true')}) + forEach(remotes, remote => { + remote.enabled = (remote.enabled === 'true') + }) return remotes } } diff --git a/src/models/schedule.js b/src/models/schedule.js index 5194265a7..ae15b438b 100644 --- a/src/models/schedule.js +++ b/src/models/schedule.js @@ -30,7 +30,9 @@ export class Schedules extends Collection { async get (properties) { const schedules = await super.get(properties) - forEach(schedules, schedule => {schedule.enabled = (schedule.enabled === 'true')}) + forEach(schedules, schedule => { + schedule.enabled = (schedule.enabled === 'true') + }) return schedules } } diff --git a/src/xapi-objects-to-xo.js b/src/xapi-objects-to-xo.js index 23a42bce9..4bcc255e5 100644 --- a/src/xapi-objects-to-xo.js +++ b/src/xapi-objects-to-xo.js @@ -155,9 +155,9 @@ export function vm (obj) { CPUs: { max: +obj.VCPUs_max, number: ( - isRunning && metrics ? - +metrics.VCPUs_number : - +obj.VCPUs_at_startup + isRunning && metrics + ? +metrics.VCPUs_number + : +obj.VCPUs_at_startup ) }, current_operations: obj.current_operations, @@ -228,9 +228,9 @@ export function vm (obj) { VIFs: link(obj, 'VIFs'), $container: ( - isRunning ? - link(obj, 'resident_on') : - link(obj, 'pool') // TODO: handle local VMs (`VM.get_possible_hosts()`). + isRunning + ? link(obj, 'resident_on') + : link(obj, 'pool') // TODO: handle local VMs (`VM.get_possible_hosts()`). ), $VBDs: link(obj, 'VBDs'), @@ -294,9 +294,9 @@ export function sr (obj) { VDIs: link(obj, 'VDIs'), $container: ( - obj.shared ? - link(obj, 'pool') : - obj.$PBDs[0] && link(obj.$PBDs[0], 'host') + obj.shared + ? link(obj, 'pool') + : obj.$PBDs[0] && link(obj.$PBDs[0], 'host') ), $PBDs: link(obj, 'PBDs') } diff --git a/src/xapi.js b/src/xapi.js index c54cde598..6319a2fd2 100644 --- a/src/xapi.js +++ b/src/xapi.js @@ -416,7 +416,6 @@ export default class Xapi extends XapiBase { async _cloneVm (vm, nameLabel = vm.name_label) { return await this.call('VM.clone', vm.$ref, nameLabel) - } async _snapshotVm (vm, nameLabel = vm.name_label) { @@ -436,9 +435,9 @@ export default class Xapi extends XapiBase { async copyVm (vmId, srId = null, nameLabel = undefined) { const vm = this.getObject(vmId) - const srRef = (srId == null) ? - '' : - this.getObject(srId).$ref + const srRef = (srId == null) + ? '' + : this.getObject(srId).$ref return await this._getOrWaitObject( await this.call('VM.copy', vm.$ref, nameLabel || vm.nameLabel, srRef) @@ -681,9 +680,9 @@ export default class Xapi extends XapiBase { if (type === 'CD') { // Choose position 3 if allowed. - position = includes(allowed, '3') ? - '3' : - allowed[0] + position = includes(allowed, '3') + ? '3' + : allowed[0] } else { position = allowed[0] diff --git a/src/xo.js b/src/xo.js index 17f7f8033..b19b71c57 100644 --- a/src/xo.js +++ b/src/xo.js @@ -634,7 +634,9 @@ export default class Xo extends EventEmitter { async syncAllRemotes () { const remotes = await this.getAllRemotes() - forEach(remotes, remote => {this.updateRemote(remote.id, {})}) + forEach(remotes, remote => { + this.updateRemote(remote.id, {}) + }) } async disableAllRemotes () { @@ -968,9 +970,9 @@ export default class Xo extends EventEmitter { return generateToken().then(token => { const url = `/api/${token}` - return url in watchers ? - generateUniqueUrl() : - url + return url in watchers + ? generateUniqueUrl() + : url }) })() @@ -1048,13 +1050,13 @@ export default class Xo extends EventEmitter { if (isString(opts)) { opts = parseUrl(opts) } else { - opts.method = opts.method != null ? - opts.method.toUpperCase() : - 'GET' + opts.method = opts.method != null + ? opts.method.toUpperCase() + : 'GET' - opts.proxyMethod = opts.proxyMethod != null ? - opts.proxyMethod.toUpperCase() : - opts.method + opts.proxyMethod = opts.proxyMethod != null + ? opts.proxyMethod.toUpperCase() + : opts.method } opts.createdAt = Date.now()