Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Upgrade eslint-config-wikimedia to 0.28.2 and make pass #257

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/base_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class BaseService {

/**
* Get environment variable values or the defaults
*
* @param {Object|string} config configuration
* @return {string} env var value or default
* @private
Expand All @@ -317,6 +318,7 @@ class BaseService {

/**
* Loads the config from file, serialized input or Object
*
* @param {undefined|Object|string} conf a configuration.
* If undefined - config is loaded from config.yaml file
* If Object - treated as already parsed configuration
Expand Down Expand Up @@ -373,6 +375,7 @@ class BaseService {

/**
* Updates the config and sets instance properties.
*
* @param {undefined|Object|string} conf a configuration.
* If undefined - config is loaded from config.yaml file
* If Object - treated as already parsed configuration
Expand Down Expand Up @@ -437,6 +440,7 @@ class BaseService {
/**
* Exits the process with a provided exit code with a little delay
* to allow asynchronous logging to complete.
*
* @param {number} [returnCode=0] exit code
* @return {Promise}
* @protected
Expand Down
25 changes: 17 additions & 8 deletions lib/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SpawnError extends Error {
/**
* Wraps a child process spawn in a promise which resolves
* when the child process exists.
*
* @param {Array} args the command and its arguments to run (uses /usr/bin/env)
* @param {Object} options various execution options; attributes:
* - {Boolean} capture whether to capture stdout and return its contents
Expand Down Expand Up @@ -104,6 +105,7 @@ function promisedSpawn( args, options ) {

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

if ( customSourcePkgs.length ) {
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`;
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`;
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`; /**/
}

