From be595cec2795a897982e6ca70404eb6400a55261 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Thu, 20 Sep 2018 18:19:04 -0700 Subject: [PATCH] Fix the linter (#16) --- packages/google-cloud-asset/package.json | 3 +- .../src/v1beta1/asset_service_client.js | 20 +++---- .../google-cloud-asset/test/gapic-v1beta1.js | 52 +++++++++---------- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/packages/google-cloud-asset/package.json b/packages/google-cloud-asset/package.json index c02319e5603..269518b39cc 100644 --- a/packages/google-cloud-asset/package.json +++ b/packages/google-cloud-asset/package.json @@ -40,7 +40,8 @@ "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", "system-test": "mocha system-test/*.js smoke-test/*.js --timeout 600000", "test-no-cover": "mocha test/*.js", - "test": "npm run cover" + "test": "npm run cover", + "fix": "eslint --fix '**/*.js' && npm run prettier" }, "dependencies": { "google-gax": "^0.20.0", diff --git a/packages/google-cloud-asset/src/v1beta1/asset_service_client.js b/packages/google-cloud-asset/src/v1beta1/asset_service_client.js index 133720b41d2..c1c1fd40b2e 100644 --- a/packages/google-cloud-asset/src/v1beta1/asset_service_client.js +++ b/packages/google-cloud-asset/src/v1beta1/asset_service_client.js @@ -72,13 +72,13 @@ class AssetServiceClient { // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = this.constructor.scopes; - let gaxGrpc = new gax.GrpcClient(opts); + const gaxGrpc = new gax.GrpcClient(opts); // Save the auth object to the client, for use by other methods. this.auth = gaxGrpc.auth; // Determine the client header string. - let clientHeader = [ + const clientHeader = [ `gl-node/${process.version}`, `grpc/${gaxGrpc.grpcVersion}`, `gax/${gax.version}`, @@ -89,7 +89,7 @@ class AssetServiceClient { } // Load the applicable protos. - let protos = merge( + const protos = merge( {}, gaxGrpc.loadProto( path.join(__dirname, '..', '..', 'protos'), @@ -123,10 +123,10 @@ class AssetServiceClient { grpc: gaxGrpc.grpc, }).operationsClient(opts); - let exportAssetsResponse = protoFilesRoot.lookup( + const exportAssetsResponse = protoFilesRoot.lookup( 'google.cloud.asset.v1beta1.ExportAssetsResponse' ); - let exportAssetsMetadata = protoFilesRoot.lookup( + const exportAssetsMetadata = protoFilesRoot.lookup( 'google.cloud.asset.v1beta1.ExportAssetsRequest' ); @@ -139,7 +139,7 @@ class AssetServiceClient { }; // Put together the default options sent with requests. - let defaults = gaxGrpc.constructSettings( + const defaults = gaxGrpc.constructSettings( 'google.cloud.asset.v1beta1.AssetService', gapicConfig, opts.clientConfig, @@ -153,20 +153,20 @@ class AssetServiceClient { // Put together the "service stub" for // google.cloud.asset.v1beta1.AssetService. - let assetServiceStub = gaxGrpc.createStub( + const assetServiceStub = gaxGrpc.createStub( protos.google.cloud.asset.v1beta1.AssetService, opts ); // Iterate over each of the methods that the service provides // and create an API call method for each. - let assetServiceStubMethods = ['exportAssets', 'batchGetAssetsHistory']; - for (let methodName of assetServiceStubMethods) { + const assetServiceStubMethods = ['exportAssets', 'batchGetAssetsHistory']; + for (const methodName of assetServiceStubMethods) { this._innerApiCalls[methodName] = gax.createApiCall( assetServiceStub.then( stub => function() { - let args = Array.prototype.slice.call(arguments, 0); + const args = Array.prototype.slice.call(arguments, 0); return stub[methodName].apply(stub, args); } ), diff --git a/packages/google-cloud-asset/test/gapic-v1beta1.js b/packages/google-cloud-asset/test/gapic-v1beta1.js index 8c9e45e0685..64614d4cbf6 100644 --- a/packages/google-cloud-asset/test/gapic-v1beta1.js +++ b/packages/google-cloud-asset/test/gapic-v1beta1.js @@ -18,28 +18,28 @@ const assert = require('assert'); const assetModule = require('../src'); -let FAKE_STATUS_CODE = 1; -let error = new Error(); +const FAKE_STATUS_CODE = 1; +const error = new Error(); error.code = FAKE_STATUS_CODE; describe('AssetServiceClient', () => { describe('exportAssets', function() { it('invokes exportAssets without error', done => { - let client = new assetModule.v1beta1.AssetServiceClient({ + const client = new assetModule.v1beta1.AssetServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.projectPath('[PROJECT]'); - let outputConfig = {}; - let request = { + const formattedParent = client.projectPath('[PROJECT]'); + const outputConfig = {}; + const request = { parent: formattedParent, outputConfig: outputConfig, }; // Mock response - let expectedResponse = {}; + const expectedResponse = {}; // Mock Grpc layer client._innerApiCalls.exportAssets = mockLongRunningGrpcMethod( @@ -50,7 +50,7 @@ describe('AssetServiceClient', () => { client .exportAssets(request) .then(responses => { - let operation = responses[0]; + const operation = responses[0]; return operation.promise(); }) .then(responses => { @@ -63,15 +63,15 @@ describe('AssetServiceClient', () => { }); it('invokes exportAssets with error', done => { - let client = new assetModule.v1beta1.AssetServiceClient({ + const client = new assetModule.v1beta1.AssetServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.projectPath('[PROJECT]'); - let outputConfig = {}; - let request = { + const formattedParent = client.projectPath('[PROJECT]'); + const outputConfig = {}; + const request = { parent: formattedParent, outputConfig: outputConfig, }; @@ -86,7 +86,7 @@ describe('AssetServiceClient', () => { client .exportAssets(request) .then(responses => { - let operation = responses[0]; + const operation = responses[0]; return operation.promise(); }) .then(() => { @@ -100,7 +100,7 @@ describe('AssetServiceClient', () => { }); it('has longrunning decoder functions', () => { - let client = new assetModule.v1beta1.AssetServiceClient({ + const client = new assetModule.v1beta1.AssetServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); @@ -117,23 +117,23 @@ describe('AssetServiceClient', () => { describe('batchGetAssetsHistory', () => { it('invokes batchGetAssetsHistory without error', done => { - let client = new assetModule.v1beta1.AssetServiceClient({ + const client = new assetModule.v1beta1.AssetServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.projectPath('[PROJECT]'); - let contentType = 'CONTENT_TYPE_UNSPECIFIED'; - let readTimeWindow = {}; - let request = { + const formattedParent = client.projectPath('[PROJECT]'); + const contentType = 'CONTENT_TYPE_UNSPECIFIED'; + const readTimeWindow = {}; + const request = { parent: formattedParent, contentType: contentType, readTimeWindow: readTimeWindow, }; // Mock response - let expectedResponse = {}; + const expectedResponse = {}; // Mock Grpc layer client._innerApiCalls.batchGetAssetsHistory = mockSimpleGrpcMethod( @@ -149,16 +149,16 @@ describe('AssetServiceClient', () => { }); it('invokes batchGetAssetsHistory with error', done => { - let client = new assetModule.v1beta1.AssetServiceClient({ + const client = new assetModule.v1beta1.AssetServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.projectPath('[PROJECT]'); - let contentType = 'CONTENT_TYPE_UNSPECIFIED'; - let readTimeWindow = {}; - let request = { + const formattedParent = client.projectPath('[PROJECT]'); + const contentType = 'CONTENT_TYPE_UNSPECIFIED'; + const readTimeWindow = {}; + const request = { parent: formattedParent, contentType: contentType, readTimeWindow: readTimeWindow, @@ -197,7 +197,7 @@ function mockSimpleGrpcMethod(expectedRequest, response, error) { function mockLongRunningGrpcMethod(expectedRequest, response, error) { return request => { assert.deepStrictEqual(request, expectedRequest); - let mockOperation = { + const mockOperation = { promise: function() { return new Promise((resolve, reject) => { if (error) {