Updates linting rules

New linting rule to disable spaces after functions, before parens
Fixed all new linting errors

I suppose I'd like this to eventually get landed in official
`eslint-config-openstack` project, but for now it is here

Change-Id: I6c77524c5679117ce3b211db0bd9943c5ad5e646
This commit is contained in:
msmol 2016-09-22 15:22:47 -04:00 committed by msmol
parent 3221a3513d
commit 7c544e1460
9 changed files with 40 additions and 35 deletions

View File

@ -1 +1,6 @@
extends: openstack/es2015
rules:
space-before-function-paren:
- 2
- never

View File

@ -42,7 +42,7 @@ export default class Glance extends AbstractService {
* }
* @param {{}} endpointConfig The configuration element for a specific glance endpoint.
*/
constructor (endpointConfig) {
constructor(endpointConfig) {
// Sanity checks.
if (!endpointConfig || !endpointConfig.url) {
throw new Error('An endpoint configuration is required.');
@ -61,7 +61,7 @@ export default class Glance extends AbstractService {
* @param {String} token An authorization token, or a promise which will resolve into one.
* @returns {Promise.<T>} A promise which will resolve with the list of images.
*/
imageList (token = null) {
imageList(token = null) {
return this
._requestComponents(token)
.then(([url, headers]) => this.http.httpRequest('GET', `${url}images`, headers))

View File

@ -22,7 +22,7 @@ export default class Keystone extends AbstractService {
* @param {{}} cloudConfig The configuration object for a specific cloud.
* @see http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations
*/
constructor (cloudConfig) {
constructor(cloudConfig) {
// Sanity checks.
if (!cloudConfig) {
throw new Error('A configuration is required.');
@ -44,7 +44,7 @@ export default class Keystone extends AbstractService {
* @returns {String} The value found in the config, or null.
* @ignore
*/
_safeConfigGet (path) {
_safeConfigGet(path) {
let segments = path.split('.');
let pointer = this.cloudConfig;
while (segments.length > 0) {
@ -63,7 +63,7 @@ export default class Keystone extends AbstractService {
*
* @returns {Promise.<T>} A promise that will resolve with the list of API versions.
*/
versions () {
versions() {
return super.versions()
.then((versions) => versions.values);
}
@ -84,7 +84,7 @@ export default class Keystone extends AbstractService {
* @param {String} projectDomainName Domain name for the project, not required with project ID.
* @returns {Promise.<T>} A promise which will resolve with a valid token.
*/
tokenIssue (username = this._safeConfigGet('auth.username'),
tokenIssue(username = this._safeConfigGet('auth.username'),
password = this._safeConfigGet('auth.password'),
projectName = this._safeConfigGet('auth.project_name'),
userDomainName = this._safeConfigGet('auth.user_domain_id'),
@ -141,7 +141,7 @@ export default class Keystone extends AbstractService {
* @param {String} adminToken An optional admin token.
* @returns {Promise.<T>} A promise which will resolve if the token has been successfully revoked.
*/
tokenRevoke (token, adminToken = null) {
tokenRevoke(token, adminToken = null) {
return Promise
.all([this.serviceEndpoint(), token, adminToken])
.then(([url, token, adminToken]) => {
@ -159,7 +159,7 @@ export default class Keystone extends AbstractService {
* @param {String} token The authorization token.
* @returns {Promise.<T>} A promise which will resolve with the service catalog.
*/
catalogList (token = null) {
catalogList(token = null) {
return this
._requestComponents(token)
.then(([url, headers]) => this.http.httpRequest('GET', `${url}auth/catalog`, headers))

View File

@ -26,7 +26,7 @@ export default class AbstractService {
* @param {string} endpointUrl The endpoint URL.
* @param {Array} supportedVersions The list of all supported versions.
*/
constructor (endpointUrl, supportedVersions) {
constructor(endpointUrl, supportedVersions) {
this._endpointUrl = endpointUrl;
this._supportedVersions = supportedVersions;
}
@ -36,7 +36,7 @@ export default class AbstractService {
*
* @returns {Http} Our HTTP service instance.
*/
get http () {
get http() {
if (!this._http) {
this._http = new Http();
}
@ -48,7 +48,7 @@ export default class AbstractService {
*
* @returns {Array} The list of all supported versions, or empty array.
*/
get supportedVersions () {
get supportedVersions() {
return this._supportedVersions || [];
}
@ -57,7 +57,7 @@ export default class AbstractService {
*
* @returns {Promise.<T>} A promise that will resolve with the list of API versions.
*/
versions () {
versions() {
return new Promise((resolve, reject) => {
let promise = this.http
.httpGet(this._endpointUrl)
@ -85,7 +85,7 @@ export default class AbstractService {
*
* @returns {Promise.<T>} A promise that will resolve with the specific API version.
*/
version () {
version() {
return this
.versions()
.then((versions) => {
@ -103,7 +103,7 @@ export default class AbstractService {
*
* @returns {Promise.<T>|*} A promise which will resolve with the endpoint URL string.
*/
serviceEndpoint () {
serviceEndpoint() {
if (!this._endpointPromise) {
this._endpointPromise = this.version()
.then((version) => {
@ -130,7 +130,7 @@ export default class AbstractService {
* @returns {Promise} A promise which resolves with [url, token].
* @private
*/
_requestComponents (token = null) {
_requestComponents(token = null) {
// Make sure the token is a promise.
let headerPromise = Promise
.resolve(token)

View File

@ -41,14 +41,14 @@ export default class Http {
*
* @returns {{string: string}} A mapping of 'headerName': 'headerValue'
*/
get defaultHeaders () {
get defaultHeaders() {
return this._defaultHeaders;
}
/**
* Create a new HTTP handler.
*/
constructor () {
constructor() {
// Add default response interceptors.
this._defaultHeaders = {
'Content-Type': 'application/json'
@ -64,7 +64,7 @@ export default class Http {
* @param {{}} body The body. It will be JSON-Encoded by the handler.
* @returns {Promise} A promise which will resolve with the processed request response.
*/
httpRequest (method, url, headers = {}, body) {
httpRequest(method, url, headers = {}, body) {
// Sanitize the headers...
headers = Object.assign({}, headers, this.defaultHeaders);
@ -106,7 +106,7 @@ export default class Http {
* @param {String} url The request URL.
* @returns {Promise} A promise which will resolve with the processed request response.
*/
httpGet (url) {
httpGet(url) {
return this.httpRequest('GET', url, {}, null);
}
@ -117,7 +117,7 @@ export default class Http {
* @param {{}} body The body. It will be JSON-Encoded by the handler.
* @returns {Promise} A promise which will resolve with the processed request response.
*/
httpPut (url, body) {
httpPut(url, body) {
return this.httpRequest('PUT', url, {}, body);
}
@ -128,7 +128,7 @@ export default class Http {
* @param {{}} body The body. It will be JSON-Encoded by the handler.
* @returns {Promise} A promise which will resolve with the processed request response.
*/
httpPost (url, body) {
httpPost(url, body) {
return this.httpRequest('POST', url, {}, body);
}
@ -138,7 +138,7 @@ export default class Http {
* @param {String} url The request URL.
* @returns {Promise} A promise which will resolve with the processed request response.
*/
httpDelete (url) {
httpDelete(url) {
return this.httpRequest('DELETE', url, {}, null);
}
}

View File

@ -25,7 +25,7 @@ export default class Version {
*
* @returns {String|*|null} The name of the service, or null.
*/
get service () {
get service() {
return this._service || null;
}
@ -34,7 +34,7 @@ export default class Version {
*
* @returns {Number} The major version number
*/
get major () {
get major() {
return this._major || 0;
}
@ -43,7 +43,7 @@ export default class Version {
*
* @returns {Number} The minor version number
*/
get minor () {
get minor() {
return this._minor || 0;
}
@ -52,7 +52,7 @@ export default class Version {
*
* @returns {Number} The patch version number.
*/
get patch () {
get patch() {
return this._patch || 0;
}
@ -62,7 +62,7 @@ export default class Version {
* @param {String} service The name of the service.
* @param {String} versionString The version string for this service.
*/
constructor (service, versionString) {
constructor(service, versionString) {
// Sanitize input
if (typeof service !== 'string') {
service = undefined;
@ -97,7 +97,7 @@ export default class Version {
* @param {String|Version} version The version to compare to.
* @returns {boolean} True if they are exactly the same, otherwise false.
*/
equals (version) {
equals(version) {
if (!(version instanceof Version)) {
// is it a parseable string?
if (typeof version === 'string') {

View File

@ -37,7 +37,7 @@ const glanceConfig = {
*
* @returns {{}} A full FetchMock configuration for Glance's Root Resource.
*/
function rootResponse () {
function rootResponse() {
return {
method: 'GET',
matcher: 'http://192.168.99.99:9292/',
@ -108,7 +108,7 @@ function rootResponse () {
};
}
function imageList (token) {
function imageList(token) {
return {
method: 'GET',
matcher: 'http://192.168.99.99:9292/v2/images',

View File

@ -39,7 +39,7 @@ const cloudConfig = {
*
* @returns {{}} A full FetchMock configuration for Keystone's Root Resource.
*/
function rootResponse () {
function rootResponse() {
return {
method: 'GET',
matcher: 'http://192.168.99.99/',
@ -96,7 +96,7 @@ function rootResponse () {
};
}
function tokenIssue () {
function tokenIssue() {
return {
method: 'POST',
matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/tokens',
@ -375,7 +375,7 @@ function tokenIssue () {
};
}
function tokenRevoke (token, adminToken = null) {
function tokenRevoke(token, adminToken = null) {
return {
method: 'DELETE',
matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/tokens',
@ -389,7 +389,7 @@ function tokenRevoke (token, adminToken = null) {
};
}
function catalogList (token) {
function catalogList(token) {
return {
method: 'GET',
matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/catalog',

View File

@ -20,7 +20,7 @@ describe('Version', () => {
it("should parse various header versions", () => {
const testVersion = function (args, results) {
const testVersion = function(args, results) {
const v = new Version(...args);
expect(v.service).toBe(results[0]);
expect(v.major).toBe(results[1]);