Expand Down Expand Up @@ -258,6 +259,7 @@ function createDockerFile() {

/**
* Spawns a docker process which (re)builds the image
*
* @return {Promise} the promise starting the build
*/
function buildImg() {
Expand All @@ -271,6 +273,7 @@ function buildImg() {

/**
* Starts the container and returns once it has finished executing
*
* @param {Array} args the array of extra parameters to pass, optional
* @param {boolean} hidePorts whether to keep the ports hidden inside the container, optional
* @return {Promise} the promise starting the container
Expand Down Expand Up @@ -303,6 +306,7 @@ function startContainer( args, hidePorts ) {
/**
* Verify that Docker is installed and that the minimum version is 1.8 (1.12 Mac)
* or terminate the runner.
*
* @return {boolean} true if Docker is installed and > min version
*/
function ensureDockerVersion() {
Expand Down Expand Up @@ -330,6 +334,7 @@ function ensureDockerVersion() {
* Updates the deploy repository to current master and
* rebuilds the node modules, committing and git-review-ing
* the result
*
* @return {Promise}
*/
function updateDeploy() {
Expand Down Expand Up @@ -450,8 +455,9 @@ function updateDeploy() {
opts.submodule_ref,
opts.submodule ] );
}
} ).then( () => // make sure the package.json symlink is in place
fs.symlinkAsync( `${ opts.submodule }/package.json`, 'package.json' )
} ).then(
// make sure the package.json symlink is in place
() => fs.symlinkAsync( `${ opts.submodule }/package.json`, 'package.json' )
.catch( () => {} ).then( () => promisedGit( [ 'add', 'package.json' ] ) ) ).then( () => {
if ( !opts.need_build ) {
return;
Expand Down Expand Up @@ -490,10 +496,12 @@ function updateDeploy() {
];
}
return promisedSpawn( findAttr, { capture: true, ignoreErr: true } );
} ).then( () => // add the built submodules
promisedGit( [ 'add', 'node_modules' ] ) );
} ).then( () => // commit the changes
promisedGit( [ 'commit', '-m', opts.commit_msg ] ) )
} ).then( // add the built submodules
() => promisedGit( [ 'add', 'node_modules' ] )
);
} )
// commit the changes
.then( () => promisedGit( [ 'commit', '-m', opts.commit_msg ] ) )
.then( () => {
if ( !opts.review ) {
console.log( '\n\nChanges are sitting in the sync-repo branch in' );
Expand All @@ -516,6 +524,7 @@ function updateDeploy() {

/**
* Determines the UID and GID to run under in the container
*
* @return {Promise} a promise resolving when the check is done
*/
function getUid() {
Expand Down
3 changes: 3 additions & 0 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class Logger {
*
* If the message should be logged, returns an object with bunyan log level
* and a specialized logger for the given component, otherwise returns undefined
*
* @param {string} levelPath a logging level + component (e.g. 'warn/component_name')
* @return {Object|undefined} corresponding bunyan log level and a specialized logger
* @private
Expand All @@ -268,6 +269,7 @@ class Logger {
*
* If the level is higher than the configured minimal level, returns it,
* Otherwise returns undefined.
*
* @param {string} level a logging level
* @return {string|undefined} corresponding bunyan log level
* @private
Expand Down Expand Up @@ -339,6 +341,7 @@ class Logger {

/**
* Logs and info object with a specified level
*
* @param {string} level Log level and components, for example 'trace/request'
* @param {Object|Function} info log statement object, or a callback to lazily construct
* the log statement after we've decided that this particular
Expand Down
6 changes: 3 additions & 3 deletions lib/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ class Master extends BaseService {

_start() {
// Start Prometheus Metrics Endpoint
const prometheus_config = this.config.metrics.find( ( o ) => {
return o.type === 'prometheus';
} );
const prometheus_config = this.config.metrics.find( ( o ) => o.type === 'prometheus' );
if ( prometheus_config ) {
this.prometheusServer = new PrometheusServer(
prometheus_config,
Expand Down Expand Up @@ -311,6 +309,7 @@ class Master extends BaseService {
/**
* Checks times of the heartbeats for each worker
* killing workers that were inactive for too long
*
* @private
*/
_setupHeartbeatCheck() {
Expand Down Expand Up @@ -343,6 +342,7 @@ class Master extends BaseService {

/**
* Saves the timestamp of a worker heartbeat
*
* @param {Object} worker
* @private
*/
Expand Down
4 changes: 1 addition & 3 deletions lib/metrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class Metrics {
}

fetchClient( name ) {
return this.clients.find( ( client ) => {
return client.constructor.name === name;
} );
return this.clients.find( ( client ) => client.constructor.name === name );
}

// Example Options:
Expand Down
3 changes: 3 additions & 0 deletions lib/ratelimiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class RateLimiterMaster {

/**
* Initialize the internal limiter.
*
* @return {Promise<RateLimiter>}
*/
setup() {
Expand Down Expand Up @@ -96,6 +97,7 @@ class RateLimiterWorker {

/**
* Synchronous limit check
*
* @param {string} key
* @param {number} limit
* @param {number} increment default 1
Expand All @@ -122,6 +124,7 @@ class RateLimiterWorker {

/**
* Checks whether we're above the limit without updating the counters.
*
* @param {string} key
* @param {number} limit
* @return {boolean} `true` if above the limit
Expand Down
15 changes: 8 additions & 7 deletions lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ class Worker extends BaseService {

_start() {
if ( cluster.isWorker ) {
cluster.worker.on( 'disconnect', () =>
this.stop()
.then( () => this._exitProcess( 0 ) ) );
cluster.worker.on(
'disconnect', () => this.stop().then( () => this._exitProcess( 0 ) )
);
}

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

return this._requireModule( service.module || service.name )
.then( ( svcMod ) => {
return service.entrypoint ?
svcMod[ service.entrypoint ]( opts ) : svcMod( opts );
} );
.then(
( svcMod ) => service.entrypoint ?
svcMod[ service.entrypoint ]( opts ) :
svcMod( opts )
);
} )
.then( ( res ) => {
let ret = res;
Expand Down
Loading
Loading