Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvisser committed Dec 13, 2020
1 parent 9726ffe commit 4ea791d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module.exports = {
},
plugins: ['sort-keys-fix', 'import'],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ varsIgnorePattern: '^_.*' },
],
'import/newline-after-import': 'error',
'import/order': [
'error',
Expand Down
23 changes: 11 additions & 12 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */

// Karma configuration
// Generated on Wed May 27 2020 14:52:46 GMT-0400 (Eastern Daylight Time)
Expand All @@ -24,30 +25,28 @@ module.exports = (config) => {
// list of files / patterns to exclude
exclude: [],

karmaTypescriptConfig: {
bundlerOptions: {
acornOptions: {
ecmaVersion: 11,
},
transforms: [
require('karma-typescript-es6-transform')()
]
}
},

// list of files / patterns to load in the browser
files: [
'node_modules/@babel/polyfill/dist/polyfill.js',
'src/*.ts',
'src/**/*.ts',
'test/*.ts',
'test/**/*.ts'
'test/**/*.ts',
],

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'karma-typescript'],

karmaTypescriptConfig: {
bundlerOptions: {
acornOptions: {
ecmaVersion: 11,
},
transforms: [require('karma-typescript-es6-transform')()],
},
},

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
Expand Down
16 changes: 8 additions & 8 deletions src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { hasValue } from './util';

type SystemProtocol = {
ping: {
body: {};
response: {};
body: Record<string, unknown>;
response: Record<string, unknown>;
};
};

Expand Down Expand Up @@ -146,7 +146,7 @@ function handleTell0<
function handleAsk0<
P extends Protoframe,
T extends ProtoframeMessageType<P>,
R extends ProtoframeMessageResponse<P, T> & {}
R extends ProtoframeMessageResponse<P, T> & Record<string, unknown>
>(
thisWindow: Window,
targetWindow: Window,
Expand Down Expand Up @@ -190,7 +190,7 @@ async function ask0<
P extends Protoframe,
T extends ProtoframeMessageType<P>,
B extends ProtoframeMessageBody<P, T>,
R extends ProtoframeMessageResponse<P, T> & {}
R extends ProtoframeMessageResponse<P, T> & Record<string, unknown>
>(
thisWindow: Window,
targetWindow: Window,
Expand Down Expand Up @@ -275,7 +275,7 @@ interface AbstractProtoframePubsub<P extends Protoframe>
ask<
T extends ProtoframeMessageType<P>,
B extends ProtoframeMessageBody<P, T>,
R extends ProtoframeMessageResponse<P, T> & {}
R extends ProtoframeMessageResponse<P, T> & Record<string, unknown>
>(
type: T,
body: B,
Expand All @@ -291,7 +291,7 @@ interface AbstractProtoframePubsub<P extends Protoframe>
*/
handleAsk<
T extends ProtoframeMessageType<P>,
R extends ProtoframeMessageResponse<P, T> & {}
R extends ProtoframeMessageResponse<P, T> & Record<string, unknown>
>(
type: T,
handler: (body: ProtoframeMessageBody<P, T>) => Promise<R>,
Expand Down Expand Up @@ -532,7 +532,7 @@ export class ProtoframePubsub<P extends Protoframe>

public handleAsk<
T extends ProtoframeMessageType<P>,
R extends P[T]['response'] & {}
R extends P[T]['response'] & Record<string, unknown>
>(type: T, handler: (body: P[T]['body']) => Promise<R>): void {
this.listeners.push(
handleAsk0(
Expand All @@ -549,7 +549,7 @@ export class ProtoframePubsub<P extends Protoframe>
public ask<
T extends ProtoframeMessageType<P>,
B extends P[T]['body'],
R extends P[T]['response'] & {}
R extends P[T]['response'] & Record<string, unknown>
>(type: T, body: B, timeout = 10000): Promise<R> {
return ask0(
this.thisWindow,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** The protocol type that holds your message types and their schema. */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Protoframe = Record<string, ProtoframeEntry<any, any>>;
export type ProtoframeEntry<B, R extends {}> = {
export type ProtoframeEntry<B, R extends Record<string, unknown>> = {
body: B;
response?: R;
};
Expand Down

0 comments on commit 4ea791d

Please sign in to comment.