Skip to content

Commit 58d05c2

Browse files
committed
Auto-fix space-in-parens and comma-dangle throughout library
1 parent 1bd9c85 commit 58d05c2

19 files changed

+135
-132
lines changed

lib/autodiscovery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ function locateAPIRootHeader( response ) {
3232
}
3333

3434
module.exports = {
35-
locateAPIRootHeader: locateAPIRootHeader
35+
locateAPIRootHeader: locateAPIRootHeader,
3636
};

lib/constructors/wp-request.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ function WPRequest( options ) {
3636
'headers',
3737
'username',
3838
'password',
39-
'nonce'
40-
].reduce(function( localOptions, key ) {
39+
'nonce',
40+
].reduce( function( localOptions, key ) {
4141
if ( options && options[ key ] ) {
4242
localOptions[ key ] = options[ key ];
4343
}
4444
return localOptions;
45-
}, {});
45+
}, {} );
4646

4747
/**
4848
* The HTTP transport methods (.get, .post, .put, .delete, .head) to use for this request
@@ -127,13 +127,13 @@ function prepareTaxonomies( taxonomyFilters ) {
127127

128128
return objectReduce( taxonomyFilters, function( result, terms, key ) {
129129
// Trim whitespace and concatenate multiple terms with +
130-
result[ key ] = terms.map(function( term ) {
130+
result[ key ] = terms.map( function( term ) {
131131
// Coerce term into a string so that trim() won't fail
132132
return ( term + '' ).trim().toLowerCase();
133-
}).join( '+' );
133+
} ).join( '+' );
134134

135135
return result;
136-
}, {});
136+
}, {} );
137137
}
138138

139139
/**
@@ -161,7 +161,7 @@ function populated( obj ) {
161161
values[ key ] = val;
162162
}
163163
return values;
164-
}, {});
164+
}, {} );
165165
}
166166

167167
/**
@@ -180,7 +180,7 @@ function validatePathLevel( levelDefinitions, levelContents ) {
180180
// One "level" may have multiple options, as a route tree is a branching
181181
// structure. We consider a level "valid" if the provided levelContents
182182
// match any of the available validators.
183-
var valid = levelDefinitions.reduce(function( anyOptionValid, levelOption ) {
183+
var valid = levelDefinitions.reduce( function( anyOptionValid, levelOption ) {
184184
if ( ! levelOption.validate ) {
185185
// If there is no validator function, the level is implicitly valid
186186
return true;
@@ -189,14 +189,14 @@ function validatePathLevel( levelDefinitions, levelContents ) {
189189
}, false );
190190

191191
if ( ! valid ) {
192-
throw new Error([
192+
throw new Error( [
193193
'Invalid path component:',
194194
levelContents,
195195
// awkward pluralization support:
196196
'does not match' + ( levelDefinitions.length > 1 ? ' any of' : '' ),
197-
levelDefinitions.reduce(function( components, levelOption ) {
197+
levelDefinitions.reduce( function( components, levelOption ) {
198198
return components.concat( levelOption.component );
199-
}, [] ).join( ', ' )
199+
}, [] ).join( ', ' ),
200200
].join( ' ' ) );
201201
}
202202
}
@@ -254,19 +254,19 @@ WPRequest.prototype._renderPath = function() {
254254

255255
var pathParts = this._path;
256256
var orderedPathParts = Object.keys( pathParts )
257-
.sort(function( a, b ) {
257+
.sort( function( a, b ) {
258258
var intA = parseInt( a, 10 );
259259
var intB = parseInt( b, 10 );
260260
return intA - intB;
261-
})
262-
.map(function( pathPartKey ) {
261+
} )
262+
.map( function( pathPartKey ) {
263263
return pathParts[ pathPartKey ];
264-
});
264+
} );
265265

266266
// Combine all parts of the path together, filtered to omit any components
267267
// that are unspecified or empty strings, to create the full path template
268268
var path = [
269-
this._namespace
269+
this._namespace,
270270
].concat( orderedPathParts ).filter( identity ).join( '/' );
271271

272272
return path;
@@ -330,12 +330,12 @@ WPRequest.prototype.setPathPart = function( level, val ) {
330330
WPRequest.prototype.validatePath = function() {
331331
// Iterate through all _specified_ levels of this endpoint
332332
var specifiedLevels = Object.keys( this._path )
333-
.map(function( level ) {
333+
.map( function( level ) {
334334
return parseInt( level, 10 );
335-
})
336-
.filter(function( pathPartKey ) {
335+
} )
336+
.filter( function( pathPartKey ) {
337337
return ! isNaN( pathPartKey );
338-
});
338+
} );
339339

340340
var maxLevel = Math.max.apply( null, specifiedLevels );
341341

@@ -391,7 +391,7 @@ WPRequest.prototype.param = function( props, value ) {
391391
}
392392

393393
// Iterate through the properties
394-
Object.keys( props ).forEach(function( key ) {
394+
Object.keys( props ).forEach( function( key ) {
395395
var value = props[ key ];
396396

397397
// Arrays should be de-duped and sorted
@@ -401,7 +401,7 @@ WPRequest.prototype.param = function( props, value ) {
401401

402402
// Set the value
403403
this._params[ key ] = value;
404-
}.bind( this ));
404+
}.bind( this ) );
405405

406406
return this;
407407
};

lib/data/simplify-object.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ function simplifyObject( obj ) {
4242
newObj.args = objectReduce( val, function( slimArgs, argVal, argKey ) {
4343
slimArgs[ argKey ] = {};
4444
return slimArgs;
45-
}, {});
45+
}, {} );
4646
} else {
4747
// Pass all other objects through simplifyObject
4848
newObj[ key ] = simplifyObject( obj[ key ] );
4949
}
5050
return newObj;
51-
}, {});
51+
}, {} );
5252
}
5353

5454
// All other types pass through without modification

lib/data/update-default-routes-json.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
* application's directory. The name of the output file can be customized with
6666
* the `--file` option.
6767
*/
68+
/* eslint-disable no-console */
6869
'use strict';
6970
7071
var agent = require( 'superagent' );
@@ -95,7 +96,7 @@ function getJSON( cbFn ) {
9596
agent
9697
.get( endpoint )
9798
.set( 'Accept', 'application/json' )
98-
.end(function( err, res ) {
99+
.end( function( err, res ) {
99100
// Inspect the error and then the response to infer various error states
100101
if ( err ) {
101102
console.error( '\nSomething went wrong! Could not download endpoint JSON.' );
@@ -115,7 +116,7 @@ function getJSON( cbFn ) {
115116
}
116117

117118
cbFn( res );
118-
});
119+
} );
119120
}
120121

121122
// The only assumption we want to make about the URL is that it should be a web
@@ -137,7 +138,7 @@ fs.stat( outputPath, function( err, stats ) {
137138
}
138139
139140
// If we made it this far, our arguments look good! Carry on.
140-
getJSON(function( response ) {
141+
getJSON( function( response ) {
141142
// Extract the JSON
142143
var endpointJSON = JSON.parse( JSON.stringify( response.body ) );
143144
// Simplify the JSON structure and pick out the routes dictionary
@@ -151,6 +152,6 @@ fs.stat( outputPath, function( err, stats ) {
151152
return process.exit( 1 );
152153
}
153154
console.log( '\nSuccessfully saved ' + outputFilePath );
154-
});
155-
});
156-
});
155+
} );
156+
} );
157+
} );

