Skip to content

Commit 54e3bb8

Browse files
committed
build: Upgrade eslint-config-wikimedia to 0.28.2 and make pass
Almost all auto-fixes, with a few manual clean-ups. This is also an opportunity to commit the result of `npm audit fix`.
1 parent 8c99ad3 commit 54e3bb8

File tree

9 files changed

+1213
-747
lines changed

9 files changed

+1213
-747
lines changed

lib/base_service.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class BaseService {
294294

295295
/**
296296
* Get environment variable values or the defaults
297+
*
297298
* @param {Object|string} config configuration
298299
* @return {string} env var value or default
299300
* @private
@@ -317,6 +318,7 @@ class BaseService {
317318

318319
/**
319320
* Loads the config from file, serialized input or Object
321+
*
320322
* @param {undefined|Object|string} conf a configuration.
321323
* If undefined - config is loaded from config.yaml file
322324
* If Object - treated as already parsed configuration
@@ -373,6 +375,7 @@ class BaseService {
373375

374376
/**
375377
* Updates the config and sets instance properties.
378+
*
376379
* @param {undefined|Object|string} conf a configuration.
377380
* If undefined - config is loaded from config.yaml file
378381
* If Object - treated as already parsed configuration
@@ -437,6 +440,7 @@ class BaseService {
437440
/**
438441
* Exits the process with a provided exit code with a little delay
439442
* to allow asynchronous logging to complete.
443+
*
440444
* @param {number} [returnCode=0] exit code
441445
* @return {Promise}
442446
* @protected

lib/docker.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SpawnError extends Error {
3838
/**
3939
* Wraps a child process spawn in a promise which resolves
4040
* when the child process exists.
41+
*
4142
* @param {Array} args the command and its arguments to run (uses /usr/bin/env)
4243
* @param {Object} options various execution options; attributes:
4344
* - {Boolean} capture whether to capture stdout and return its contents
@@ -104,6 +105,7 @@ function promisedSpawn( args, options ) {
104105

105106
/**
106107
* Generates the Dockerfile used to build the image and start the container
108+
*
107109
* @return {Promise} the promise which creates the image file
108110
*/
109111
function createDockerFile() {
@@ -192,8 +194,7 @@ function createDockerFile() {
192194
contents += `RUN apt-get update && apt-get install -y ${ extraPkgs.join( ' ' ) } && rm -rf /var/lib/apt/lists/*\n`; /**/
193195

194196
if ( customSourcePkgs.length ) {
195-
contents += `RUN echo > /etc/apt/sources.list && ${ customSourcePkgs.map( ( customSourcePkgSpec ) =>
196-
`echo deb "${ customSourcePkgSpec.repo_url } ${ customSourcePkgSpec.release } ${ customSourcePkgSpec.pool }" >> /etc/apt/sources.list` ).join( ' && ' ) }\n`;
197+
contents += `RUN echo > /etc/apt/sources.list && ${ customSourcePkgs.map( ( customSourcePkgSpec ) => `echo deb "${ customSourcePkgSpec.repo_url } ${ customSourcePkgSpec.release } ${ customSourcePkgSpec.pool }" >> /etc/apt/sources.list` ).join( ' && ' ) }\n`;
197198
contents += `RUN apt-get update && ${ customSourcePkgs.map( ( customSourcePkgSpec ) => `apt-get install -y --force-yes -t ${ customSourcePkgSpec.release } ${ customSourcePkgSpec.packages.join( ' ' ) }` ).join( ' && ' ) } && rm -rf /var/lib/apt/lists/*\n`; /**/
198199
}
199200

@@ -258,6 +259,7 @@ function createDockerFile() {
258259

259260
/**
260261
* Spawns a docker process which (re)builds the image
262+
*
261263
* @return {Promise} the promise starting the build
262264
*/
263265
function buildImg() {
@@ -271,6 +273,7 @@ function buildImg() {
271273

272274
/**
273275
* Starts the container and returns once it has finished executing
276+
*
274277
* @param {Array} args the array of extra parameters to pass, optional
275278
* @param {boolean} hidePorts whether to keep the ports hidden inside the container, optional
276279
* @return {Promise} the promise starting the container
@@ -303,6 +306,7 @@ function startContainer( args, hidePorts ) {
303306
/**
304307
* Verify that Docker is installed and that the minimum version is 1.8 (1.12 Mac)
305308
* or terminate the runner.
309+
*
306310
* @return {boolean} true if Docker is installed and > min version
307311
*/
308312
function ensureDockerVersion() {
@@ -330,6 +334,7 @@ function ensureDockerVersion() {
330334
* Updates the deploy repository to current master and
331335
* rebuilds the node modules, committing and git-review-ing
332336
* the result
337+
*
333338
* @return {Promise}
334339
*/
335340
function updateDeploy() {
@@ -450,8 +455,9 @@ function updateDeploy() {
450455
opts.submodule_ref,
451456
opts.submodule ] );
452457
}
453-
} ).then( () => // make sure the package.json symlink is in place
454-
fs.symlinkAsync( `${ opts.submodule }/package.json`, 'package.json' )
458+
} ).then(
459+
// make sure the package.json symlink is in place
460+
() => fs.symlinkAsync( `${ opts.submodule }/package.json`, 'package.json' )
455461
.catch( () => {} ).then( () => promisedGit( [ 'add', 'package.json' ] ) ) ).then( () => {
456462
if ( !opts.need_build ) {
457463
return;
@@ -490,10 +496,12 @@ function updateDeploy() {
490496
];
491497
}
492498
return promisedSpawn( findAttr, { capture: true, ignoreErr: true } );
493-
} ).then( () => // add the built submodules
494-
promisedGit( [ 'add', 'node_modules' ] ) );
495-
} ).then( () => // commit the changes
496-
promisedGit( [ 'commit', '-m', opts.commit_msg ] ) )
499+
} ).then( // add the built submodules
500+
() => promisedGit( [ 'add', 'node_modules' ] )
501+
);
502+
} )
503+
// commit the changes
504+
.then( () => promisedGit( [ 'commit', '-m', opts.commit_msg ] ) )
497505
.then( () => {
498506
if ( !opts.review ) {
499507
console.log( '\n\nChanges are sitting in the sync-repo branch in' );
@@ -516,6 +524,7 @@ function updateDeploy() {
516524

517525
/**
518526
* Determines the UID and GID to run under in the container
527+
*
519528
* @return {Promise} a promise resolving when the check is done
520529
*/
521530
function getUid() {

lib/logger.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ class Logger {
245245
*
246246
* If the message should be logged, returns an object with bunyan log level
247247
* and a specialized logger for the given component, otherwise returns undefined
248+
*
248249
* @param {string} levelPath a logging level + component (e.g. 'warn/component_name')
249250
* @return {Object|undefined} corresponding bunyan log level and a specialized logger
250251
* @private
@@ -268,6 +269,7 @@ class Logger {
268269
*
269270
* If the level is higher than the configured minimal level, returns it,
270271
* Otherwise returns undefined.
272+
*
271273
* @param {string} level a logging level
272274
* @return {string|undefined} corresponding bunyan log level
273275
* @private
@@ -339,6 +341,7 @@ class Logger {
339341

340342
/**
341343
* Logs and info object with a specified level
344+
*
342345
* @param {string} level Log level and components, for example 'trace/request'
343346
* @param {Object|Function} info log statement object, or a callback to lazily construct
344347
* the log statement after we've decided that this particular

lib/master.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ class Master extends BaseService {
8989

9090
_start() {
9191
// Start Prometheus Metrics Endpoint
92-
const prometheus_config = this.config.metrics.find( ( o ) => {
93-
return o.type === 'prometheus';
94-
} );
92+
const prometheus_config = this.config.metrics.find( ( o ) => o.type === 'prometheus' );
9593
if ( prometheus_config ) {
9694
this.prometheusServer = new PrometheusServer(
9795
prometheus_config,
@@ -311,6 +309,7 @@ class Master extends BaseService {
311309
/**
312310
* Checks times of the heartbeats for each worker
313311
* killing workers that were inactive for too long
312+
*
314313
* @private
315314
*/
316315
_setupHeartbeatCheck() {
@@ -343,6 +342,7 @@ class Master extends BaseService {
343342

344343
/**
345344
* Saves the timestamp of a worker heartbeat
345+
*
346346
* @param {Object} worker
347347
* @private
348348
*/

lib/metrics/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ class Metrics {
6464
}
6565

6666
fetchClient( name ) {
67-
return this.clients.find( ( client ) => {
68-
return client.constructor.name === name;
69-
} );
67+
return this.clients.find( ( client ) => client.constructor.name === name );
7068
}
7169

7270
// Example Options:

lib/ratelimiter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class RateLimiterMaster {
3636

3737
/**
3838
* Initialize the internal limiter.
39+
*
3940
* @return {Promise<RateLimiter>}
4041
*/
4142
setup() {
@@ -96,6 +97,7 @@ class RateLimiterWorker {
9697

9798
/**
9899
* Synchronous limit check
100+
*
99101
* @param {string} key
100102
* @param {number} limit
101103
* @param {number} increment default 1
@@ -122,6 +124,7 @@ class RateLimiterWorker {
122124

123125
/**
124126
* Checks whether we're above the limit without updating the counters.
127+
*
125128
* @param {string} key
126129
* @param {number} limit
127130
* @return {boolean} `true` if above the limit

lib/worker.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ class Worker extends BaseService {
108108

109109
_start() {
110110
if ( cluster.isWorker ) {
111-
cluster.worker.on( 'disconnect', () =>
112-
this.stop()
113-
.then( () => this._exitProcess( 0 ) ) );
111+
cluster.worker.on(
112+
'disconnect', () => this.stop().then( () => this._exitProcess( 0 ) )
113+
);
114114
}
115115

116116
// Enable heap dumps in /tmp on kill -USR2.
@@ -189,10 +189,11 @@ class Worker extends BaseService {
189189
};
190190

191191
return this._requireModule( service.module || service.name )
192-
.then( ( svcMod ) => {
193-
return service.entrypoint ?
194-
svcMod[ service.entrypoint ]( opts ) : svcMod( opts );
195-
} );
192+
.then(
193+
( svcMod ) => service.entrypoint ?
194+
svcMod[ service.entrypoint ]( opts ) :
195+
svcMod( opts )
196+
);
196197
} )
197198
.then( ( res ) => {
198199
let ret = res;

0 commit comments

Comments
 (0)