From 7f6843011b6121ff2a8d904ac4f2f4dac3132b38 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Thu, 5 Dec 2024 16:45:13 -0800 Subject: [PATCH] rerun lint and fix test in tools --- gax/.eslintignore | 5 ++++- gax/esm/src/grpc.ts | 1 - gax/esm/src/streamingCalls/streaming.ts | 2 +- gax/esm/test/browser-test/karma.conf.js | 1 - gax/esm/test/browser-test/test/test.endtoend.ts | 7 ++----- gax/esm/test/browser-test/webpack.config.js | 4 ++-- gax/esm/test/unit/grpc.ts | 8 ++------ gax/esm/test/unit/iamService.ts | 2 +- gax/samples/package.json | 1 + gax/samples/system-test/test.quickstart.js | 2 +- tools/.eslintrc.json | 10 +++++++++- tools/src/compileProtos.ts | 4 +--- 12 files changed, 24 insertions(+), 23 deletions(-) diff --git a/gax/.eslintignore b/gax/.eslintignore index 9fb5a5d92..d5b7c35f6 100644 --- a/gax/.eslintignore +++ b/gax/.eslintignore @@ -7,4 +7,7 @@ protos/ samples/generated/ **/*.d.ts *.d.ts -**/**.d.ts \ No newline at end of file +**/**.d.ts +samples +esm/test/browser-test/karma.conf.js +esm/test/browser-test/webpack.config.js \ No newline at end of file diff --git a/gax/esm/src/grpc.ts b/gax/esm/src/grpc.ts index ba8470588..9b9bdb5c6 100644 --- a/gax/esm/src/grpc.ts +++ b/gax/esm/src/grpc.ts @@ -197,7 +197,6 @@ export class GrpcClient { } } - /** * Creates a gRPC credentials. It asks the auth data if necessary. * @private diff --git a/gax/esm/src/streamingCalls/streaming.ts b/gax/esm/src/streamingCalls/streaming.ts index f97eb671e..714f90a11 100644 --- a/gax/esm/src/streamingCalls/streaming.ts +++ b/gax/esm/src/streamingCalls/streaming.ts @@ -37,7 +37,7 @@ import {ResponseType} from '../apitypes.js'; // eslint-disable-next-line @typescript-eslint/no-var-requires import duplexify from 'duplexify'; // eslint-disable-next-line @typescript-eslint/no-var-requires -import retryRequest, { Options } from 'retry-request'; +import retryRequest, {Options} from 'retry-request'; // Directly copy over Duplexify interfaces export interface DuplexifyOptions extends DuplexOptions { diff --git a/gax/esm/test/browser-test/karma.conf.js b/gax/esm/test/browser-test/karma.conf.js index 1380725eb..59d73250d 100644 --- a/gax/esm/test/browser-test/karma.conf.js +++ b/gax/esm/test/browser-test/karma.conf.js @@ -18,7 +18,6 @@ // Use `npm run browser-test` in the main google-gax package to run browser tests with Karma. const path = require('path'); -// eslint-disable-next-line n/no-missing-require const isDocker = require('is-docker')(); const webpackConfig = require('./webpack.config.js'); webpackConfig.performance = {hints: false}; diff --git a/gax/esm/test/browser-test/test/test.endtoend.ts b/gax/esm/test/browser-test/test/test.endtoend.ts index 6ef49e003..9b428f3c2 100644 --- a/gax/esm/test/browser-test/test/test.endtoend.ts +++ b/gax/esm/test/browser-test/test/test.endtoend.ts @@ -23,19 +23,18 @@ import * as http2 from 'http2'; import * as net from 'net'; import * as tls from 'tls'; import * as sinon from 'sinon'; // Import Sinon.JS for mocking -import { createByteLengthFunction } from 'google-gax'; +import {createByteLengthFunction} from 'google-gax'; // Mock the http2 module with constants const http2Mock = { // ... other http2 mocks if needed ... constants: { - HTTP2_HEADER_AUTHORITY: ':authority', + HTTP2_HEADER_AUTHORITY: ':authority', HTTP2_HEADER_STATUS: ':status', // Add this line // ... other constants as needed ... }, }; - // ... in your afterEach hook: // ... (rest of your code) ... @@ -61,7 +60,6 @@ const http2Mock = { // } // ); - // // Mock 'net.createConnection' // (net.createConnection as any).__original = net.createConnection; // (net.createConnection as any).mockImplementation( @@ -106,7 +104,6 @@ describe('Run tests against gRPC server', () => { }, }; - const opts = { auth: authStub as unknown as GoogleAuth, protocol: 'http', diff --git a/gax/esm/test/browser-test/webpack.config.js b/gax/esm/test/browser-test/webpack.config.js index 3da77f021..61e731da0 100644 --- a/gax/esm/test/browser-test/webpack.config.js +++ b/gax/esm/test/browser-test/webpack.config.js @@ -53,7 +53,7 @@ module.exports = { dns: 'empty', tls: 'empty', './framer': 'empty', - framer: 'empty' + framer: 'empty', }, mode: 'production', -}; \ No newline at end of file +}; diff --git a/gax/esm/test/unit/grpc.ts b/gax/esm/test/unit/grpc.ts index 95d660d6a..04beafa8a 100644 --- a/gax/esm/test/unit/grpc.ts +++ b/gax/esm/test/unit/grpc.ts @@ -47,7 +47,7 @@ function gaxGrpc(options?: GrpcClientOptions) { return new GrpcClient(options); } -describe.only('grpc', () => { +describe('grpc', () => { describe('grpcVersion', () => { it('holds the proper grpc version', () => { assert.strictEqual(gaxGrpc().grpcVersion, grpcVersion); @@ -129,11 +129,7 @@ describe.only('grpc', () => { address: any; creds: any; options: any; - constructor( - address: any, - creds: any, - options: any - ) { + constructor(address: any, creds: any, options: any) { this.address = address; this.creds = creds; this.options = options; diff --git a/gax/esm/test/unit/iamService.ts b/gax/esm/test/unit/iamService.ts index 666798319..e60046117 100644 --- a/gax/esm/test/unit/iamService.ts +++ b/gax/esm/test/unit/iamService.ts @@ -57,7 +57,7 @@ describe('IAM service', () => { projectId: 'bogus', }); client.initialize(); - console.log('what is protos?') + console.log('what is protos?'); console.log(protos); console.log(protos.google); const request = generateSampleMessage( diff --git a/gax/samples/package.json b/gax/samples/package.json index a927f4354..f283b426f 100644 --- a/gax/samples/package.json +++ b/gax/samples/package.json @@ -1,6 +1,7 @@ { "description": "Samples for the google-gax npm module.", "license": "Apache-2.0", + "type": "commonjs", "author": "Google LLC", "engines": { "node": ">=10" diff --git a/gax/samples/system-test/test.quickstart.js b/gax/samples/system-test/test.quickstart.js index 52879e885..d21ef4f1e 100644 --- a/gax/samples/system-test/test.quickstart.js +++ b/gax/samples/system-test/test.quickstart.js @@ -1,3 +1,4 @@ + /** * Copyright 2020 Google LLC * @@ -23,7 +24,6 @@ const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -// eslint-disable-next-line no-undef const cwd = path.join(__dirname, '..'); describe('Quickstart', () => { diff --git a/tools/.eslintrc.json b/tools/.eslintrc.json index 3e8d97ccb..8193085f7 100644 --- a/tools/.eslintrc.json +++ b/tools/.eslintrc.json @@ -1,4 +1,12 @@ { "extends": "./node_modules/gts", - "root": true + "root": true, + "globals": { + "require": true + }, + "env": { + "browser": true, + "node": true, + "es6": true + }, } diff --git a/tools/src/compileProtos.ts b/tools/src/compileProtos.ts index 2b65d70d2..0a5429c53 100644 --- a/tools/src/compileProtos.ts +++ b/tools/src/compileProtos.ts @@ -29,6 +29,7 @@ export const gaxProtos = path.join( '..', '..', '..', + '..', 'protos' ); const readdir = util.promisify(fs.readdir); @@ -68,7 +69,6 @@ async function findProtoJsonFiles(directory: string): Promise { const files = await readdir(directory); for (const file of files) { const fullPath = path.join(directory, file); - console.log(fullPath); const fileStat = await stat(fullPath); if (fileStat.isFile() && file.match(PROTO_LIST_REGEX)) { result.push(fullPath); @@ -393,8 +393,6 @@ export async function generateRootName(directories: string[]): Promise { * `./src` folder of the given client library. */ export async function main(parameters: string[]): Promise { - console.log("PWD") - console.log(process.cwd()); const protoJsonFiles: string[] = []; let skipJson = false; let esm = false;