lib/endpoint-factories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ function generateEndpointFactories( routesByNamespace ) {
5555
}
5656

5757
module.exports = {
58-
generate: generateEndpointFactories
58+
generate: generateEndpointFactories,
5959
};

lib/endpoint-request.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,29 @@ function createEndpointRequest( handlerSpec, resource, namespace ) {
4545
// Mix in all available shortcut methods for GET request query parameters that
4646
// are valid within this endpoint tree
4747
if ( typeof handlerSpec._getArgs === 'object' ) {
48-
Object.keys( handlerSpec._getArgs ).forEach(function( supportedQueryParam ) {
48+
Object.keys( handlerSpec._getArgs ).forEach( function( supportedQueryParam ) {
4949
var mixinsForParam = mixins[ supportedQueryParam ];
5050

5151
// Only proceed if there is a mixin available AND the specified mixins will
5252
// not overwrite any previously-set prototype method
5353
if ( typeof mixinsForParam === 'object' ) {
54-
Object.keys( mixinsForParam ).forEach(function( methodName ) {
54+
Object.keys( mixinsForParam ).forEach( function( methodName ) {
5555
applyMixin( EndpointRequest.prototype, methodName, mixinsForParam[ methodName ] );
56-
});
56+
} );
5757
}
58-
});
58+
} );
5959
}
6060

61-
Object.keys( handlerSpec._setters ).forEach(function( setterFnName ) {
61+
Object.keys( handlerSpec._setters ).forEach( function( setterFnName ) {
6262
// Only assign setter functions if they do not overwrite preexisting methods
6363
if ( ! EndpointRequest.prototype[ setterFnName ] ) {
6464
EndpointRequest.prototype[ setterFnName ] = handlerSpec._setters[ setterFnName ];
6565
}
66-
});
66+
} );
6767

6868
return EndpointRequest;
6969
}
7070

7171
module.exports = {
72-
create: createEndpointRequest
72+
create: createEndpointRequest,
7373
};

lib/http-transport.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function createPaginationObject( result, options, httpTransport ) {
169169
_paging = {
170170
total: result.headers[ 'x-wp-total' ],
171171
totalPages: totalPages,
172-
links: links
172+
links: links,
173173
};
174174

175175
// Re-use any options from the original request, updating only the endpoint
@@ -180,16 +180,16 @@ function createPaginationObject( result, options, httpTransport ) {
180180
if ( links.next ) {
181181
_paging.next = new WPRequest( extend( {}, options, {
182182
transport: httpTransport,
183-
endpoint: mergeUrl( endpoint, links.next )
184-
}));
183+
endpoint: mergeUrl( endpoint, links.next ),
184+
} ) );
185185
}
186186

