Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Aug 27, 2024
1 parent b29c480 commit 386f51c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/connector/src/connection/mosMessageParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ export class MosMessageParser extends EventEmitter<MosMessageParserEvents> {
}
private debugTrace(str: string) {
if (this.debug) {
// Supress console spam:
if (!`${str}`.match(/<heartbeat>/)) {
// Suppress console spam:
if (!/<heartbeat>/.exec(`${str}`)) {
// eslint-disable-next-line no-console
console.log(str)
}
Expand Down
10 changes: 5 additions & 5 deletions packages/connector/src/connection/mosSocketClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class MosSocketClient extends EventEmitter<MosSocketClientEvents> {
if (!this._lastConnectionAttempt || Date.now() - this._lastConnectionAttempt >= this._reconnectDelay) {
// !_lastReconnectionAttempt (means first attempt) OR time > _reconnectionDelay since last attempt
// recreate client if new attempt:
if (this._client && this._client.connecting) {
if (this._client?.connecting) {
this._client.destroy()
this._client.removeAllListeners()
delete this._client
Expand Down Expand Up @@ -274,8 +274,8 @@ export class MosSocketClient extends EventEmitter<MosSocketClientEvents> {
/**
* convenience wrapper to expose all logging calls to parent object
*/
log(args: string | number | any): void {
this.debugTrace(args)
log(...args: any[]): void {
this.debugTrace(...args)
}
public setDebug(debug: boolean): void {
this._debug = debug
Expand Down Expand Up @@ -544,8 +544,8 @@ export class MosSocketClient extends EventEmitter<MosSocketClientEvents> {
}
}, this._commandTimeout)
}
private debugTrace(...strs: any[]) {
private debugTrace(...args: any[]) {
// eslint-disable-next-line no-console
if (this._debug) console.log(...strs)
if (this._debug) console.log(...args)
}
}
2 changes: 1 addition & 1 deletion packages/helper/src/mosModel/MosMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export abstract class MosMessage {
prepare(messageID?: number): void {
if (!this.mosID) throw new Error(`Can't prepare message: mosID missing`)
if (!this.ncsID) throw new Error(`Can't prepare message: ncsID missing`)
this._messageID = messageID ? messageID : MosMessage.getNewMessageID()
this._messageID = messageID ?? MosMessage.getNewMessageID()
}

/** */
Expand Down
6 changes: 3 additions & 3 deletions packages/helper/src/mosModel/parseMosTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function getSpecialMosTypes(strict: boolean) {
validate: (_value: string) => true,
valueOf: (value: string) => value,
stringify: (value: string) => value,
is: (value: string | any): value is string => typeof value !== 'string',
is: (value: any): value is string => typeof value !== 'string',
fallback: () => '',
}
const stringEnum: MosType<string, string, { enum: { [key: string]: string }; value: AnyXMLValue }> = {
Expand All @@ -237,7 +237,7 @@ function getSpecialMosTypes(strict: boolean) {
validate: (_value: string) => true,
valueOf: (value: string) => value,
stringify: (value: string) => value,
is: (value: string | any): value is string => typeof value !== 'string',
is: (value: any): value is string => typeof value !== 'string',
fallback: () => '',
}
const number: MosType<number, number, AnyXMLValue> = {
Expand All @@ -248,7 +248,7 @@ function getSpecialMosTypes(strict: boolean) {
validate: (_value: number) => true,
valueOf: (value: number) => value,
stringify: (value: number) => `${value}`,
is: (value: number | any): value is number => typeof value !== 'number',
is: (value: any): value is number => typeof value !== 'number',
fallback: () => 0,
}

Expand Down
2 changes: 1 addition & 1 deletion packages/helper/src/mosModel/profile1/xmlConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export namespace XMLMosAck {

const ack: IMOSAck = {
ID: mosTypes.mosString128.createRequired(xml.objID, 'objID'),
Revision: mosTypes.number.createOptional(xml.objRev, 'objRev') || 0,
Revision: mosTypes.number.createOptional(xml.objRev, 'objRev') ?? 0,
Status:
mosTypes.stringEnum.createOptional({ value: xml.status, enum: IMOSAckStatus }, 'status') ||
IMOSAckStatus.ACK,
Expand Down
2 changes: 1 addition & 1 deletion packages/model/src/mosTypes/mosDuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function create(anyValue: AnyValue, strict: boolean): IMOSDuration {
if (typeof anyValue === 'number') {
value = anyValue
} else if (typeof anyValue === 'string') {
const m = anyValue.match(/(\d+):(\d+):(\d+)/)
const m = /(\d+):(\d+):(\d+)/.exec(anyValue)
if (!m) throw new Error(`MosDuration: Invalid input format: "${anyValue}"!`)

const hh: number = parseInt(m[1], 10)
Expand Down

0 comments on commit 386f51c

Please sign in to comment.