diff --git a/@xen-orchestra/cron/src/index.js b/@xen-orchestra/cron/src/index.js index 96725642c..f5925311d 100644 --- a/@xen-orchestra/cron/src/index.js +++ b/@xen-orchestra/cron/src/index.js @@ -44,7 +44,9 @@ class Schedule { this._createDate = zone.toLowerCase() === 'utc' ? moment.utc - : zone === 'local' ? moment : () => moment.tz(zone) + : zone === 'local' + ? moment + : () => moment.tz(zone) } createJob (fn) { diff --git a/@xen-orchestra/fs/src/checksum.js b/@xen-orchestra/fs/src/checksum.js index b99f7677b..dcb870440 100644 --- a/@xen-orchestra/fs/src/checksum.js +++ b/@xen-orchestra/fs/src/checksum.js @@ -85,8 +85,8 @@ export const validChecksumOfReadStream = ( callback( checksum !== expectedChecksum ? new Error( - `Bad checksum (${checksum}), expected: ${expectedChecksum}` - ) + `Bad checksum (${checksum}), expected: ${expectedChecksum}` + ) : null ) } diff --git a/packages/vhd-cli/src/commands/merge.js b/packages/vhd-cli/src/commands/merge.js index 6be19d4af..db319585e 100644 --- a/packages/vhd-cli/src/commands/merge.js +++ b/packages/vhd-cli/src/commands/merge.js @@ -14,7 +14,8 @@ export default async function main (args) { onProgress ({ done, total }) { if (bar === undefined) { bar = new Bar({ - format: 'merging [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}', + format: + 'merging [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}', }) bar.start(total, done) } else { diff --git a/packages/vhd-lib/src/createReadableSparseStream.js b/packages/vhd-lib/src/createReadableSparseStream.js index d5864ea21..edd96289c 100644 --- a/packages/vhd-lib/src/createReadableSparseStream.js +++ b/packages/vhd-lib/src/createReadableSparseStream.js @@ -58,7 +58,7 @@ export default asyncIteratorToStream(async function * ( const maxTableEntries = Math.ceil(diskSize / VHD_BLOCK_SIZE_BYTES) + 1 const tablePhysicalSizeBytes = - Math.ceil(maxTableEntries * 4 / SECTOR_SIZE) * SECTOR_SIZE + Math.ceil((maxTableEntries * 4) / SECTOR_SIZE) * SECTOR_SIZE const batPosition = FOOTER_SIZE + HEADER_SIZE const firstBlockPosition = batPosition + tablePhysicalSizeBytes @@ -115,7 +115,7 @@ export default asyncIteratorToStream(async function * ( } next.data.copy( currentBlockWithBitmap, - bitmapSize + next.offsetBytes % VHD_BLOCK_SIZE_BYTES + bitmapSize + (next.offsetBytes % VHD_BLOCK_SIZE_BYTES) ) } yield * yieldAndTrack(currentBlockWithBitmap) diff --git a/packages/vhd-lib/src/merge.js b/packages/vhd-lib/src/merge.js index f25edfeac..12595ad05 100644 --- a/packages/vhd-lib/src/merge.js +++ b/packages/vhd-lib/src/merge.js @@ -51,7 +51,10 @@ export default concurrency(2)(async function merge ( // finds first allocated block for the 2 following loops let firstBlock = 0 - while (firstBlock < maxTableEntries && !childVhd.containsBlock(firstBlock)) { + while ( + firstBlock < maxTableEntries && + !childVhd.containsBlock(firstBlock) + ) { ++firstBlock } diff --git a/packages/xen-api/examples/utils.js b/packages/xen-api/examples/utils.js index 688ae15cb..778010c51 100644 --- a/packages/xen-api/examples/utils.js +++ b/packages/xen-api/examples/utils.js @@ -30,14 +30,14 @@ exports.resolveRef = (xapi, type, refOrUuidOrNameLabel) => isOpaqueRef(refOrUuidOrNameLabel) ? refOrUuidOrNameLabel : xapi.call(`${type}.get_by_uuid`, refOrUuidOrNameLabel).catch(() => - xapi - .call(`${type}.get_by_name_label`, refOrUuidOrNameLabel) - .then(refs => { - if (refs.length === 1) { - return refs[0] - } - throw new Error( - `no single match for ${type} with name label ${refOrUuidOrNameLabel}` - ) - }) - ) + xapi + .call(`${type}.get_by_name_label`, refOrUuidOrNameLabel) + .then(refs => { + if (refs.length === 1) { + return refs[0] + } + throw new Error( + `no single match for ${type} with name label ${refOrUuidOrNameLabel}` + ) + }) + ) diff --git a/packages/xo-cli/src/index.js b/packages/xo-cli/src/index.js index ed375390c..17b4de1d4 100755 --- a/packages/xo-cli/src/index.js +++ b/packages/xo-cli/src/index.js @@ -308,8 +308,8 @@ async function listObjects (args) { const properties = getKeys(extractFlags(args)) const filterProperties = properties.length ? function (object) { - return pick(object, properties) - } + return pick(object, properties) + } : identity const filter = args.length ? parseParameters(args) : undefined diff --git a/packages/xo-collection/src/collection.js b/packages/xo-collection/src/collection.js index 6b7f6cb29..f64335331 100644 --- a/packages/xo-collection/src/collection.js +++ b/packages/xo-collection/src/collection.js @@ -8,7 +8,10 @@ import isObject from './is-object' // =================================================================== -const { create: createObject, prototype: { hasOwnProperty } } = Object +const { + create: createObject, + prototype: { hasOwnProperty }, +} = Object export const ACTION_ADD = 'add' export const ACTION_UPDATE = 'update' diff --git a/packages/xo-lib/example.js b/packages/xo-lib/example.js index 1a3d0d6ad..207ce8823 100644 --- a/packages/xo-lib/example.js +++ b/packages/xo-lib/example.js @@ -10,8 +10,7 @@ const xo = new Xo({ url: 'localhost:9000', }) -xo - .open() +xo.open() .then(function () { return xo .call('acl.get', {}) diff --git a/packages/xo-server-load-balancer/src/density-plan.js b/packages/xo-server-load-balancer/src/density-plan.js index 401119fb3..bccf7bac4 100644 --- a/packages/xo-server-load-balancer/src/density-plan.js +++ b/packages/xo-server-load-balancer/src/density-plan.js @@ -8,13 +8,10 @@ import { debug } from './utils' export default class DensityPlan extends Plan { _checkRessourcesThresholds (objects, averages) { const { low } = this._thresholds.memoryFree - return filter( - objects, - object => { - const { memory, memoryFree = memory } = averages[object.id] - return memoryFree > low - } - ) + return filter(objects, object => { + const { memory, memoryFree = memory } = averages[object.id] + return memoryFree > low + }) } async execute () { diff --git a/packages/xo-server-perf-alert/src/index.js b/packages/xo-server-perf-alert/src/index.js index e1d16ee70..33f07c69b 100644 --- a/packages/xo-server-perf-alert/src/index.js +++ b/packages/xo-server-perf-alert/src/index.js @@ -124,7 +124,7 @@ const SR_FUNCTIONS = { comparator: '>', createGetter: threshold => sr => { const getDisplayableValue = () => - sr.physical_utilisation * 100 / sr.physical_size + (sr.physical_utilisation * 100) / sr.physical_size return { getDisplayableValue, shouldAlarm: () => getDisplayableValue() > threshold, diff --git a/packages/xo-server-transport-nagios/src/index.js b/packages/xo-server-transport-nagios/src/index.js index 3f4b2ef63..e67306bfc 100644 --- a/packages/xo-server-transport-nagios/src/index.js +++ b/packages/xo-server-transport-nagios/src/index.js @@ -120,9 +120,13 @@ class XoServerNagios { const client = new net.Socket() - client.connect(this._conf.port, this._conf.server, () => { - console.log('Successful connection') - }) + client.connect( + this._conf.port, + this._conf.server, + () => { + console.log('Successful connection') + } + ) client.on('data', data => { const timestamp = data.readInt32BE(128) diff --git a/packages/xo-server-usage-report/src/index.js b/packages/xo-server-usage-report/src/index.js index 699de07b3..95b4657bc 100644 --- a/packages/xo-server-usage-report/src/index.js +++ b/packages/xo-server-usage-report/src/index.js @@ -201,7 +201,7 @@ function computePercentage (curr, prev, options) { opt => prev[opt] === 0 || prev[opt] === null ? 'NONE' - : `${(curr[opt] - prev[opt]) * 100 / prev[opt]}` + : `${((curr[opt] - prev[opt]) * 100) / prev[opt]}` ) ) } diff --git a/packages/xo-server/src/collection/redis.js b/packages/xo-server/src/collection/redis.js index 26dd386b9..5640a8900 100644 --- a/packages/xo-server/src/collection/redis.js +++ b/packages/xo-server/src/collection/redis.js @@ -83,14 +83,14 @@ export default class Redis extends Collection { values == null ? redis.srem(idsIndex, id) // entry no longer exists : asyncMap(indexes, index => { - const value = values[index] - if (value !== undefined) { - return redis.sadd( - `${prefix}_${index}:${String(value).toLowerCase()}`, - id - ) - } - }) + const value = values[index] + if (value !== undefined) { + return redis.sadd( + `${prefix}_${index}:${String(value).toLowerCase()}`, + id + ) + } + }) ) ) ) diff --git a/packages/xo-server/src/proxy-console.js b/packages/xo-server/src/proxy-console.js index 676cf13f1..52ecc4d42 100644 --- a/packages/xo-server/src/proxy-console.js +++ b/packages/xo-server/src/proxy-console.js @@ -58,16 +58,15 @@ export default function proxyConsole (ws, vmConsole, sessionId) { ws.close() }) - ws - .on('error', error => { - closed = true - debug( - 'error from the XO client: %s', - error.stack || error.message || error - ) + ws.on('error', error => { + closed = true + debug( + 'error from the XO client: %s', + error.stack || error.message || error + ) - socket.end() - }) + socket.end() + }) .on('message', data => { if (!closed) { socket.write(data) diff --git a/packages/xo-server/src/utils.spec.js b/packages/xo-server/src/utils.spec.js index b24775ad4..24eee18ce 100644 --- a/packages/xo-server/src/utils.spec.js +++ b/packages/xo-server/src/utils.spec.js @@ -100,7 +100,7 @@ describe('formatXml()', function () { describe('generateToken()', () => { it('generates a string', async () => { - expect(typeof await generateToken()).toBe('string') + expect(typeof (await generateToken())).toBe('string') }) }) diff --git a/packages/xo-server/src/xo-mixins/authentication.js b/packages/xo-server/src/xo-mixins/authentication.js index 958f30154..1374cd0a5 100644 --- a/packages/xo-server/src/xo-mixins/authentication.js +++ b/packages/xo-server/src/xo-mixins/authentication.js @@ -165,7 +165,7 @@ export default class { } async deleteAuthenticationToken (id) { - if (!await this._tokens.remove(id)) { + if (!(await this._tokens.remove(id))) { throw noSuchAuthenticationToken(id) } } diff --git a/packages/xo-server/src/xo-mixins/ip-pools.js b/packages/xo-server/src/xo-mixins/ip-pools.js index 2be6af2fc..8f3feb381 100644 --- a/packages/xo-server/src/xo-mixins/ip-pools.js +++ b/packages/xo-server/src/xo-mixins/ip-pools.js @@ -175,8 +175,8 @@ export default class IpPools { Promise.all(mapToArray(updatedIpPools, ipPool => this._save(ipPool))) return resourseSetId ? this._xo - .allocateLimitsInResourceSet(limits, resourseSetId) - .then(saveIpPools) + .allocateLimitsInResourceSet(limits, resourseSetId) + .then(saveIpPools) : saveIpPools() } })() diff --git a/packages/xo-server/src/xo-mixins/resource-sets.js b/packages/xo-server/src/xo-mixins/resource-sets.js index 43674619f..0330c0a3e 100644 --- a/packages/xo-server/src/xo-mixins/resource-sets.js +++ b/packages/xo-server/src/xo-mixins/resource-sets.js @@ -61,15 +61,15 @@ const normalize = set => ({ ipPools: set.ipPools || [], limits: set.limits ? map( - set.limits, - limit => - isObject(limit) - ? limit - : { - available: limit, - total: limit, - } - ) + set.limits, + limit => + isObject(limit) + ? limit + : { + available: limit, + total: limit, + } + ) : {}, name: set.name || '', objects: set.objects || [], diff --git a/packages/xo-server/src/xo-mixins/subjects.js b/packages/xo-server/src/xo-mixins/subjects.js index 7cce3f95c..3cb66c33e 100644 --- a/packages/xo-server/src/xo-mixins/subjects.js +++ b/packages/xo-server/src/xo-mixins/subjects.js @@ -64,7 +64,7 @@ export default class { ) ) - if (!await usersDb.exists()) { + if (!(await usersDb.exists())) { const email = 'admin@admin.net' const password = 'admin' @@ -229,7 +229,7 @@ export default class { } async changeUserPassword (userId, oldPassword, newPassword) { - if (!await this.checkUserPassword(userId, oldPassword, false)) { + if (!(await this.checkUserPassword(userId, oldPassword, false))) { throw invalidCredentials() } diff --git a/packages/xo-server/src/xo-mixins/xen-servers.js b/packages/xo-server/src/xo-mixins/xen-servers.js index 68b0f03b6..639bbda90 100644 --- a/packages/xo-server/src/xo-mixins/xen-servers.js +++ b/packages/xo-server/src/xo-mixins/xen-servers.js @@ -81,7 +81,7 @@ export default class { async unregisterXenServer (id) { ;this.disconnectXenServer(id)::ignoreErrors() - if (!await this._servers.remove(id)) { + if (!(await this._servers.remove(id))) { throw noSuchObject(id, 'xenServer') } } @@ -406,9 +406,10 @@ export default class { async mergeXenPools (sourceId, targetId, force = false) { const sourceXapi = this.getXapi(sourceId) - const { _auth: { user, password }, _url: { hostname } } = this.getXapi( - targetId - ) + const { + _auth: { user, password }, + _url: { hostname }, + } = this.getXapi(targetId) // We don't want the events of the source XAPI to interfere with // the events of the new XAPI. diff --git a/packages/xo-server/src/xo.js b/packages/xo-server/src/xo.js index bf3135d0a..ca41e61d7 100644 --- a/packages/xo-server/src/xo.js +++ b/packages/xo-server/src/xo.js @@ -58,7 +58,10 @@ export default class Xo extends EventEmitter { // Returns an object from its key or UUID. getObject (key, type) { - const { all, indexes: { byRef } } = this._objects + const { + all, + indexes: { byRef }, + } = this._objects const obj = all[key] || byRef[key] if (!obj) { diff --git a/packages/xo-web/gulpfile.js b/packages/xo-web/gulpfile.js index fa6962c8e..1b517a8fa 100644 --- a/packages/xo-web/gulpfile.js +++ b/packages/xo-web/gulpfile.js @@ -94,32 +94,32 @@ const src = lazyFn(function () { return PRODUCTION ? function src (pattern, opts) { - const base = resolve(opts && opts.base) + const base = resolve(opts && opts.base) - return gulp.src(pattern, { - base: base, - cwd: base, - passthrough: opts && opts.passthrough, - sourcemaps: opts && opts.sourcemaps, - }) - } - : function src (pattern, opts) { - const base = resolve(opts && opts.base) - - return pipe( - gulp.src(pattern, { + return gulp.src(pattern, { base: base, cwd: base, passthrough: opts && opts.passthrough, sourcemaps: opts && opts.sourcemaps, - }), - require('gulp-watch')(pattern, { - base: base, - cwd: base, - }), - require('gulp-plumber')() - ) - } + }) + } + : function src (pattern, opts) { + const base = resolve(opts && opts.base) + + return pipe( + gulp.src(pattern, { + base: base, + cwd: base, + passthrough: opts && opts.passthrough, + sourcemaps: opts && opts.sourcemaps, + }), + require('gulp-watch')(pattern, { + base: base, + cwd: base, + }), + require('gulp-plumber')() + ) + } }) // Similar to `gulp.dest()` but the output directory is relative to @@ -136,13 +136,13 @@ const dest = lazyFn(function () { return PRODUCTION ? function dest (path) { - return gulp.dest(resolve(path), opts) - } + return gulp.dest(resolve(path), opts) + } : function dest (path) { - const stream = gulp.dest(resolve(path), opts) - stream.pipe(livereload()) - return stream - } + const stream = gulp.dest(resolve(path), opts) + stream.pipe(livereload()) + return stream + } }) // =================================================================== diff --git a/packages/xo-web/src/common/json-schema-input/enum-input.js b/packages/xo-web/src/common/json-schema-input/enum-input.js index db900b185..0b755612f 100644 --- a/packages/xo-web/src/common/json-schema-input/enum-input.js +++ b/packages/xo-web/src/common/json-schema-input/enum-input.js @@ -43,7 +43,9 @@ export default class EnumInput extends Component { required={required} value={this._getSelectedIndex()} > - {_('noSelectedValue', message => )} + {_('noSelectedValue', message => ( + + ))} {map(enumNames, (name, index) => (