Skip to content

Commit

Permalink
chore: mandatory code format
Browse files Browse the repository at this point in the history
  • Loading branch information
svrooij committed Feb 7, 2024
1 parent ec5b501 commit e1d195b
Show file tree
Hide file tree
Showing 24 changed files with 46 additions and 45 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Expand Up @@ -13,6 +13,7 @@ module.exports = {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. '@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/return-await': 'off',
'class-methods-use-this':'off',
'max-classes-per-file':'off',
'max-len':'off',
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/metadata-helper.ts
Expand Up @@ -18,7 +18,7 @@ export default class MetadataHelper {
static ParseDIDLTrack(didl: unknown, host: string, port = 1400): Track | undefined {
if (typeof didl === 'undefined') return undefined;
MetadataHelper.debug('Parsing DIDL %o', didl);
const parsedItem = didl as {[key: string]: any };
const parsedItem = didl as { [key: string]: any };
const didlItem = (parsedItem['DIDL-Lite'] && parsedItem['DIDL-Lite'].item) ? parsedItem['DIDL-Lite'].item : parsedItem;
const track: Track = {
Album: XmlHelper.DecodeHtml(didlItem['upnp:album']),
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/playmode-helper.ts
Expand Up @@ -23,7 +23,7 @@ export default class PlayModeHelper {
}
}

private static repeatMap: { [key in PlayMode]: Repeat} = {
private static repeatMap: { [key in PlayMode]: Repeat } = {
[PlayMode.RepeatAll]: Repeat.RepeatAll,
[PlayMode.Shuffle]: Repeat.RepeatAll,
[PlayMode.RepeatOne]: Repeat.RepeatOne,
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/xml-helper.ts
Expand Up @@ -125,7 +125,7 @@ export default class XmlHelper {
}
}

input.children.forEach((child: XmlElement | XmlText | XmlCdata | XmlComment | XmlProcessingInstruction| XmlDeclaration | XmlDocumentType) => {
input.children.forEach((child: XmlElement | XmlText | XmlCdata | XmlComment | XmlProcessingInstruction | XmlDeclaration | XmlDocumentType) => {
// for (const child of input.children) {
if (child instanceof XmlElement) {
const value = this.NormalizeXml(child, removeNamespace);
Expand Down
4 changes: 2 additions & 2 deletions src/models/playmode.ts
Expand Up @@ -8,11 +8,11 @@ export enum PlayMode {
/**
* @deprecated Typ-o replaced by ShuffleRepeatOne
*/
SuffleRepeatOne = 'SHUFFLE_REPEAT_ONE'
SuffleRepeatOne = 'SHUFFLE_REPEAT_ONE',
}

export enum Repeat {
Off = 'Off',
RepeatAll = 'RepeatAll',
RepeatOne = 'RepeatOne'
RepeatOne = 'RepeatOne',
}
2 changes: 1 addition & 1 deletion src/models/service-event.ts
Expand Up @@ -19,5 +19,5 @@ export enum ServiceEvents {
LastChange = 'serviceEvent',
ServiceEvent = 'serviceEvent',
SubscriptionError = 'subscriptionError',
Unprocessed = 'rawEvent'
Unprocessed = 'rawEvent',
}
4 changes: 2 additions & 2 deletions src/models/transport-state.ts
Expand Up @@ -2,12 +2,12 @@ export enum TransportState {
Stopped = 'STOPPED',
Playing = 'PLAYING',
Paused = 'PAUSED_PLAYBACK',
Transitioning = 'TRANSITIONING'
Transitioning = 'TRANSITIONING',
}

export enum GroupTransportState {
GroupStopped = 'GROUP_STOPPED',
GroupPlaying = 'GROUP_PLAYING'
GroupPlaying = 'GROUP_PLAYING',
}

export type ExtendedTransportState = TransportState | GroupTransportState;
4 changes: 2 additions & 2 deletions src/services/alarm-clock.service.ts
Expand Up @@ -132,7 +132,7 @@ export class AlarmClockServiceBase extends BaseService<AlarmClockServiceEvent> {
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('UpdateAlarm', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
AssignedID: 'number',
CurrentDailyIndexRefreshTime: 'string',
Expand All @@ -153,7 +153,7 @@ export class AlarmClockServiceBase extends BaseService<AlarmClockServiceEvent> {
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
AlarmListVersion: 'string',
DailyIndexRefreshTime: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/audio-in.service.ts
Expand Up @@ -51,7 +51,7 @@ export class AudioInService extends BaseService<AudioInServiceEvent> {
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('StopTransmissionToGroup', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
CurrentName: 'string',
CurrentIcon: 'string',
Expand All @@ -62,7 +62,7 @@ export class AudioInService extends BaseService<AudioInServiceEvent> {
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
AudioInputName: 'string',
Icon: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/av-transport.service.ts
Expand Up @@ -345,7 +345,7 @@ export class AVTransportService extends BaseService<AVTransportServiceEvent> {
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('Stop', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
FirstTrackNumberEnqueued: 'number',
NumTracksAdded: 'number',
Expand Down Expand Up @@ -391,7 +391,7 @@ export class AVTransportService extends BaseService<AVTransportServiceEvent> {
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
AbsoluteCounterPosition: 'number',
AbsoluteTimePosition: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/connection-manager.service.ts
Expand Up @@ -39,7 +39,7 @@ export class ConnectionManagerService extends BaseService<ConnectionManagerServi
Promise<GetProtocolInfoResponse> { return await this.SoapRequest<GetProtocolInfoResponse>('GetProtocolInfo'); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
ConnectionIDs: 'string',
RcsID: 'number',
Expand All @@ -55,7 +55,7 @@ export class ConnectionManagerService extends BaseService<ConnectionManagerServi
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
CurrentConnectionIDs: 'string',
SinkProtocolInfo: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/content-directory.service.ts
Expand Up @@ -119,7 +119,7 @@ export class ContentDirectoryServiceBase extends BaseService<ContentDirectorySer
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('UpdateObject', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
Result: 'string',
NumberReturned: 'number',
Expand All @@ -140,7 +140,7 @@ export class ContentDirectoryServiceBase extends BaseService<ContentDirectorySer
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
Browseable: 'boolean',
ContainerUpdateIDs: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/device-properties.service.ts
Expand Up @@ -145,7 +145,7 @@ export class DevicePropertiesService extends BaseService<DevicePropertiesService
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('SetZoneAttributes', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
State: 'string',
IncludeLinkedZones: 'boolean',
Expand Down Expand Up @@ -175,7 +175,7 @@ export class DevicePropertiesService extends BaseService<DevicePropertiesService
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
AirPlayEnabled: 'boolean',
AutoplayIncludeLinkedZones: 'boolean',
Expand Down
4 changes: 2 additions & 2 deletions src/services/group-management.service.ts
Expand Up @@ -42,7 +42,7 @@ export class GroupManagementService extends BaseService<GroupManagementServiceEv
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('SetSourceAreaIds', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
CurrentTransportSettings: 'string',
CurrentURI: 'string',
Expand All @@ -53,7 +53,7 @@ export class GroupManagementService extends BaseService<GroupManagementServiceEv
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
GroupCoordinatorIsLocal: 'boolean',
LocalGroupUUID: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/group-rendering-control.service.ts
Expand Up @@ -96,7 +96,7 @@ export class GroupRenderingControlService extends BaseService<GroupRenderingCont
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('SnapshotGroupVolume', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
CurrentMute: 'boolean',
CurrentVolume: 'number',
Expand All @@ -105,7 +105,7 @@ export class GroupRenderingControlService extends BaseService<GroupRenderingCont
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
GroupMute: 'boolean',
GroupVolume: 'number',
Expand Down
4 changes: 2 additions & 2 deletions src/services/ht-control.service.ts
Expand Up @@ -54,7 +54,7 @@ export class HTControlService extends BaseService<HTControlServiceEvent> {
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('SetLEDFeedbackState', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
CurrentIRRepeaterState: 'string',
LEDFeedbackState: 'string',
Expand All @@ -63,7 +63,7 @@ export class HTControlService extends BaseService<HTControlServiceEvent> {
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
IRRepeaterState: 'string',
LEDFeedbackState: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/music-services.service.ts
Expand Up @@ -43,7 +43,7 @@ export class MusicServicesServiceBase extends BaseService<MusicServicesServiceEv
Promise<boolean> { return await this.SoapRequestNoResponse('UpdateAvailableServices'); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
SessionId: 'string',
AvailableServiceDescriptorList: 'string',
Expand All @@ -53,7 +53,7 @@ export class MusicServicesServiceBase extends BaseService<MusicServicesServiceEv
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
ServiceId: 'number',
ServiceListVersion: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/q-play.service.ts
Expand Up @@ -33,7 +33,7 @@ export class QPlayService extends BaseService<undefined> {
Promise<QPlayAuthResponse> { return await this.SoapRequestWithBody<typeof input, QPlayAuthResponse>('QPlayAuth', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
Code: 'string',
MID: 'string',
Expand All @@ -42,7 +42,7 @@ export class QPlayService extends BaseService<undefined> {
}

// No properties in service description, throw error on retrieval.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
throw new Error('No event properties in service definition');
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/queue.service.ts
Expand Up @@ -66,7 +66,7 @@ export class QueueService extends BaseService<QueueServiceEvent> {
Promise<SaveAsSonosPlaylistResponse> { return await this.SoapRequestWithBody<typeof input, SaveAsSonosPlaylistResponse>('SaveAsSonosPlaylist', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
FirstTrackNumberEnqueued: 'number',
NumTracksAdded: 'number',
Expand All @@ -83,7 +83,7 @@ export class QueueService extends BaseService<QueueServiceEvent> {
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
Curated: 'boolean',
LastChange: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/rendering-control.service.ts
Expand Up @@ -173,7 +173,7 @@ export class RenderingControlServiceBase extends BaseService<RenderingControlSer
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('SetVolumeDB', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
CurrentBass: 'number',
CurrentValue: 'number',
Expand All @@ -199,7 +199,7 @@ export class RenderingControlServiceBase extends BaseService<RenderingControlSer
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
AudioDelay: 'string',
AudioDelayLeftRear: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/system-properties.service.ts
Expand Up @@ -100,7 +100,7 @@ export class SystemPropertiesServiceBase extends BaseService<SystemPropertiesSer
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('SetString', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
AccountUDN: 'string',
AccountNickname: 'string',
Expand All @@ -113,7 +113,7 @@ export class SystemPropertiesServiceBase extends BaseService<SystemPropertiesSer
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
CustomerID: 'string',
ThirdPartyHash: 'string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/virtual-line-in.service.ts
Expand Up @@ -50,14 +50,14 @@ export class VirtualLineInService extends BaseService<VirtualLineInServiceEvent>
Promise<boolean> { return await this.SoapRequestWithBodyNoResponse<typeof input>('StopTransmission', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
CurrentTransportSettings: 'string',
};
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
AVTransportURIMetaData: 'Track | string',
CurrentTrackMetaData: 'Track | string',
Expand Down
4 changes: 2 additions & 2 deletions src/services/zone-group-topology.service.ts
Expand Up @@ -64,7 +64,7 @@ export class ZoneGroupTopologyServiceBase extends BaseService<ZoneGroupTopologyS
Promise<SubmitDiagnosticsResponse> { return await this.SoapRequestWithBody<typeof input, SubmitDiagnosticsResponse>('SubmitDiagnostics', input); }
// #endregion

protected responseProperties(): {[key: string]: string} {
protected responseProperties(): { [key: string]: string } {
return {
UpdateItem: 'string',
CurrentZoneGroupName: 'string',
Expand All @@ -77,7 +77,7 @@ export class ZoneGroupTopologyServiceBase extends BaseService<ZoneGroupTopologyS
}

// Event properties from service description.
protected eventProperties(): {[key: string]: string} {
protected eventProperties(): { [key: string]: string } {
return {
AlarmRunSequence: 'string',
AreasUpdateID: 'string',
Expand Down
10 changes: 5 additions & 5 deletions src/sonos-device.ts
Expand Up @@ -49,7 +49,7 @@ export default class SonosDevice extends SonosDeviceBase {
* @param {({coordinator?: SonosDevice; name: string; managerEvents: EventEmitter} | undefined)} [groupConfig=undefined] groupConfig is used by the SonosManager to setup group change events.
* @memberof SonosDevice
*/
constructor(host: string, port = 1400, uuid: string | undefined = undefined, name: string | undefined = undefined, groupConfig: {coordinator?: SonosDevice; name: string; managerEvents: EventEmitter} | undefined = undefined) {
constructor(host: string, port = 1400, uuid: string | undefined = undefined, name: string | undefined = undefined, groupConfig: { coordinator?: SonosDevice; name: string; managerEvents: EventEmitter } | undefined = undefined) {
super(host, port, uuid);
this.name = name;
if (groupConfig) {
Expand Down Expand Up @@ -158,7 +158,7 @@ export default class SonosDevice extends SonosDeviceBase {
}
const foundService = this.GetServiceByName(service);
const objectToCallOn = typeof foundService !== 'undefined'
? foundService as unknown as {[key: string]: any}
? foundService as unknown as { [key: string]: any }
: this.executeCommandGetFunctions();

const proto = Object.getPrototypeOf(objectToCallOn);
Expand All @@ -182,9 +182,9 @@ export default class SonosDevice extends SonosDeviceBase {
throw new Error(`Command ${correctCommand} isn't a function`);
}

private executeCommandGetFunctions(): {[key: string]: any} {
private executeCommandGetFunctions(): { [key: string]: any } {
// This code looks weird, but is required to convince TypeScript this is actually what we want.
return this as unknown as {[key: string]: any};
return this as unknown as { [key: string]: any };
}

/**
Expand Down Expand Up @@ -904,7 +904,7 @@ export default class SonosDevice extends SonosDeviceBase {
// #region Group stuff
private boundHandleGroupUpdate = this.handleGroupUpdate.bind(this);

private handleGroupUpdate(data: { coordinator: SonosDevice | undefined; name: string}): void {
private handleGroupUpdate(data: { coordinator: SonosDevice | undefined; name: string }): void {
if (data.coordinator && data.coordinator?.uuid !== this.Uuid && (!this.coordinator || this.coordinator?.Uuid !== data.coordinator?.Uuid)) {
this.debug('Coordinator changed for %s', this.uuid);
this.coordinator?.events?.removeListener('simpleTransportState', this.boundHandleCoordinatorSimpleStateEvent);
Expand Down

0 comments on commit e1d195b

Please sign in to comment.