diff --git a/packages/google-cloud-asset/.eslintrc.json b/packages/google-cloud-asset/.eslintrc.json new file mode 100644 index 00000000000..eb23147be61 --- /dev/null +++ b/packages/google-cloud-asset/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/packages/google-cloud-asset/.eslintrc.yml b/packages/google-cloud-asset/.eslintrc.yml deleted file mode 100644 index 73eeec27612..00000000000 --- a/packages/google-cloud-asset/.eslintrc.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -extends: - - 'eslint:recommended' - - 'plugin:node/recommended' - - prettier -plugins: - - node - - prettier -rules: - prettier/prettier: error - block-scoped-var: error - eqeqeq: error - no-warning-comments: warn - no-var: error - prefer-const: error diff --git a/packages/google-cloud-asset/.prettierrc b/packages/google-cloud-asset/.prettierrc deleted file mode 100644 index df6eac07446..00000000000 --- a/packages/google-cloud-asset/.prettierrc +++ /dev/null @@ -1,8 +0,0 @@ ---- -bracketSpacing: false -printWidth: 80 -semi: true -singleQuote: true -tabWidth: 2 -trailingComma: es5 -useTabs: false diff --git a/packages/google-cloud-asset/.prettierrc.js b/packages/google-cloud-asset/.prettierrc.js new file mode 100644 index 00000000000..21df107092c --- /dev/null +++ b/packages/google-cloud-asset/.prettierrc.js @@ -0,0 +1,17 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/packages/google-cloud-asset/package.json b/packages/google-cloud-asset/package.json index 3ad8fabc021..51e7fec41c6 100644 --- a/packages/google-cloud-asset/package.json +++ b/packages/google-cloud-asset/package.json @@ -5,7 +5,7 @@ "license": "Apache-2.0", "author": "Google LLC", "engines": { - "node": ">=8.10.0" + "node": ">=10.0.0" }, "repository": "googleapis/nodejs-asset", "main": "build/src/index.js", @@ -43,30 +43,25 @@ "prelint": "cd samples; npm link ../; npm i" }, "dependencies": { - "google-gax": "^1.14.1", - "protobufjs": "^6.8.0" + "google-gax": "^1.15.1", + "protobufjs": "^6.8.9" }, "devDependencies": { - "@types/mocha": "^7.0.0", - "@types/node": "^12.0.0", - "c8": "^7.0.1", - "codecov": "^3.0.4", - "eslint": "^6.0.0", - "eslint-config-prettier": "^6.0.0", - "eslint-plugin-node": "^11.0.0", - "eslint-plugin-prettier": "^3.0.0", - "gts": "^1.0.0", - "jsdoc": "^3.6.2", - "jsdoc-fresh": "^1.0.1", - "jsdoc-region-tag": "^1.0.2", - "linkinator": "^2.0.0", - "mocha": "^7.0.0", + "@types/mocha": "^7.0.2", + "@types/node": "^13.9.3", + "c8": "^7.1.0", + "codecov": "^3.6.5", + "gts": "^2.0.0-alpha.5", + "jsdoc": "^3.6.3", + "jsdoc-fresh": "^1.0.2", + "jsdoc-region-tag": "^1.0.4", + "linkinator": "^2.0.4", + "mocha": "^7.1.1", "null-loader": "^3.0.0", "pack-n-play": "^1.0.0-2", - "prettier": "^1.13.7", - "ts-loader": "^6.2.1", - "typescript": "~3.6.4", - "webpack": "^4.41.2", - "webpack-cli": "^3.3.10" + "ts-loader": "^6.2.2", + "typescript": "~3.8.3", + "webpack": "^4.42.0", + "webpack-cli": "^3.3.11" } } diff --git a/packages/google-cloud-asset/src/v1/asset_service_client.ts b/packages/google-cloud-asset/src/v1/asset_service_client.ts index 5efcd8e79b1..ee309055227 100644 --- a/packages/google-cloud-asset/src/v1/asset_service_client.ts +++ b/packages/google-cloud-asset/src/v1/asset_service_client.ts @@ -163,6 +163,7 @@ export class AssetServiceClient { // rather than holding a request open. const protoFilesRoot = opts.fallback ? this._gaxModule.protobuf.Root.fromJSON( + /* eslint-disable @typescript-eslint/no-var-requires */ require('../../protos/protos.json') ) : this._gaxModule.protobuf.loadSync(nodejsProtoPath); @@ -227,6 +228,7 @@ export class AssetServiceClient { 'google.cloud.asset.v1.AssetService' ) : // tslint:disable-next-line no-any + /* eslint-disable @typescript-eslint/no-explicit-any */ (this._protos as any).google.cloud.asset.v1.AssetService, this._opts ) as Promise<{[method: string]: Function}>; @@ -249,7 +251,8 @@ export class AssetServiceClient { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; diff --git a/packages/google-cloud-asset/src/v1beta1/asset_service_client.ts b/packages/google-cloud-asset/src/v1beta1/asset_service_client.ts index dc6b2d88d12..563a9dcd703 100644 --- a/packages/google-cloud-asset/src/v1beta1/asset_service_client.ts +++ b/packages/google-cloud-asset/src/v1beta1/asset_service_client.ts @@ -147,6 +147,7 @@ export class AssetServiceClient { // rather than holding a request open. const protoFilesRoot = opts.fallback ? this._gaxModule.protobuf.Root.fromJSON( + /* eslint-disable @typescript-eslint/no-var-requires */ require('../../protos/protos.json') ) : this._gaxModule.protobuf.loadSync(nodejsProtoPath); @@ -211,6 +212,7 @@ export class AssetServiceClient { 'google.cloud.asset.v1beta1.AssetService' ) : // tslint:disable-next-line no-any + /* eslint-disable @typescript-eslint/no-explicit-any */ (this._protos as any).google.cloud.asset.v1beta1.AssetService, this._opts ) as Promise<{[method: string]: Function}>; @@ -225,7 +227,8 @@ export class AssetServiceClient { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; diff --git a/packages/google-cloud-asset/src/v1p1beta1/asset_service_client.ts b/packages/google-cloud-asset/src/v1p1beta1/asset_service_client.ts index e53bdfd0e3f..fd965c29efb 100644 --- a/packages/google-cloud-asset/src/v1p1beta1/asset_service_client.ts +++ b/packages/google-cloud-asset/src/v1p1beta1/asset_service_client.ts @@ -23,8 +23,6 @@ import { CallOptions, Descriptors, ClientOptions, - PaginationCallback, - PaginationResponse, } from 'google-gax'; import * as path from 'path'; @@ -198,6 +196,7 @@ export class AssetServiceClient { 'google.cloud.asset.v1p1beta1.AssetService' ) : // tslint:disable-next-line no-any + /* eslint-disable @typescript-eslint/no-explicit-any */ (this._protos as any).google.cloud.asset.v1p1beta1.AssetService, this._opts ) as Promise<{[method: string]: Function}>; @@ -215,7 +214,8 @@ export class AssetServiceClient { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; diff --git a/packages/google-cloud-asset/src/v1p2beta1/asset_service_client.ts b/packages/google-cloud-asset/src/v1p2beta1/asset_service_client.ts index 00796f3e511..3348b8c0a4b 100644 --- a/packages/google-cloud-asset/src/v1p2beta1/asset_service_client.ts +++ b/packages/google-cloud-asset/src/v1p2beta1/asset_service_client.ts @@ -195,6 +195,7 @@ export class AssetServiceClient { 'google.cloud.asset.v1p2beta1.AssetService' ) : // tslint:disable-next-line no-any + /* eslint-disable @typescript-eslint/no-explicit-any */ (this._protos as any).google.cloud.asset.v1p2beta1.AssetService, this._opts ) as Promise<{[method: string]: Function}>; @@ -215,7 +216,8 @@ export class AssetServiceClient { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; diff --git a/packages/google-cloud-asset/src/v1p4beta1/asset_service_client.ts b/packages/google-cloud-asset/src/v1p4beta1/asset_service_client.ts index 18be1e8c02b..d7ea8f96a7a 100644 --- a/packages/google-cloud-asset/src/v1p4beta1/asset_service_client.ts +++ b/packages/google-cloud-asset/src/v1p4beta1/asset_service_client.ts @@ -147,6 +147,7 @@ export class AssetServiceClient { // rather than holding a request open. const protoFilesRoot = opts.fallback ? this._gaxModule.protobuf.Root.fromJSON( + /* eslint-disable @typescript-eslint/no-var-requires */ require('../../protos/protos.json') ) : this._gaxModule.protobuf.loadSync(nodejsProtoPath); @@ -215,6 +216,7 @@ export class AssetServiceClient { 'google.cloud.asset.v1p4beta1.AssetService' ) : // tslint:disable-next-line no-any + /* eslint-disable @typescript-eslint/no-explicit-any */ (this._protos as any).google.cloud.asset.v1p4beta1.AssetService, this._opts ) as Promise<{[method: string]: Function}>; @@ -232,7 +234,8 @@ export class AssetServiceClient { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; diff --git a/packages/google-cloud-asset/system-test/fixtures/sample/src/index.js b/packages/google-cloud-asset/system-test/fixtures/sample/src/index.js index 6f3575b6c25..77608a15112 100644 --- a/packages/google-cloud-asset/system-test/fixtures/sample/src/index.js +++ b/packages/google-cloud-asset/system-test/fixtures/sample/src/index.js @@ -16,7 +16,6 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** - /* eslint-disable node/no-missing-require, no-unused-vars */ const asset = require('@google-cloud/asset'); diff --git a/packages/google-cloud-asset/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-asset/system-test/fixtures/sample/src/index.ts index 1c292d6b651..6ba56206311 100644 --- a/packages/google-cloud-asset/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-asset/system-test/fixtures/sample/src/index.ts @@ -19,7 +19,7 @@ import {AssetServiceClient} from '@google-cloud/asset'; function main() { - const assetServiceClient = new AssetServiceClient(); + new AssetServiceClient(); } main(); diff --git a/packages/google-cloud-asset/system-test/install.ts b/packages/google-cloud-asset/system-test/install.ts index c9aa74ec221..0581f7fc273 100644 --- a/packages/google-cloud-asset/system-test/install.ts +++ b/packages/google-cloud-asset/system-test/install.ts @@ -21,7 +21,7 @@ import {readFileSync} from 'fs'; import {describe, it} from 'mocha'; describe('typescript consumer tests', () => { - it('should have correct type signature for typescript users', async function() { + it('should have correct type signature for typescript users', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), // path to your module. @@ -35,7 +35,7 @@ describe('typescript consumer tests', () => { await packNTest(options); // will throw upon error. }); - it('should have correct type signature for javascript users', async function() { + it('should have correct type signature for javascript users', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), // path to your module. diff --git a/packages/google-cloud-asset/test/gapic-asset_service-v1.ts b/packages/google-cloud-asset/test/gapic-asset_service-v1.ts index d79fd23bb73..532b495fc55 100644 --- a/packages/google-cloud-asset/test/gapic-asset_service-v1.ts +++ b/packages/google-cloud-asset/test/gapic-asset_service-v1.ts @@ -19,6 +19,7 @@ import * as protosTypes from '../protos/protos'; import * as assert from 'assert'; import {describe, it} from 'mocha'; +/* eslint-disable @typescript-eslint/no-var-requires */ const assetserviceModule = require('../src'); const FAKE_STATUS_CODE = 1; @@ -38,7 +39,9 @@ export interface Callback { } export class Operation { + /* eslint-disable @typescript-eslint/no-empty-function */ constructor() {} + /* eslint-disable @typescript-eslint/no-empty-function */ promise() {} } function mockSimpleGrpcMethod( @@ -154,8 +157,6 @@ describe('v1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1.IBatchGetAssetsHistoryRequest = {}; request.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.batchGetAssetsHistory = mockSimpleGrpcMethod( request, @@ -206,8 +207,6 @@ describe('v1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1.ICreateFeedRequest = {}; request.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.createFeed = mockSimpleGrpcMethod( request, @@ -258,8 +257,6 @@ describe('v1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1.IGetFeedRequest = {}; request.name = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.getFeed = mockSimpleGrpcMethod( request, @@ -310,8 +307,6 @@ describe('v1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1.IListFeedsRequest = {}; request.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.listFeeds = mockSimpleGrpcMethod( request, @@ -364,8 +359,6 @@ describe('v1.AssetServiceClient', () => { const request: protosTypes.google.cloud.asset.v1.IUpdateFeedRequest = {}; request.feed = {}; request.feed.name = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.updateFeed = mockSimpleGrpcMethod( request, @@ -416,8 +409,6 @@ describe('v1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1.IDeleteFeedRequest = {}; request.name = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.deleteFeed = mockSimpleGrpcMethod( request, @@ -475,8 +466,6 @@ describe('v1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1.IExportAssetsRequest = {}; request.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.exportAssets = mockLongRunningGrpcMethod( request, diff --git a/packages/google-cloud-asset/test/gapic-asset_service-v1beta1.ts b/packages/google-cloud-asset/test/gapic-asset_service-v1beta1.ts index dfb52b9da76..d132ea66896 100644 --- a/packages/google-cloud-asset/test/gapic-asset_service-v1beta1.ts +++ b/packages/google-cloud-asset/test/gapic-asset_service-v1beta1.ts @@ -19,6 +19,7 @@ import * as protosTypes from '../protos/protos'; import * as assert from 'assert'; import {describe, it} from 'mocha'; +/* eslint-disable @typescript-eslint/no-var-requires */ const assetserviceModule = require('../src'); const FAKE_STATUS_CODE = 1; @@ -38,7 +39,9 @@ export interface Callback { } export class Operation { + /* eslint-disable @typescript-eslint/no-empty-function */ constructor() {} + /* eslint-disable @typescript-eslint/no-empty-function */ promise() {} } function mockSimpleGrpcMethod( @@ -156,8 +159,6 @@ describe('v1beta1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1beta1.IBatchGetAssetsHistoryRequest = {}; request.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.batchGetAssetsHistory = mockSimpleGrpcMethod( request, @@ -215,8 +216,6 @@ describe('v1beta1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1beta1.IExportAssetsRequest = {}; request.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.exportAssets = mockLongRunningGrpcMethod( request, diff --git a/packages/google-cloud-asset/test/gapic-asset_service-v1p1beta1.ts b/packages/google-cloud-asset/test/gapic-asset_service-v1p1beta1.ts index 9f1b560b792..d6fabc35216 100644 --- a/packages/google-cloud-asset/test/gapic-asset_service-v1p1beta1.ts +++ b/packages/google-cloud-asset/test/gapic-asset_service-v1p1beta1.ts @@ -19,9 +19,9 @@ import * as protosTypes from '../protos/protos'; import * as assert from 'assert'; import {describe, it} from 'mocha'; +/* eslint-disable @typescript-eslint/no-var-requires */ const assetserviceModule = require('../src'); -const FAKE_STATUS_CODE = 1; class FakeError { name: string; message: string; @@ -32,13 +32,14 @@ class FakeError { this.code = n; } } -const error = new FakeError(FAKE_STATUS_CODE); export interface Callback { (err: FakeError | null, response?: {} | null): void; } export class Operation { + /* eslint-disable @typescript-eslint/no-empty-function */ constructor() {} + /* eslint-disable @typescript-eslint/no-empty-function */ promise() {} } describe('v1p1beta1.AssetServiceClient', () => { diff --git a/packages/google-cloud-asset/test/gapic-asset_service-v1p2beta1.ts b/packages/google-cloud-asset/test/gapic-asset_service-v1p2beta1.ts index 73678598dfe..391eed09912 100644 --- a/packages/google-cloud-asset/test/gapic-asset_service-v1p2beta1.ts +++ b/packages/google-cloud-asset/test/gapic-asset_service-v1p2beta1.ts @@ -19,6 +19,7 @@ import * as protosTypes from '../protos/protos'; import * as assert from 'assert'; import {describe, it} from 'mocha'; +/* eslint-disable @typescript-eslint/no-var-requires */ const assetserviceModule = require('../src'); const FAKE_STATUS_CODE = 1; @@ -38,7 +39,9 @@ export interface Callback { } export class Operation { + /* eslint-disable @typescript-eslint/no-empty-function */ constructor() {} + /* eslint-disable @typescript-eslint/no-empty-function */ promise() {} } function mockSimpleGrpcMethod( @@ -135,8 +138,6 @@ describe('v1p2beta1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1p2beta1.ICreateFeedRequest = {}; request.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.createFeed = mockSimpleGrpcMethod( request, @@ -187,8 +188,6 @@ describe('v1p2beta1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1p2beta1.IGetFeedRequest = {}; request.name = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.getFeed = mockSimpleGrpcMethod( request, @@ -239,8 +238,6 @@ describe('v1p2beta1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1p2beta1.IListFeedsRequest = {}; request.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.listFeeds = mockSimpleGrpcMethod( request, @@ -293,8 +290,6 @@ describe('v1p2beta1.AssetServiceClient', () => { const request: protosTypes.google.cloud.asset.v1p2beta1.IUpdateFeedRequest = {}; request.feed = {}; request.feed.name = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.updateFeed = mockSimpleGrpcMethod( request, @@ -345,8 +340,6 @@ describe('v1p2beta1.AssetServiceClient', () => { // Mock request const request: protosTypes.google.cloud.asset.v1p2beta1.IDeleteFeedRequest = {}; request.name = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.deleteFeed = mockSimpleGrpcMethod( request, diff --git a/packages/google-cloud-asset/test/gapic-asset_service-v1p4beta1.ts b/packages/google-cloud-asset/test/gapic-asset_service-v1p4beta1.ts index 9a8ce3c619e..521a5aa2b73 100644 --- a/packages/google-cloud-asset/test/gapic-asset_service-v1p4beta1.ts +++ b/packages/google-cloud-asset/test/gapic-asset_service-v1p4beta1.ts @@ -19,6 +19,7 @@ import * as protosTypes from '../protos/protos'; import * as assert from 'assert'; import {describe, it} from 'mocha'; +/* eslint-disable @typescript-eslint/no-var-requires */ const assetserviceModule = require('../src'); const FAKE_STATUS_CODE = 1; @@ -38,7 +39,9 @@ export interface Callback { } export class Operation { + /* eslint-disable @typescript-eslint/no-empty-function */ constructor() {} + /* eslint-disable @typescript-eslint/no-empty-function */ promise() {} } function mockSimpleGrpcMethod( @@ -158,8 +161,6 @@ describe('v1p4beta1.AssetServiceClient', () => { const request: protosTypes.google.cloud.asset.v1p4beta1.IAnalyzeIamPolicyRequest = {}; request.analysisQuery = {}; request.analysisQuery.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.analyzeIamPolicy = mockSimpleGrpcMethod( request, @@ -219,8 +220,6 @@ describe('v1p4beta1.AssetServiceClient', () => { const request: protosTypes.google.cloud.asset.v1p4beta1.IExportIamPolicyAnalysisRequest = {}; request.analysisQuery = {}; request.analysisQuery.parent = ''; - // Mock response - const expectedResponse = {}; // Mock gRPC layer client._innerApiCalls.exportIamPolicyAnalysis = mockLongRunningGrpcMethod( request, diff --git a/packages/google-cloud-asset/webpack.config.js b/packages/google-cloud-asset/webpack.config.js index c49be15531d..55345f33a87 100644 --- a/packages/google-cloud-asset/webpack.config.js +++ b/packages/google-cloud-asset/webpack.config.js @@ -36,27 +36,27 @@ module.exports = { { test: /\.tsx?$/, use: 'ts-loader', - exclude: /node_modules/ + exclude: /node_modules/, }, { test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]grpc/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]retry-request/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]gtoken/, - use: 'null-loader' + use: 'null-loader', }, ], },