Revert "grpc-js: allow any for linting globally"

This reverts commit 16ec0f0f64 and
replaces tslint-disable statements by eslint-disable.
This commit is contained in:
Patrick Remy 2020-04-10 11:03:53 +02:00
parent 226016c7dc
commit 53f3daa685
No known key found for this signature in database
GPG Key ID: FE25C0B14C0500CD
22 changed files with 66 additions and 9 deletions

View File

@ -2,7 +2,6 @@
"root": true,
"extends": "./node_modules/gts",
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"node/no-unpublished-import": ["error", {
"tryExtensions": [".ts", ".js", ".json", ".node"]
}]

View File

@ -69,6 +69,7 @@ export interface MetadataListener {
}
export interface MessageListener {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(message: any, next: (message: any) => void): void;
}
@ -89,6 +90,7 @@ export type Listener = Partial<FullListener>;
*/
export interface InterceptingListener {
onReceiveMetadata(metadata: Metadata): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onReceiveMessage(message: any): void;
onReceiveStatus(status: StatusObject): void;
}
@ -115,6 +117,7 @@ export class InterceptingListenerImpl implements InterceptingListener {
this.nextListener.onReceiveMetadata(metadata);
});
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onReceiveMessage(message: any): void {
/* If this listener processes messages asynchronously, the last message may
* be reordered with respect to the status */

View File

@ -20,6 +20,7 @@ import { ConnectionOptions, createSecureContext, PeerCertificate } from 'tls';
import { CallCredentials } from './call-credentials';
import { CIPHER_SUITES, getDefaultRootsData } from './tls-helpers';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function verifyIsBufferOrNull(obj: any, friendlyName: string): void {
if (obj && !(obj instanceof Buffer)) {
throw new TypeError(`${friendlyName}, if provided, must be a Buffer.`);

View File

@ -111,7 +111,7 @@ export interface Channel {
method: string,
deadline: Deadline,
host: string | null | undefined,
parentCall: any,
parentCall: any, // eslint-disable-line @typescript-eslint/no-explicit-any
propagateFlags: number | null | undefined
): Call;
}
@ -460,7 +460,7 @@ export class ChannelImplementation implements Channel {
method: string,
deadline: Deadline,
host: string | null | undefined,
parentCall: any,
parentCall: any, // eslint-disable-line @typescript-eslint/no-explicit-any
propagateFlags: number | null | undefined
): Call {
if (typeof method !== 'string') {

View File

@ -59,6 +59,7 @@ export interface MetadataRequester {
}
export interface MessageRequester {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(message: any, next: (message: any) => void): void;
}
@ -183,6 +184,7 @@ const defaultRequester: FullRequester = {
};
export interface InterceptorOptions extends CallOptions {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
method_definition: ClientMethodDefinition<any, any>;
}
@ -190,7 +192,9 @@ export interface InterceptingCallInterface {
cancelWithStatus(status: Status, details: string): void;
getPeer(): string;
start(metadata: Metadata, listener?: Partial<InterceptingListener>): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sendMessageWithContext(context: MessageContext, message: any): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sendMessage(message: any): void;
startRead(): void;
halfClose(): void;
@ -274,6 +278,7 @@ export class InterceptingCall implements InterceptingCallInterface {
this.nextCall.start(md, finalInterceptingListener);
});
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sendMessageWithContext(context: MessageContext, message: any): void {
this.processingMessage = true;
this.requester.sendMessage(message, (finalMessage) => {
@ -284,6 +289,7 @@ export class InterceptingCall implements InterceptingCallInterface {
}
});
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sendMessage(message: any): void {
this.sendMessageWithContext({}, message);
}
@ -334,6 +340,7 @@ function getCall(channel: Channel, path: string, options: CallOptions): Call {
class BaseInterceptingCall implements InterceptingCallInterface {
constructor(
protected call: Call,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected methodDefinition: ClientMethodDefinition<any, any>
) {}
cancelWithStatus(status: Status, details: string): void {
@ -345,6 +352,7 @@ class BaseInterceptingCall implements InterceptingCallInterface {
setCredentials(credentials: CallCredentials): void {
this.call.setCredentials(credentials);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sendMessageWithContext(context: MessageContext, message: any): void {
let serialized: Buffer;
try {
@ -354,6 +362,7 @@ class BaseInterceptingCall implements InterceptingCallInterface {
this.call.cancelWithStatus(Status.INTERNAL, 'Serialization failure');
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sendMessage(message: any) {
this.sendMessageWithContext({}, message);
}
@ -367,6 +376,7 @@ class BaseInterceptingCall implements InterceptingCallInterface {
interceptingListener?.onReceiveMetadata?.(metadata);
},
onReceiveMessage: (message) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let deserialized: any;
try {
deserialized = this.methodDefinition.responseDeserialize(message);
@ -403,6 +413,7 @@ class BaseInterceptingCall implements InterceptingCallInterface {
*/
class BaseUnaryInterceptingCall extends BaseInterceptingCall
implements InterceptingCallInterface {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(call: Call, methodDefinition: ClientMethodDefinition<any, any>) {
super(call, methodDefinition);
}
@ -411,6 +422,7 @@ class BaseUnaryInterceptingCall extends BaseInterceptingCall
const wrapperListener: InterceptingListener = {
onReceiveMetadata:
listener?.onReceiveMetadata?.bind(listener) ?? ((metadata) => {}),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onReceiveMessage: (message: any) => {
receivedMessage = true;
listener?.onReceiveMessage?.(message);
@ -433,9 +445,11 @@ class BaseUnaryInterceptingCall extends BaseInterceptingCall
*/
class BaseStreamingInterceptingCall extends BaseInterceptingCall
implements InterceptingCallInterface {}
function getBottomInterceptingCall(
channel: Channel,
options: InterceptorOptions,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
methodDefinition: ClientMethodDefinition<any, any>
) {
const call = getCall(channel, methodDefinition.path, options);
@ -455,6 +469,7 @@ export interface Interceptor {
}
export interface InterceptorProvider {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(methodDefinition: ClientMethodDefinition<any, any>): Interceptor;
}
@ -464,8 +479,10 @@ export interface InterceptorArguments {
callInterceptors: Interceptor[];
callInterceptorProviders: InterceptorProvider[];
}
export function getInterceptingCall(
interceptorArgs: InterceptorArguments,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
methodDefinition: ClientMethodDefinition<any, any>,
options: CallOptions,
channel: Channel

View File

@ -59,6 +59,7 @@ export interface UnaryCallback<ResponseType> {
(err: ServiceError | null, value?: ResponseType): void;
}
/* eslint-disable @typescript-eslint/no-explicit-any */
export interface CallOptions {
deadline?: Deadline;
host?: string;
@ -72,6 +73,7 @@ export interface CallOptions {
interceptors?: Interceptor[];
interceptor_providers?: InterceptorProvider[];
}
/* eslint-enable @typescript-eslint/no-explicit-any */
export interface CallProperties<RequestType, ResponseType> {
argument?: RequestType;
@ -84,7 +86,7 @@ export interface CallProperties<RequestType, ResponseType> {
}
export interface CallInvocationTransformer {
(callProperties: CallProperties<any, any>): CallProperties<any, any>;
(callProperties: CallProperties<any, any>): CallProperties<any, any>; // eslint-disable-line @typescript-eslint/no-explicit-any
}
export type ClientOptions = Partial<ChannelOptions> & {
@ -314,6 +316,7 @@ export class Client {
onReceiveMetadata: (metadata) => {
emitter.emit('metadata', metadata);
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onReceiveMessage(message: any) {
if (responseMessage != null) {
call.cancelWithStatus(Status.INTERNAL, 'Too many responses received');
@ -430,6 +433,7 @@ export class Client {
onReceiveMetadata: (metadata) => {
emitter.emit('metadata', metadata);
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onReceiveMessage(message: any) {
if (responseMessage != null) {
call.cancelWithStatus(Status.INTERNAL, 'Too many responses received');
@ -552,6 +556,7 @@ export class Client {
onReceiveMetadata(metadata: Metadata) {
stream.emit('metadata', metadata);
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onReceiveMessage(message: any) {
if (stream.push(message)) {
call.startRead();

View File

@ -67,15 +67,15 @@ if (!semver.satisfies(process.version, supportedNodeVersions)) {
}
interface IndexedObject {
[key: string]: any;
[key: number]: any;
[key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any
[key: number]: any; // eslint-disable-line @typescript-eslint/no-explicit-any
}
function mixin(...sources: IndexedObject[]) {
const result: { [key: string]: Function } = {};
for (const source of sources) {
for (const propName of Object.getOwnPropertyNames(source)) {
const property: any = source[propName];
const property: any = source[propName]; // eslint-disable-line @typescript-eslint/no-explicit-any
if (typeof property === 'function') {
result[propName] = property;
}
@ -250,14 +250,18 @@ export {
export { handleBidiStreamingCall, handleServerStreamingCall, handleUnaryCall };
/* eslint-disable @typescript-eslint/no-explicit-any */
export type Call =
| ClientUnaryCall
| ClientReadableStream<any>
| ClientWritableStream<any>
| ClientDuplexStream<any, any>;
/* eslint-enable @typescript-eslint/no-explicit-any */
/**** Unimplemented function stubs ****/
/* eslint-disable @typescript-eslint/no-explicit-any */
export const loadObject = (value: any, options: any) => {
throw new Error(
'Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead'

View File

@ -21,6 +21,10 @@
* specific object type if the input has the right structure, and throws an
* error otherwise. */
/* The any type is purposely used here. All functions validate their input at
* runtime */
/* eslint-disable @typescript-eslint/no-explicit-any */
export type RoundRobinConfig = {};
export interface XdsConfig {

View File

@ -47,6 +47,8 @@ export const setLogger = (logger: Partial<Console>): void => {
export const setLoggerVerbosity = (verbosity: LogVerbosity): void => {
_logVerbosity = verbosity;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const log = (severity: LogVerbosity, ...args: any[]): void => {
if (severity >= _logVerbosity && typeof _logger.error === 'function') {
_logger.error(...args);

View File

@ -50,6 +50,7 @@ export interface MethodDefinition<RequestType, ResponseType>
ServerMethodDefinition<RequestType, ResponseType> {}
export interface ServiceDefinition {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[index: string]: MethodDefinition<any, any>;
}
@ -164,6 +165,7 @@ function partial(
serialize: Function,
deserialize: Function
): Function {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return function (this: any, ...args: any[]) {
return fn.call(this, path, serialize, deserialize, ...args);
};

View File

@ -18,6 +18,8 @@
import { Duplex, Readable, Writable } from 'stream';
import { EmitterAugmentation1 } from './events';
/* eslint-disable @typescript-eslint/no-explicit-any */
export type WriteCallback = (error: Error | null | undefined) => void;
export interface IntermediateObjectReadable<T> extends Readable {

View File

@ -174,6 +174,7 @@ export class ServerWritableStreamImpl<RequestType, ResponseType>
async _write(
chunk: ResponseType,
encoding: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
callback: (...args: any[]) => void
) {
try {
@ -200,6 +201,7 @@ export class ServerWritableStreamImpl<RequestType, ResponseType>
callback(null);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
end(metadata?: any) {
if (metadata) {
this.trailingMetadata = metadata;
@ -669,6 +671,7 @@ export class Http2ServerCallStream<
}
}
/* eslint-disable @typescript-eslint/no-explicit-any */
type UntypedServerCall = Http2ServerCallStream<any, any>;
function handleExpiredDeadline(call: UntypedServerCall) {

View File

@ -70,6 +70,7 @@ function getUnimplementedStatusResponse(
};
}
/* eslint-disable @typescript-eslint/no-explicit-any */
type UntypedUnaryHandler = UnaryHandler<any, any>;
type UntypedClientStreamingHandler = ClientStreamingHandler<any, any>;
type UntypedServerStreamingHandler = ServerStreamingHandler<any, any>;
@ -411,6 +412,7 @@ export class Server {
this.sessions.forEach((session) => {
// Cast NGHTTP2_CANCEL to any because TypeScript doesn't seem to
// recognize destroy(code) as a valid signature.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
session.destroy(http2.constants.NGHTTP2_CANCEL as any);
});
this.sessions.clear();

View File

@ -22,6 +22,10 @@
* specific object type if the input has the right structure, and throws an
* error otherwise. */
/* The any type is purposely used here. All functions validate their input at
* runtime */
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as lbconfig from './load-balancing-config';
import * as os from 'os';

View File

@ -63,6 +63,7 @@ export class SubchannelPool {
/* These objects are created with Object.create(null), so they do not
* have a prototype, which means that for (... in ...) loops over them
* do not need to be filtered */
// eslint-disable-disable-next-line:forin
for (const channelTarget in this.pool) {
const subchannelObjArray = this.pool[channelTarget];

View File

@ -72,6 +72,7 @@ export namespace assert2 {
* Wraps a function to keep track of whether it was called or not.
* @param fn The function to wrap.
*/
// tslint:disable:no-any
export function mustCall<T>(
fn: (...args: any[]) => T
): (...args: any[]) => T {

View File

@ -49,6 +49,7 @@ class CallCredentialsMock implements CallCredentials {
}
}
// tslint:disable-next-line:no-any
const readFile: (...args: any[]) => Promise<Buffer> = promisify(fs.readFile);
// A promise which resolves to loaded files in the form { ca, key, cert }
const pFixtures = Promise.all(

View File

@ -15,6 +15,8 @@
*
*/
// Allow `any` data type for testing runtime type checking.
// tslint:disable no-any
import * as assert from 'assert';
import * as resolverManager from '../src/resolver';
import { ServiceConfig } from '../src/service-config';

View File

@ -16,6 +16,7 @@
*/
// Allow `any` data type for testing runtime type checking.
// tslint:disable no-any
import * as assert from 'assert';
import { readFileSync } from 'fs';
import { join } from 'path';

View File

@ -16,6 +16,7 @@
*/
// Allow `any` data type for testing runtime type checking.
// tslint:disable no-any
import * as assert from 'assert';
import * as path from 'path';

View File

@ -16,6 +16,7 @@
*/
// Allow `any` data type for testing runtime type checking.
// tslint:disable no-any
import * as assert from 'assert';
import { join } from 'path';

View File

@ -16,6 +16,7 @@
*/
// Allow `any` data type for testing runtime type checking.
// tslint:disable no-any
import * as assert from 'assert';
import * as fs from 'fs';
import * as http2 from 'http2';
@ -38,13 +39,13 @@ describe('Server', () => {
describe('constructor', () => {
it('should work with no arguments', () => {
assert.doesNotThrow(() => {
new Server();
new Server(); // tslint:disable-line:no-unused-expression
});
});
it('should work with an empty object argument', () => {
assert.doesNotThrow(() => {
new Server({});
new Server({}); // tslint:disable-line:no-unused-expression
});
});