187187
// Create a WPRequest instance pre-bound to the "prev" page, if available
188188
if ( links.prev ) {
189189
_paging.prev = new WPRequest( extend( {}, options, {
190190
transport: httpTransport,
191-
endpoint: mergeUrl( endpoint, links.prev )
192-
}));
191+
endpoint: mergeUrl( endpoint, links.prev ),
192+
} ) );
193193
}
194194

195195
return _paging;
@@ -209,18 +209,18 @@ function createPaginationObject( result, options, httpTransport ) {
209209
* @returns {Promise} A promise to the superagent request
210210
*/
211211
function invokeAndPromisify( request, callback, transform ) {
212-
return new Promise(function( resolve, reject ) {
212+
return new Promise( function( resolve, reject ) {
213213
// Fire off the result
214-
request.end(function( err, result ) {
214+
request.end( function( err, result ) {
215215

216216
// Return the results as a promise
217217
if ( err || result.error ) {
218218
reject( err || result.error );
219219
} else {
220220
resolve( result );
221221
}
222-
});
223-
}).then( transform ).then(function( result ) {
222+
} );
223+
} ).then( transform ).then( function( result ) {
224224
// If a node-style callback was provided, call it, but also return the
225225
// result value for use via the returned Promise
226226
if ( callback && typeof callback === 'function' ) {
@@ -244,7 +244,7 @@ function invokeAndPromisify( request, callback, transform ) {
244244
} else {
245245
throw err;
246246
}
247-
});
247+
} );
248248
}
249249

250250
/**
@@ -386,5 +386,5 @@ module.exports = {
386386
get: _httpGet,
387387
head: _httpHead,
388388
post: _httpPost,
389-
put: _httpPut
389+
put: _httpPut,
390390
};

lib/mixins/filters.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ filterMixins.taxonomy = function( taxonomy, term ) {
7777
/* jshint validthis:true */
7878
var termIsArray = Array.isArray( term );
7979
var termIsNumber = termIsArray ?
80-
term.reduce(function( allAreNumbers, term ) {
80+
term.reduce( function( allAreNumbers, term ) {
8181
return allAreNumbers && typeof term === 'number';
8282
}, true ) :
8383
typeof term === 'number';
8484
var termIsString = termIsArray ?
85-
term.reduce(function( allAreStrings, term ) {
85+
term.reduce( function( allAreStrings, term ) {
8686
return allAreStrings && typeof term === 'string';
8787
}, true ) :
8888
typeof term === 'string';

lib/mixins/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ var mixins = {
1919
categories: {
2020
categories: parameterMixins.categories,
2121
/** @deprecated use .categories() */
22-
category: parameterMixins.category
22+
category: parameterMixins.category,
2323
},
2424
categories_exclude: {
25-
excludeCategories: parameterMixins.excludeCategories
25+
excludeCategories: parameterMixins.excludeCategories,
2626
},
2727
tags: {
2828
tags: parameterMixins.tags,
2929
/** @deprecated use .tags() */
30-
tag: parameterMixins.tag
30+
tag: parameterMixins.tag,
3131
},
3232
tags_exclude: {
33-
excludeTags: parameterMixins.excludeTags
33+
excludeTags: parameterMixins.excludeTags,
3434
},
3535
filter: filterMixins,
3636
post: {
3737
post: parameterMixins.post,
3838
/** @deprecated use .post() */
39-
forPost: parameterMixins.post
40-
}
39+
forPost: parameterMixins.post,
40+
},
4141
};
4242

4343
// All of these parameter mixins use a setter function named identically to the
@@ -51,10 +51,10 @@ var mixins = {
5151
'parent',
5252
'password',
5353
'status',
54-
'sticky'
55-
].forEach(function( mixinName ) {
54+
'sticky',
55+
].forEach( function( mixinName ) {
5656
mixins[ mixinName ] = {};
5757
mixins[ mixinName ][ mixinName ] = parameterMixins[ mixinName ];
58-
});
58+
} );
5959

6060
module.exports = mixins;

lib/path-part-setter.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ function createPathPartSetter( node ) {
2121
var nodeName = node.names[ 0 ];
2222
var supportedMethods = node.methods || [];
2323
var dynamicChildren = node.children ? Object.keys( node.children )
24-
.map(function( key ) {
24+
.map( function( key ) {
2525
return node.children[ key ];
26-
})
27-
.filter(function( childNode ) {
26+
} )
27+
.filter( function( childNode ) {
2828
return childNode.namedGroup === true;
29-
}) : [];
29+
} ) : [];
3030
var dynamicChild = dynamicChildren.length === 1 && dynamicChildren[ 0 ];
3131
var dynamicChildLevel = dynamicChild && dynamicChild.level;
3232

@@ -87,5 +87,5 @@ function createPathPartSetter( node ) {
8787
}
8888

8989
module.exports = {
90-
create: createPathPartSetter
90+
create: createPathPartSetter,
9191
};

0 commit comments

Comments
 (0)