From 7c544e14601a5a3bc3192e9fbb3e10ab922a9251 Mon Sep 17 00:00:00 2001 From: msmol Date: Thu, 22 Sep 2016 15:22:47 -0400 Subject: [PATCH] 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 --- .eslintrc | 5 +++++ src/glance.js | 4 ++-- src/keystone.js | 12 ++++++------ src/util/abstractService.js | 14 +++++++------- src/util/http.js | 14 +++++++------- src/util/version.js | 12 ++++++------ test/unit/helpers/data/glance.js | 4 ++-- test/unit/helpers/data/keystone.js | 8 ++++---- test/unit/util/versionTest.js | 2 +- 9 files changed, 40 insertions(+), 35 deletions(-) diff --git a/.eslintrc b/.eslintrc index 7108359..b563c6c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1 +1,6 @@ extends: openstack/es2015 + +rules: + space-before-function-paren: + - 2 + - never diff --git a/src/glance.js b/src/glance.js index adb3981..33521e2 100644 --- a/src/glance.js +++ b/src/glance.js @@ -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.} 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)) diff --git a/src/keystone.js b/src/keystone.js index cc5603a..5f8a7af 100644 --- a/src/keystone.js +++ b/src/keystone.js @@ -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.} 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.} 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.} 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.} 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)) diff --git a/src/util/abstractService.js b/src/util/abstractService.js index aba087f..0a1654d 100644 --- a/src/util/abstractService.js +++ b/src/util/abstractService.js @@ -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.} 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.} 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.|*} 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) diff --git a/src/util/http.js b/src/util/http.js index cb7815b..8369198 100644 --- a/src/util/http.js +++ b/src/util/http.js @@ -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); } } diff --git a/src/util/version.js b/src/util/version.js index 3d1e41e..cb92cd2 100644 --- a/src/util/version.js +++ b/src/util/version.js @@ -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') { diff --git a/test/unit/helpers/data/glance.js b/test/unit/helpers/data/glance.js index 64e1558..b8623c6 100644 --- a/test/unit/helpers/data/glance.js +++ b/test/unit/helpers/data/glance.js @@ -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', diff --git a/test/unit/helpers/data/keystone.js b/test/unit/helpers/data/keystone.js index a77b203..e10d082 100644 --- a/test/unit/helpers/data/keystone.js +++ b/test/unit/helpers/data/keystone.js @@ -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', diff --git a/test/unit/util/versionTest.js b/test/unit/util/versionTest.js index 64363c9..e23f518 100644 --- a/test/unit/util/versionTest.js +++ b/test/unit/util/versionTest.js @@ -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]);