Narrow linting rules and fix for eslintrc for js files

This commit is contained in:
hensm
2022-04-27 22:28:38 +01:00
parent 5e2d9a2fbc
commit dececa46c3
27 changed files with 298 additions and 246 deletions

View File

@@ -72,8 +72,6 @@ export default class Session extends CastClient {
this.establishAppConnection(this.transportId);
this.onSessionCreated?.(this.sessionId);
const { friendlyName } = this.receiverDevice;
messaging.sendMessage({
subject: "cast:sessionCreated",
data: {

View File

@@ -3,7 +3,7 @@
import messaging, { Message } from "../../messaging";
import Session from "./Session";
import CastClient, { NS_CONNECTION, NS_RECEIVER } from "./client";
import CastClient from "./client";
const sessions = new Map<string, Session>();

View File

@@ -125,7 +125,7 @@ interface BreakClip {
contentId?: string;
contentType?: string;
contentUrl?: string;
customData?: {};
customData?: unknown;
duration?: number;
id: string;
hlsSegmentFormat?: HlsSegmentFormat;
@@ -137,7 +137,7 @@ interface BreakClip {
interface TextTrackStyle {
backgroundColor: Nullable<string>;
customData: any;
customData: unknown;
edgeColor: Nullable<string>;
edgeType: Nullable<string>;
fontFamily: Nullable<string>;
@@ -151,7 +151,7 @@ interface TextTrackStyle {
}
interface Track {
customData: any;
customData: unknown;
language: Nullable<string>;
name: Nullable<string>;
subtype: Nullable<string>;
@@ -162,7 +162,7 @@ interface Track {
}
interface UserActionState {
customData: any;
customData: unknown;
userAction: UserAction;
}
@@ -185,7 +185,7 @@ interface MediaInformation {
contentId: string;
contentType: string;
contentUrl?: string;
customData: any;
customData: unknown;
duration: Nullable<number>;
entity?: string;
hlsSegmentFormat?: HlsSegmentFormat;
@@ -269,7 +269,7 @@ interface PhotoMediaMetadata {
interface QueueItem {
activeTrackIds: Nullable<number[]>;
autoplay: boolean;
customData: any;
customData: unknown;
itemId: Nullable<number>;
media: MediaInformation;
playbackDuration: Nullable<number>;

View File

@@ -6,7 +6,7 @@ import { handleCastMessage } from "./components/cast";
import { startDiscovery, stopDiscovery } from "./components/discovery";
import { startMediaServer, stopMediaServer } from "./components/mediaServer";
import { __applicationName, __applicationVersion } from "../../package.json";
import { __applicationVersion } from "../../package.json";
process.on("SIGTERM", () => {
stopDiscovery();

View File

@@ -37,7 +37,6 @@ export async function convertSrtToVtt(srtFilePath: string) {
* millisecond separator.
*/
for (const groups of fileContents.matchAll(REGEX_CAPTION)) {
const captionSource = groups[0];
const captionIndex = groups[1];
const captionTime = groups[2];
const captionText = groups[3];

View File

@@ -163,12 +163,12 @@ type MessageDefinitions = {
/**
* Sent to bridge to stop HTTP media server.
*/
"bridge:stopMediaServer": {};
"bridge:stopMediaServer": undefined;
/**
* Sent to media sender from bridge when the media server has
* stopped.
*/
"mediaCast:mediaServerStopped": {};
"mediaCast:mediaServerStopped": undefined;
/**
* Sent to media sender from bridge when the media server has
* encountered an error.
@@ -190,8 +190,8 @@ type Messages = {
* all-optional keys.
*/
type NarrowedMessage<L extends MessageBase<keyof MessageDefinitions>> =
L extends any
? {} extends L["data"]
L extends unknown
? undefined extends L["data"]
? Omit<L, "data"> & Partial<L>
: L
: never;
@@ -231,7 +231,7 @@ class Messenger extends TypedEmitter<MessengerEvents> {
this.encodeTransform.write(message);
}
send(data: any) {
send(data: unknown) {
this.encodeTransform.write(data);
}
}

View File

@@ -1,9 +1,9 @@
"use strict";
import { Transform } from "stream";
import { Transform, TransformCallback } from "stream";
import { Message } from "./bridge/messaging";
type ResponseHandlerFunction = (message: Message) => Promise<any>;
type ResponseHandlerFunction = (message: Message) => Promise<unknown>;
/**
* Takes a handler function that implements the transform
@@ -20,8 +20,7 @@ export class ResponseTransform extends Transform {
public _transform(
chunk: Message,
_encoding: string,
// tslint:disable-next-line:ban-types
callback: Function
callback: TransformCallback
) {
Promise.resolve(this._handler(chunk)).then(res => {
if (res) {
@@ -49,10 +48,10 @@ export class DecodeTransform extends Transform {
}
public _transform(
chunk: any,
chunk: Uint8Array,
_encoding: string,
// tslint:disable-next-line:ban-types
callback: Function
callback: TransformCallback
) {
// Append next chunk to buffer
this._messageBuffer = Buffer.concat([this._messageBuffer, chunk]);
@@ -108,10 +107,10 @@ export class EncodeTransform extends Transform {
}
public _transform(
chunk: any,
chunk: Uint8Array,
_encoding: string,
// tslint:disable-next-line:ban-types
callback: Function
callback: TransformCallback
) {
const messageLength = Buffer.alloc(4);
const message = Buffer.from(JSON.stringify(chunk));