chore: Enforce a few house rules via eslint (#2539)
This commit is contained in:
committed by
dermotduffy
parent
5572ec728e
commit
921d45e577
+7
-7
@@ -35,13 +35,13 @@ export const hasAudio = (
|
||||
pc?: RTCPeerConnection | null,
|
||||
mseCodecs?: string,
|
||||
): boolean => {
|
||||
// For WebRTC: Check if there's an audio receiver with an active track.
|
||||
// We check that the track is not muted because muted means no media data
|
||||
// is flowing (e.g., the source isn't producing audio). It is not related to
|
||||
// the audio being muted by the user on the receiving end.
|
||||
// Only trust receivers when the connection is actually established — a stale
|
||||
// RTCPeerConnection (e.g. WebRTC failed, fell back to MSE) will have
|
||||
// receivers with muted tracks that don't reflect actual media availability.
|
||||
// For WebRTC: Check if there's an audio receiver with an active track. We
|
||||
// check that the track is not muted because muted means no media data is
|
||||
// flowing (e.g., the source isn't producing audio). It is not related to the
|
||||
// audio being muted by the user on the receiving end. Only trust receivers
|
||||
// when the connection is actually established -- a stale RTCPeerConnection
|
||||
// (e.g. WebRTC failed, fell back to MSE) will have receivers with muted
|
||||
// tracks that don't reflect actual media availability.
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/2417
|
||||
if (pc && pc.connectionState === 'connected') {
|
||||
const receivers = pc.getReceivers();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AdvancedCameraCardError } from '../types.js';
|
||||
|
||||
// Narrows an unknown error to its structured object `context` — non-null and
|
||||
// of object type — or null if the error is not an AdvancedCameraCardError or
|
||||
// Narrows an unknown error to its structured object `context` -- non-null and
|
||||
// of object type -- or null if the error is not an AdvancedCameraCardError or
|
||||
// has no usable context. Consolidates the instanceof + typeof + null-guard
|
||||
// dance that notification builders and error handlers would otherwise repeat.
|
||||
export const getContextFromError = (error: unknown): object | null =>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Walk up `element`'s ancestor chain (through shadow boundaries) looking for
|
||||
* an ancestor with the given tag name. Returns true if one is found and that
|
||||
* same element also appears in the event's composedPath — indicating the event
|
||||
* same element also appears in the event's composedPath -- indicating the event
|
||||
* originated from within the same subtree as the element.
|
||||
*/
|
||||
export const isAncestorInEventPath = (
|
||||
|
||||
@@ -11,10 +11,10 @@ const MEDIA_INFO_HEIGHT_CUTOFF = 50;
|
||||
const MEDIA_INFO_WIDTH_CUTOFF = MEDIA_INFO_HEIGHT_CUTOFF;
|
||||
|
||||
/**
|
||||
* Create a MediaLoadedInfo object. `targetID` is intentionally NOT an option
|
||||
* — it's owned by the source controller (`MediaLoadedInfoSourceController`)
|
||||
* and injected at dispatch time, so leaves don't have to (and can't) plumb
|
||||
* it through info construction.
|
||||
* Create a MediaLoadedInfo object. `targetID` is intentionally NOT an option --
|
||||
* it's owned by the source controller (`MediaLoadedInfoSourceController`) and
|
||||
* injected at dispatch time, so leaves don't have to (and can't) plumb it
|
||||
* through info construction.
|
||||
* @param source An event or HTMLElement that should be used as a source.
|
||||
* @returns A new info or null if one could not be created.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Usage of this function needs to be justified with a comment.
|
||||
export const sleep = async (seconds: number) => {
|
||||
// This is the low-level delay primitive callers reach for instead of a raw timer.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
await new Promise((r) => setTimeout(r, seconds * 1000));
|
||||
};
|
||||
|
||||
@@ -19,6 +19,8 @@ export class Timer {
|
||||
|
||||
public start(seconds: number, func: () => void): void {
|
||||
this.stop();
|
||||
// This class is the sanctioned wrapper for the browser timer APIs.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
this._timer = window.setTimeout(() => {
|
||||
this._timer = null;
|
||||
func();
|
||||
@@ -28,6 +30,8 @@ export class Timer {
|
||||
|
||||
public startRepeated(seconds: number, func: () => void): void {
|
||||
this.stop();
|
||||
// This class is the sanctioned wrapper for the browser timer APIs.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
this._timer = window.setInterval(() => {
|
||||
func();
|
||||
}, seconds * 1000);
|
||||
|
||||
@@ -76,7 +76,7 @@ function strip(schema: z.ZodType, cache: Map<z.ZodType, z.ZodType>): z.ZodType {
|
||||
let result: z.ZodType;
|
||||
|
||||
if (schema instanceof z.ZodDefault || schema instanceof z.ZodPrefault) {
|
||||
// Unwrap the default — don't cache the wrapper itself.
|
||||
// Unwrap the default -- don't cache the wrapper itself.
|
||||
result = strip(toClassic(schema.unwrap()), cache);
|
||||
} else if (schema instanceof z.ZodObject) {
|
||||
const newShape: Record<string, z.core.$ZodType> = {};
|
||||
|
||||
Reference in New Issue
Block a user