From 4ea791dad70167b2ab1d7e28c1e5aef6cf8ce5f0 Mon Sep 17 00:00:00 2001 From: Branden Visser Date: Sat, 12 Dec 2020 21:12:03 -0500 Subject: [PATCH] fix linting issues --- .eslintrc.js | 4 ++++ karma.conf.js | 23 +++++++++++------------ src/connector.ts | 16 ++++++++-------- src/types.ts | 2 +- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c0b99a6..66c3718 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', diff --git a/karma.conf.js b/karma.conf.js index 1b14228..c82300a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -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) @@ -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, diff --git a/src/connector.ts b/src/connector.ts index 5c09de7..e350da7 100644 --- a/src/connector.ts +++ b/src/connector.ts @@ -12,8 +12,8 @@ import { hasValue } from './util'; type SystemProtocol = { ping: { - body: {}; - response: {}; + body: Record; + response: Record; }; }; @@ -146,7 +146,7 @@ function handleTell0< function handleAsk0< P extends Protoframe, T extends ProtoframeMessageType

, - R extends ProtoframeMessageResponse & {} + R extends ProtoframeMessageResponse & Record >( thisWindow: Window, targetWindow: Window, @@ -190,7 +190,7 @@ async function ask0< P extends Protoframe, T extends ProtoframeMessageType

, B extends ProtoframeMessageBody, - R extends ProtoframeMessageResponse & {} + R extends ProtoframeMessageResponse & Record >( thisWindow: Window, targetWindow: Window, @@ -275,7 +275,7 @@ interface AbstractProtoframePubsub

ask< T extends ProtoframeMessageType

, B extends ProtoframeMessageBody, - R extends ProtoframeMessageResponse & {} + R extends ProtoframeMessageResponse & Record >( type: T, body: B, @@ -291,7 +291,7 @@ interface AbstractProtoframePubsub

*/ handleAsk< T extends ProtoframeMessageType

, - R extends ProtoframeMessageResponse & {} + R extends ProtoframeMessageResponse & Record >( type: T, handler: (body: ProtoframeMessageBody) => Promise, @@ -532,7 +532,7 @@ export class ProtoframePubsub

public handleAsk< T extends ProtoframeMessageType

, - R extends P[T]['response'] & {} + R extends P[T]['response'] & Record >(type: T, handler: (body: P[T]['body']) => Promise): void { this.listeners.push( handleAsk0( @@ -549,7 +549,7 @@ export class ProtoframePubsub

public ask< T extends ProtoframeMessageType

, B extends P[T]['body'], - R extends P[T]['response'] & {} + R extends P[T]['response'] & Record >(type: T, body: B, timeout = 10000): Promise { return ask0( this.thisWindow, diff --git a/src/types.ts b/src/types.ts index 5c5d089..e28fbad 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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>; -export type ProtoframeEntry = { +export type ProtoframeEntry> = { body: B; response?: R; };