Skip to content

Commit cd24d69

Browse files
committed
style: run eslint fix on codebase
Fixes #2464
1 parent 3bf2af1 commit cd24d69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+4096
-2195
lines changed

packages/grpc-js/src/admin.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*
1616
*/
1717

18-
import { ServiceDefinition } from "./make-client";
19-
import { Server, UntypedServiceImplementation } from "./server";
18+
import { ServiceDefinition } from './make-client';
19+
import { Server, UntypedServiceImplementation } from './server';
2020

2121
interface GetServiceDefinition {
2222
(): ServiceDefinition;
@@ -26,14 +26,20 @@ interface GetHandlers {
2626
(): UntypedServiceImplementation;
2727
}
2828

29-
const registeredAdminServices: {getServiceDefinition: GetServiceDefinition, getHandlers: GetHandlers}[] = [];
29+
const registeredAdminServices: {
30+
getServiceDefinition: GetServiceDefinition;
31+
getHandlers: GetHandlers;
32+
}[] = [];
3033

31-
export function registerAdminService(getServiceDefinition: GetServiceDefinition, getHandlers: GetHandlers) {
32-
registeredAdminServices.push({getServiceDefinition, getHandlers});
34+
export function registerAdminService(
35+
getServiceDefinition: GetServiceDefinition,
36+
getHandlers: GetHandlers
37+
) {
38+
registeredAdminServices.push({ getServiceDefinition, getHandlers });
3339
}
3440

3541
export function addAdminServicesToServer(server: Server): void {
36-
for (const {getServiceDefinition, getHandlers} of registeredAdminServices) {
42+
for (const { getServiceDefinition, getHandlers } of registeredAdminServices) {
3743
server.addService(getServiceDefinition(), getHandlers());
3844
}
39-
}
45+
}

packages/grpc-js/src/call-credentials.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ export abstract class CallCredentials {
125125
});
126126
}
127127
getHeaders.then(
128-
(headers) => {
128+
headers => {
129129
const metadata = new Metadata();
130130
for (const key of Object.keys(headers)) {
131131
metadata.add(key, headers[key]);
132132
}
133133
callback(null, metadata);
134134
},
135-
(err) => {
135+
err => {
136136
callback(err);
137137
}
138138
);
@@ -152,7 +152,7 @@ class ComposedCallCredentials extends CallCredentials {
152152
async generateMetadata(options: CallMetadataOptions): Promise<Metadata> {
153153
const base: Metadata = new Metadata();
154154
const generated: Metadata[] = await Promise.all(
155-
this.creds.map((cred) => cred.generateMetadata(options))
155+
this.creds.map(cred => cred.generateMetadata(options))
156156
);
157157
for (const gen of generated) {
158158
base.merge(gen);

packages/grpc-js/src/call-interface.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*
1616
*/
1717

18-
import { CallCredentials } from "./call-credentials";
19-
import { Status } from "./constants";
20-
import { Deadline } from "./deadline";
21-
import { Metadata } from "./metadata";
22-
import { ServerSurfaceCall } from "./server-call";
18+
import { CallCredentials } from './call-credentials';
19+
import { Status } from './constants';
20+
import { Deadline } from './deadline';
21+
import { Metadata } from './metadata';
22+
import { ServerSurfaceCall } from './server-call';
2323

2424
export interface CallStreamOptions {
2525
deadline: Deadline;
@@ -38,7 +38,7 @@ export interface StatusObject {
3838

3939
export type PartialStatusObject = Pick<StatusObject, 'code' | 'details'> & {
4040
metadata: Metadata | null;
41-
}
41+
};
4242

4343
export const enum WriteFlags {
4444
BufferHint = 1,
@@ -118,7 +118,7 @@ export class InterceptingListenerImpl implements InterceptingListener {
118118

119119
onReceiveMetadata(metadata: Metadata): void {
120120
this.processingMetadata = true;
121-
this.listener.onReceiveMetadata(metadata, (metadata) => {
121+
this.listener.onReceiveMetadata(metadata, metadata => {
122122
this.processingMetadata = false;
123123
this.nextListener.onReceiveMetadata(metadata);
124124
this.processPendingMessage();
@@ -128,9 +128,9 @@ export class InterceptingListenerImpl implements InterceptingListener {
128128
// eslint-disable-next-line @typescript-eslint/no-explicit-any
129129
onReceiveMessage(message: any): void {
130130
/* If this listener processes messages asynchronously, the last message may
131-
* be reordered with respect to the status */
131+
* be reordered with respect to the status */
132132
this.processingMessage = true;
133-
this.listener.onReceiveMessage(message, (msg) => {
133+
this.listener.onReceiveMessage(message, msg => {
134134
this.processingMessage = false;
135135
if (this.processingMetadata) {
136136
this.pendingMessage = msg;
@@ -142,7 +142,7 @@ export class InterceptingListenerImpl implements InterceptingListener {
142142
});
143143
}
144144
onReceiveStatus(status: StatusObject): void {
145-
this.listener.onReceiveStatus(status, (processedStatus) => {
145+
this.listener.onReceiveStatus(status, processedStatus => {
146146
if (this.processingMetadata || this.processingMessage) {
147147
this.pendingStatus = processedStatus;
148148
} else {
@@ -170,4 +170,4 @@ export interface Call {
170170
halfClose(): void;
171171
getCallNumber(): number;
172172
setCredentials(credentials: CallCredentials): void;
173-
}
173+
}

packages/grpc-js/src/call-number.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
let nextCallNumber = 0;
1919

2020
export function getNextCallNumber() {
21-
return nextCallNumber++;
22-
}
21+
return nextCallNumber++;
22+
}

packages/grpc-js/src/call.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,29 @@ export type ClientWritableStream<RequestType> = {
6565
/**
6666
* A type representing the return value of a bidirectional stream method call.
6767
*/
68-
export type ClientDuplexStream<
69-
RequestType,
70-
ResponseType
71-
> = ClientWritableStream<RequestType> & ClientReadableStream<ResponseType>;
68+
export type ClientDuplexStream<RequestType, ResponseType> =
69+
ClientWritableStream<RequestType> & ClientReadableStream<ResponseType>;
7270

7371
/**
7472
* Construct a ServiceError from a StatusObject. This function exists primarily
7573
* as an attempt to make the error stack trace clearly communicate that the
7674
* error is not necessarily a problem in gRPC itself.
7775
* @param status
7876
*/
79-
export function callErrorFromStatus(status: StatusObject, callerStack: string): ServiceError {
77+
export function callErrorFromStatus(
78+
status: StatusObject,
79+
callerStack: string
80+
): ServiceError {
8081
const message = `${status.code} ${Status[status.code]}: ${status.details}`;
8182
const error = new Error(message);
8283
const stack = `${error.stack}\nfor call at\n${callerStack}`;
83-
return Object.assign(new Error(message), status, {stack});
84+
return Object.assign(new Error(message), status, { stack });
8485
}
8586

8687
export class ClientUnaryCallImpl
8788
extends EventEmitter
88-
implements ClientUnaryCall {
89+
implements ClientUnaryCall
90+
{
8991
public call?: InterceptingCallInterface;
9092
constructor() {
9193
super();
@@ -102,7 +104,8 @@ export class ClientUnaryCallImpl
102104

103105
export class ClientReadableStreamImpl<ResponseType>
104106
extends Readable
105-
implements ClientReadableStream<ResponseType> {
107+
implements ClientReadableStream<ResponseType>
108+
{
106109
public call?: InterceptingCallInterface;
107110
constructor(readonly deserialize: (chunk: Buffer) => ResponseType) {
108111
super({ objectMode: true });
@@ -123,7 +126,8 @@ export class ClientReadableStreamImpl<ResponseType>
123126

124127
export class ClientWritableStreamImpl<RequestType>
125128
extends Writable
126-
implements ClientWritableStream<RequestType> {
129+
implements ClientWritableStream<RequestType>
130+
{
127131
public call?: InterceptingCallInterface;
128132
constructor(readonly serialize: (value: RequestType) => Buffer) {
129133
super({ objectMode: true });
@@ -156,7 +160,8 @@ export class ClientWritableStreamImpl<RequestType>
156160

157161
export class ClientDuplexStreamImpl<RequestType, ResponseType>
158162
extends Duplex
159-
implements ClientDuplexStream<RequestType, ResponseType> {
163+
implements ClientDuplexStream<RequestType, ResponseType>
164+
{
160165
public call?: InterceptingCallInterface;
161166
constructor(
162167
readonly serialize: (value: RequestType) => Buffer,

packages/grpc-js/src/channel-credentials.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
*
1616
*/
1717

18-
import { ConnectionOptions, createSecureContext, PeerCertificate, SecureContext } from 'tls';
18+
import {
19+
ConnectionOptions,
20+
createSecureContext,
21+
PeerCertificate,
22+
SecureContext,
23+
} from 'tls';
1924

2025
import { CallCredentials } from './call-credentials';
2126
import { CIPHER_SUITES, getDefaultRootsData } from './tls-helpers';
@@ -137,10 +142,7 @@ export abstract class ChannelCredentials {
137142
cert: certChain ?? undefined,
138143
ciphers: CIPHER_SUITES,
139144
});
140-
return new SecureChannelCredentialsImpl(
141-
secureContext,
142-
verifyOptions ?? {}
143-
);
145+
return new SecureChannelCredentialsImpl(secureContext, verifyOptions ?? {});
144146
}
145147

146148
/**
@@ -153,11 +155,11 @@ export abstract class ChannelCredentials {
153155
* @param secureContext The return value of tls.createSecureContext()
154156
* @param verifyOptions Additional options to modify certificate verification
155157
*/
156-
static createFromSecureContext(secureContext: SecureContext, verifyOptions?: VerifyOptions): ChannelCredentials {
157-
return new SecureChannelCredentialsImpl(
158-
secureContext,
159-
verifyOptions ?? {}
160-
)
158+
static createFromSecureContext(
159+
secureContext: SecureContext,
160+
verifyOptions?: VerifyOptions
161+
): ChannelCredentials {
162+
return new SecureChannelCredentialsImpl(secureContext, verifyOptions ?? {});
161163
}
162164

163165
/**
@@ -196,19 +198,19 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
196198
private verifyOptions: VerifyOptions
197199
) {
198200
super();
199-
this.connectionOptions = {
200-
secureContext
201+
this.connectionOptions = {
202+
secureContext,
201203
};
202204
// Node asserts that this option is a function, so we cannot pass undefined
203205
if (verifyOptions?.checkServerIdentity) {
204-
this.connectionOptions.checkServerIdentity = verifyOptions.checkServerIdentity;
206+
this.connectionOptions.checkServerIdentity =
207+
verifyOptions.checkServerIdentity;
205208
}
206209
}
207210

208211
compose(callCredentials: CallCredentials): ChannelCredentials {
209-
const combinedCallCredentials = this.callCredentials.compose(
210-
callCredentials
211-
);
212+
const combinedCallCredentials =
213+
this.callCredentials.compose(callCredentials);
212214
return new ComposedChannelCredentialsImpl(this, combinedCallCredentials);
213215
}
214216

@@ -225,9 +227,10 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
225227
}
226228
if (other instanceof SecureChannelCredentialsImpl) {
227229
return (
228-
this.secureContext === other.secureContext &&
229-
this.verifyOptions.checkServerIdentity === other.verifyOptions.checkServerIdentity
230-
);
230+
this.secureContext === other.secureContext &&
231+
this.verifyOptions.checkServerIdentity ===
232+
other.verifyOptions.checkServerIdentity
233+
);
231234
} else {
232235
return false;
233236
}
@@ -242,9 +245,8 @@ class ComposedChannelCredentialsImpl extends ChannelCredentials {
242245
super(callCreds);
243246
}
244247
compose(callCredentials: CallCredentials) {
245-
const combinedCallCredentials = this.callCredentials.compose(
246-
callCredentials
247-
);
248+
const combinedCallCredentials =
249+
this.callCredentials.compose(callCredentials);
248250
return new ComposedChannelCredentialsImpl(
249251
this.channelCredentials,
250252
combinedCallCredentials

packages/grpc-js/src/channel.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export interface Channel {
9191
}
9292

9393
export class ChannelImplementation implements Channel {
94-
9594
private internalChannel: InternalChannel;
9695

9796
constructor(
@@ -133,13 +132,17 @@ export class ChannelImplementation implements Channel {
133132
deadline: Date | number,
134133
callback: (error?: Error) => void
135134
): void {
136-
this.internalChannel.watchConnectivityState(currentState, deadline, callback);
135+
this.internalChannel.watchConnectivityState(
136+
currentState,
137+
deadline,
138+
callback
139+
);
137140
}
138141

139142
/**
140143
* Get the channelz reference object for this channel. The returned value is
141144
* garbage if channelz is disabled for this channel.
142-
* @returns
145+
* @returns
143146
*/
144147
getChannelzRef() {
145148
return this.internalChannel.getChannelzRef();
@@ -160,6 +163,12 @@ export class ChannelImplementation implements Channel {
160163
'Channel#createCall: deadline must be a number or Date'
161164
);
162165
}
163-
return this.internalChannel.createCall(method, deadline, host, parentCall, propagateFlags);
166+
return this.internalChannel.createCall(
167+
method,
168+
deadline,
169+
host,
170+
parentCall,
171+
propagateFlags
172+
);
164173
}
165174
}

0 commit comments

Comments
 (0)