Browse Source

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
msmol 2 years ago
parent
commit
7c544e1460

+ 5
- 0
.eslintrc View File

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

+ 2
- 2
src/glance.js View File

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

+ 6
- 6
src/keystone.js View File

@@ -22,7 +22,7 @@ export default class Keystone extends AbstractService {
22 22
    * @param {{}} cloudConfig The configuration object for a specific cloud.
23 23
    * @see http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations
24 24
    */
25
-  constructor (cloudConfig) {
25
+  constructor(cloudConfig) {
26 26
     // Sanity checks.
27 27
     if (!cloudConfig) {
28 28
       throw new Error('A configuration is required.');
@@ -44,7 +44,7 @@ export default class Keystone extends AbstractService {
44 44
    * @returns {String} The value found in the config, or null.
45 45
    * @ignore
46 46
    */
47
-  _safeConfigGet (path) {
47
+  _safeConfigGet(path) {
48 48
     let segments = path.split('.');
49 49
     let pointer = this.cloudConfig;
50 50
     while (segments.length > 0) {
@@ -63,7 +63,7 @@ export default class Keystone extends AbstractService {
63 63
    *
64 64
    * @returns {Promise.<T>} A promise that will resolve with the list of API versions.
65 65
    */
66
-  versions () {
66
+  versions() {
67 67
     return super.versions()
68 68
       .then((versions) => versions.values);
69 69
   }
@@ -84,7 +84,7 @@ export default class Keystone extends AbstractService {
84 84
    * @param {String} projectDomainName Domain name for the project, not required with project ID.
85 85
    * @returns {Promise.<T>} A promise which will resolve with a valid token.
86 86
    */
87
-  tokenIssue (username = this._safeConfigGet('auth.username'),
87
+  tokenIssue(username = this._safeConfigGet('auth.username'),
88 88
               password = this._safeConfigGet('auth.password'),
89 89
               projectName = this._safeConfigGet('auth.project_name'),
90 90
               userDomainName = this._safeConfigGet('auth.user_domain_id'),
@@ -141,7 +141,7 @@ export default class Keystone extends AbstractService {
141 141
    * @param {String} adminToken An optional admin token.
142 142
    * @returns {Promise.<T>} A promise which will resolve if the token has been successfully revoked.
143 143
    */
144
-  tokenRevoke (token, adminToken = null) {
144
+  tokenRevoke(token, adminToken = null) {
145 145
     return Promise
146 146
       .all([this.serviceEndpoint(), token, adminToken])
147 147
       .then(([url, token, adminToken]) => {
@@ -159,7 +159,7 @@ export default class Keystone extends AbstractService {
159 159
    * @param {String} token The authorization token.
160 160
    * @returns {Promise.<T>} A promise which will resolve with the service catalog.
161 161
    */
162
-  catalogList (token = null) {
162
+  catalogList(token = null) {
163 163
     return this
164 164
       ._requestComponents(token)
165 165
       .then(([url, headers]) => this.http.httpRequest('GET', `${url}auth/catalog`, headers))

+ 7
- 7
src/util/abstractService.js View File

@@ -26,7 +26,7 @@ export default class AbstractService {
26 26
    * @param {string} endpointUrl The endpoint URL.
27 27
    * @param {Array} supportedVersions The list of all supported versions.
28 28
    */
29
-  constructor (endpointUrl, supportedVersions) {
29
+  constructor(endpointUrl, supportedVersions) {
30 30
     this._endpointUrl = endpointUrl;
31 31
     this._supportedVersions = supportedVersions;
32 32
   }
@@ -36,7 +36,7 @@ export default class AbstractService {
36 36
    *
37 37
    * @returns {Http} Our HTTP service instance.
38 38
    */
39
-  get http () {
39
+  get http() {
40 40
     if (!this._http) {
41 41
       this._http = new Http();
42 42
     }
@@ -48,7 +48,7 @@ export default class AbstractService {
48 48
    *
49 49
    * @returns {Array} The list of all supported versions, or empty array.
50 50
    */
51
-  get supportedVersions () {
51
+  get supportedVersions() {
52 52
     return this._supportedVersions || [];
53 53
   }
54 54
 
@@ -57,7 +57,7 @@ export default class AbstractService {
57 57
    *
58 58
    * @returns {Promise.<T>} A promise that will resolve with the list of API versions.
59 59
    */
60
-  versions () {
60
+  versions() {
61 61
     return new Promise((resolve, reject) => {
62 62
       let promise = this.http
63 63
         .httpGet(this._endpointUrl)
@@ -85,7 +85,7 @@ export default class AbstractService {
85 85
    *
86 86
    * @returns {Promise.<T>} A promise that will resolve with the specific API version.
87 87
    */
88
-  version () {
88
+  version() {
89 89
     return this
90 90
       .versions()
91 91
       .then((versions) => {
@@ -103,7 +103,7 @@ export default class AbstractService {
103 103
    *
104 104
    * @returns {Promise.<T>|*} A promise which will resolve with the endpoint URL string.
105 105
    */
106
-  serviceEndpoint () {
106
+  serviceEndpoint() {
107 107
     if (!this._endpointPromise) {
108 108
       this._endpointPromise = this.version()
109 109
         .then((version) => {
@@ -130,7 +130,7 @@ export default class AbstractService {
130 130
    * @returns {Promise} A promise which resolves with [url, token].
131 131
    * @private
132 132
    */
133
-  _requestComponents (token = null) {
133
+  _requestComponents(token = null) {
134 134
     // Make sure the token is a promise.
135 135
     let headerPromise = Promise
136 136
       .resolve(token)

+ 7
- 7
src/util/http.js View File

@@ -41,14 +41,14 @@ export default class Http {
41 41
    *
42 42
    * @returns {{string: string}} A mapping of 'headerName': 'headerValue'
43 43
    */
44
-  get defaultHeaders () {
44
+  get defaultHeaders() {
45 45
     return this._defaultHeaders;
46 46
   }
47 47
 
48 48
   /**
49 49
    * Create a new HTTP handler.
50 50
    */
51
-  constructor () {
51
+  constructor() {
52 52
     // Add default response interceptors.
53 53
     this._defaultHeaders = {
54 54
       'Content-Type': 'application/json'
@@ -64,7 +64,7 @@ export default class Http {
64 64
    * @param {{}} body The body. It will be JSON-Encoded by the handler.
65 65
    * @returns {Promise} A promise which will resolve with the processed request response.
66 66
    */
67
-  httpRequest (method, url, headers = {}, body) {
67
+  httpRequest(method, url, headers = {}, body) {
68 68
 
69 69
     // Sanitize the headers...
70 70
     headers = Object.assign({}, headers, this.defaultHeaders);
@@ -106,7 +106,7 @@ export default class Http {
106 106
    * @param {String} url The request URL.
107 107
    * @returns {Promise} A promise which will resolve with the processed request response.
108 108
    */
109
-  httpGet (url) {
109
+  httpGet(url) {
110 110
     return this.httpRequest('GET', url, {}, null);
111 111
   }
112 112
 
@@ -117,7 +117,7 @@ export default class Http {
117 117
    * @param {{}} body The body. It will be JSON-Encoded by the handler.
118 118
    * @returns {Promise} A promise which will resolve with the processed request response.
119 119
    */
120
-  httpPut (url, body) {
120
+  httpPut(url, body) {
121 121
     return this.httpRequest('PUT', url, {}, body);
122 122
   }
123 123
 
@@ -128,7 +128,7 @@ export default class Http {
128 128
    * @param {{}} body The body. It will be JSON-Encoded by the handler.
129 129
    * @returns {Promise} A promise which will resolve with the processed request response.
130 130
    */
131
-  httpPost (url, body) {
131
+  httpPost(url, body) {
132 132
     return this.httpRequest('POST', url, {}, body);
133 133
   }
134 134
 
@@ -138,7 +138,7 @@ export default class Http {
138 138
    * @param {String} url The request URL.
139 139
    * @returns {Promise} A promise which will resolve with the processed request response.
140 140
    */
141
-  httpDelete (url) {
141
+  httpDelete(url) {
142 142
     return this.httpRequest('DELETE', url, {}, null);
143 143
   }
144 144
 }

+ 6
- 6
src/util/version.js View File

@@ -25,7 +25,7 @@ export default class Version {
25 25
    *
26 26
    * @returns {String|*|null} The name of the service, or null.
27 27
    */
28
-  get service () {
28
+  get service() {
29 29
     return this._service || null;
30 30
   }
31 31
 
@@ -34,7 +34,7 @@ export default class Version {
34 34
    *
35 35
    * @returns {Number} The major version number
36 36
    */
37
-  get major () {
37
+  get major() {
38 38
     return this._major || 0;
39 39
   }
40 40
 
@@ -43,7 +43,7 @@ export default class Version {
43 43
    *
44 44
    * @returns {Number} The minor version number
45 45
    */
46
-  get minor () {
46
+  get minor() {
47 47
     return this._minor || 0;
48 48
   }
49 49
 
@@ -52,7 +52,7 @@ export default class Version {
52 52
    *
53 53
    * @returns {Number} The patch version number.
54 54
    */
55
-  get patch () {
55
+  get patch() {
56 56
     return this._patch || 0;
57 57
   }
58 58
 
@@ -62,7 +62,7 @@ export default class Version {
62 62
    * @param {String} service The name of the service.
63 63
    * @param {String} versionString The version string for this service.
64 64
    */
65
-  constructor (service, versionString) {
65
+  constructor(service, versionString) {
66 66
     // Sanitize input
67 67
     if (typeof service !== 'string') {
68 68
       service = undefined;
@@ -97,7 +97,7 @@ export default class Version {
97 97
    * @param {String|Version} version The version to compare to.
98 98
    * @returns {boolean} True if they are exactly the same, otherwise false.
99 99
    */
100
-  equals (version) {
100
+  equals(version) {
101 101
     if (!(version instanceof Version)) {
102 102
       // is it a parseable string?
103 103
       if (typeof version === 'string') {

+ 2
- 2
test/unit/helpers/data/glance.js View File

@@ -37,7 +37,7 @@ const glanceConfig = {
37 37
  *
38 38
  * @returns {{}} A full FetchMock configuration for Glance's Root Resource.
39 39
  */
40
-function rootResponse () {
40
+function rootResponse() {
41 41
   return {
42 42
     method: 'GET',
43 43
     matcher: 'http://192.168.99.99:9292/',
@@ -108,7 +108,7 @@ function rootResponse () {
108 108
   };
109 109
 }
110 110
 
111
-function imageList (token) {
111
+function imageList(token) {
112 112
   return {
113 113
     method: 'GET',
114 114
     matcher: 'http://192.168.99.99:9292/v2/images',

+ 4
- 4
test/unit/helpers/data/keystone.js View File

@@ -39,7 +39,7 @@ const cloudConfig = {
39 39
  *
40 40
  * @returns {{}} A full FetchMock configuration for Keystone's Root Resource.
41 41
  */
42
-function rootResponse () {
42
+function rootResponse() {
43 43
   return {
44 44
     method: 'GET',
45 45
     matcher: 'http://192.168.99.99/',
@@ -96,7 +96,7 @@ function rootResponse () {
96 96
   };
97 97
 }
98 98
 
99
-function tokenIssue () {
99
+function tokenIssue() {
100 100
   return {
101 101
     method: 'POST',
102 102
     matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/tokens',
@@ -375,7 +375,7 @@ function tokenIssue () {
375 375
   };
376 376
 }
377 377
 
378
-function tokenRevoke (token, adminToken = null) {
378
+function tokenRevoke(token, adminToken = null) {
379 379
   return {
380 380
     method: 'DELETE',
381 381
     matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/tokens',
@@ -389,7 +389,7 @@ function tokenRevoke (token, adminToken = null) {
389 389
   };
390 390
 }
391 391
 
392
-function catalogList (token) {
392
+function catalogList(token) {
393 393
   return {
394 394
     method: 'GET',
395 395
     matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/catalog',

+ 1
- 1
test/unit/util/versionTest.js View File

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

Loading…
Cancel
Save