Skip to content

Commit

Permalink
Fixing lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mrinc committed Dec 18, 2023
1 parent 2a9372b commit 4ec0bf5
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 52 deletions.
1 change: 1 addition & 0 deletions nodejs/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
lib
_exports
src/plugins/-*/*.*
src/tests/**/*.*
templates
docker
build
1 change: 1 addition & 0 deletions nodejs/src/base/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { DEBUG_MODE } from "../interfaces/logging";
import { SBLogging } from "../serviceBase/logging";
import {
Expand Down
5 changes: 3 additions & 2 deletions nodejs/src/base/events.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Readable } from "stream";
import { BSBConfigDefinition, BaseWithLoggingAndConfig } from "./base";
import { BSB_ERROR_METHOD_NOT_IMPLEMENTED } from "./errorMessages";
import { DEBUG_MODE } from '../interfaces';
import { SBLogging } from '../serviceBase';
import { DEBUG_MODE } from "../interfaces";
import { SBLogging } from "../serviceBase";

export interface BSBEventsConstructor {
appId: string;
Expand Down
6 changes: 3 additions & 3 deletions nodejs/src/base/logFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class LogFormatter {
return dataFromKeyVP;
}
private formatData(meta: any, key: string) {
let referencedVar = this.getSafeData(meta, key);
const referencedVar = this.getSafeData(meta, key);
if (Tools.isNullOrUndefined(referencedVar)) return "*null/undefined*";
if (Tools.isDate(referencedVar)) return referencedVar.toISOString();
if (Tools.isString(referencedVar)) return referencedVar;
Expand All @@ -39,10 +39,10 @@ export class LogFormatter {
//console.log(`_${message}:${Tools.isObject(meta)}`);
if (!Tools.isObject(meta)) return message;

let dataToParse = message.split("{");
const dataToParse = message.split("{");
let outString = dataToParse[0];
for (let i = 1; i < dataToParse.length; i++) {
let removedVar = dataToParse[i].split("}");
const removedVar = dataToParse[i].split("}");
outString += this.formatData(meta, removedVar[0]) + removedVar[1];
}
return outString;
Expand Down
2 changes: 2 additions & 0 deletions nodejs/src/base/logging.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { BSBConfigDefinition, BaseWithConfig } from "./base";
import { DEBUG_MODE, LogMeta } from "../interfaces/logging";
import { BSB_ERROR_METHOD_NOT_IMPLEMENTED } from "./errorMessages";
Expand Down Expand Up @@ -145,6 +146,7 @@ export abstract class BSBLogging<
* DO NOT REFERENCE/USE THIS CLASS - IT IS AN INTERNALLY REFERENCED CLASS
*/
export class BSBLoggingRef extends BSBLogging<BSBConfigDefinition> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public reportStat(plugin: string, key: string, value: number): void {
throw BSB_ERROR_METHOD_NOT_IMPLEMENTED("BSBLoggingRef", "reportStat");
}
Expand Down
1 change: 1 addition & 0 deletions nodejs/src/base/service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { BSBConfigDefinition, BaseWithLoggingAndConfig } from "./base";
import { ServiceEventsBase, ServiceEventsDefault } from "../interfaces/service";
import { DEBUG_MODE } from "../interfaces/logging";
Expand Down
1 change: 1 addition & 0 deletions nodejs/src/base/serviceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export abstract class BSBServiceClient<
Events["onBroadcast"]
>;
public callMethod<TA extends string>(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
...args: DynamicallyReferencedMethodCallable<
DynamicallyReferencedMethodType<Events["methods"]>,
TA
Expand Down
2 changes: 2 additions & 0 deletions nodejs/src/base/serviceConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BSB_ERROR_METHOD_NOT_IMPLEMENTED } from "./errorMessages";
import { BSBConfigType } from './base';

export abstract class BSBServiceConfig<MyPluginConfig extends Exclude<BSBConfigType, undefined>> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
constructor(cwd: string, pluginCwd: string, pluginName: string) {}
abstract validationSchema: MyPluginConfig;
abstract migrate(
Expand All @@ -17,6 +18,7 @@ export abstract class BSBServiceConfig<MyPluginConfig extends Exclude<BSBConfigT
*/
export class BSBServiceConfigRef extends BSBServiceConfig<any> {
validationSchema = {};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
migrate(toVersion: string, fromVersion: string | null, fromConfig: any) {
throw BSB_ERROR_METHOD_NOT_IMPLEMENTED("BSBServiceConfigRef", "migrate");
}
Expand Down
2 changes: 2 additions & 0 deletions nodejs/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export class FakeServiceConfig extends BSBConfig {
return { name: pluginName, enabled: false };
}
async getPluginConfig(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
pluginType: PluginType,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
plugin: string
): Promise<object | null> {
return null;
Expand Down
3 changes: 3 additions & 0 deletions nodejs/src/interfaces/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type DynamicallyReferencedMethodCallable<
ArgsReference extends boolean = true
//ShowTimeout extends boolean = true
> = ArgsReference extends true
// eslint-disable-next-line @typescript-eslint/no-unused-vars
? Interface[Method] extends (...a: infer Arguments) => infer Return
? [event: Method, ...a: Arguments]
: [event: Method, noMatchingEvent: never]
Expand Down Expand Up @@ -33,6 +34,7 @@ export type DynamicallyReferencedMethodOnIEvents<
export type DynamicallyReferencedMethodEmitIEvents<
Interface extends DynamicallyReferencedMethodBase,
Method extends string
// eslint-disable-next-line @typescript-eslint/no-unused-vars
> = Interface[Method] extends (...a: infer Arguments) => infer Return
? [event: Method, ...a: Arguments]
: [noMatchingEvent: never];
Expand All @@ -43,6 +45,7 @@ export type DynamicallyReferencedMethodEmitEARIEvents<
ArgsReference extends boolean = true
//ShowTimeout extends boolean = true
> = ArgsReference extends true
// eslint-disable-next-line @typescript-eslint/no-unused-vars
? Interface[Method] extends (...a: infer Arguments) => infer Return
? //? ShowTimeout extends true
[event: Method, timeoutSeconds?: number, ...a: Arguments]
Expand Down
6 changes: 3 additions & 3 deletions nodejs/src/plugins/config-default/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class Plugin extends BSBConfig {
);
}
async getLoggingPlugins(): Promise<Record<string, LoggingConfig>> {
let plugins = Object.keys(
const plugins = Object.keys(
this._appConfig[this._deploymentProfile].logging ?? {}
).filter((x) => {
return (
Expand All @@ -73,7 +73,7 @@ export class Plugin extends BSBConfig {
}, {} as Record<string, LoggingConfig>);
}
async getEventsPlugins(): Promise<Record<string, EventsConfig>> {
let plugins = Object.keys(
const plugins = Object.keys(
this._appConfig[this._deploymentProfile].events ?? {}
).filter((x) => {
return (
Expand All @@ -92,7 +92,7 @@ export class Plugin extends BSBConfig {
}, {} as Record<string, EventsConfig>);
}
async getServicePlugins(): Promise<Record<string, PluginDefition>> {
let plugins = Object.keys(
const plugins = Object.keys(
this._appConfig[this._deploymentProfile].services ?? {}
).filter((x) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion nodejs/src/plugins/events-default/events/emitAndReturn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class emitAndReturn extends EventEmitter {
});
const self = this;
return new Promise((resolve, reject) => {
let timeoutHandler = setTimeout(() => {
const timeoutHandler = setTimeout(() => {
reject("Timeout");
}, timeoutSeconds * 1000);
self.emit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class emitStreamAndReceiveStream extends EventEmitter {
});
const self = this;
return new Promise((resolve) => {
let receiptTimeoutHandler: NodeJS.Timeout = setTimeout(() => {
const receiptTimeoutHandler: NodeJS.Timeout = setTimeout(() => {
const err = new Error("Receive Receipt Timeout");
listener(err, null!);
self.emit(`${streamId}-error`, err);
Expand Down Expand Up @@ -73,7 +73,7 @@ export default class emitStreamAndReceiveStream extends EventEmitter {
let receiptTimeoutHandler: NodeJS.Timeout | null = setTimeout(() => {
reject(new Error("Send Receipt Timeout"));
}, self.staticCommsTimeout);
let timeoutHandler = setTimeout(() => {
const timeoutHandler = setTimeout(() => {
reject(new Error("Stream Timeout"));
}, timeout * 1000);
self.once(`${streamId}-emit`, () => {
Expand Down
2 changes: 1 addition & 1 deletion nodejs/src/plugins/logging-default/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class Plugin extends BSBLogging<BSBConfigDefinition> {
messageOrError: T | Error,
meta?: LogMeta<T>
): void {
let message =
const message =
typeof messageOrError === "string"
? messageOrError
: messageOrError.message;
Expand Down
2 changes: 1 addition & 1 deletion nodejs/src/plugins/service-default1/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class Plugin extends BSBService<any, ServiceTypes> {
"onReturnable",
async (a: number, b: number) => {
this.log.warn("RECEIVED onReturnable ({a},{b})", { a, b });
let result = await this.events.emitEventAndReturn(
const result = await this.events.emitEventAndReturn(
"onReverseReturnable",
5,
a,
Expand Down
28 changes: 15 additions & 13 deletions nodejs/src/serviceBase/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class SBEvents {
pluginName: string;
plugin: BSBEvents<any>;
} {
let matchingEvent = this.getPluginsMatchingTriggerEvent(eventAs, plugin);
const matchingEvent = this.getPluginsMatchingTriggerEvent(eventAs, plugin);
if (matchingEvent === undefined)
throw new BSBError(
"SBEvents-triggerEvent",
Expand All @@ -130,8 +130,8 @@ export class SBEvents {
}
public async init(sbConfig: SBConfig, sbLogging: SBLogging) {
this.log.debug("INIT SBEvents");
let plugins = await sbConfig.getEventsPlugins();
for (let plugin of Object.keys(plugins)) {
const plugins = await sbConfig.getEventsPlugins();
for (const plugin of Object.keys(plugins)) {
await this.addEvents(
sbConfig,
sbLogging,
Expand Down Expand Up @@ -195,7 +195,7 @@ export class SBEvents {
name: plugin.name,
});

let eventsPlugin = new reference.plugin({
const eventsPlugin = new reference.plugin({
appId: this.appId,
mode: this.mode,
pluginName: reference.name,
Expand All @@ -215,8 +215,10 @@ export class SBEvents {
eventAsType = "events";
} else if (typeof filter === "object") {
const methods = Object.keys(EventsEventTypesBase);
for (let method of methods) {
if (filter.hasOwnProperty(method)) {
for (const method of methods) {
if (
(filter as unknown as Record<string, any>)[method] !== undefined
) {
const methodValue = filter[method as keyof typeof filter];
if (typeof methodValue === "boolean") {
eventAsType = "eventsState";
Expand Down Expand Up @@ -305,7 +307,7 @@ export class SBEvents {
const start = process.hrtime();
try {
await SmartFunctionCallAsync(context, listener, ...iargs);
let diff = process.hrtime(start);
const diff = process.hrtime(start);
this.log.reportStat(
`on-broadcast-${eventsPluginName}-${pluginName}-${event}`,
(diff[0] * NS_PER_SEC + diff[1]) * MS_PER_NS
Expand Down Expand Up @@ -381,7 +383,7 @@ export class SBEvents {
try {
//console.log("CALL ON EVENT", context, listener, iargs);
await SmartFunctionCallAsync(context, listener, ...iargs);
let diff = process.hrtime(start);
const diff = process.hrtime(start);
this.log.reportStat(
`on-event-${eventsPluginName}-${pluginName}-${event}`,
(diff[0] * NS_PER_SEC + diff[1]) * MS_PER_NS
Expand Down Expand Up @@ -491,7 +493,7 @@ export class SBEvents {
const start = process.hrtime();
try {
const resp = await SmartFunctionCallAsync(context, listener, ...iargs);
let diff = process.hrtime(start);
const diff = process.hrtime(start);
this.log.reportStat(
`on-returnableevent-${eventsPluginName}-${pluginName}-${event}`,
(diff[0] * NS_PER_SEC + diff[1]) * MS_PER_NS
Expand Down Expand Up @@ -584,7 +586,7 @@ export class SBEvents {
timeoutSeconds,
args
);
let diff = process.hrtime(start);
const diff = process.hrtime(start);
this.log.reportStat(
`emit-eventandreturn-${plugin.pluginName}-${pluginName}-${event}`,
(diff[0] * NS_PER_SEC + diff[1]) * MS_PER_NS
Expand Down Expand Up @@ -623,7 +625,7 @@ export class SBEvents {
timeoutSeconds,
args
);
let diff = process.hrtime(start);
const diff = process.hrtime(start);
this.log.reportStat(
`emit-eventandreturn-${plugin.pluginName}-${pluginName}-${event}-${serverId}`,
(diff[0] * NS_PER_SEC + diff[1]) * MS_PER_NS
Expand Down Expand Up @@ -658,7 +660,7 @@ export class SBEvents {
error,
stream
);
let diff = process.hrtime(start);
const diff = process.hrtime(start);
this.log.reportStat(
`receivestream-${eventsPluginName}-${pluginName}-${event}`,
(diff[0] * NS_PER_SEC + diff[1]) * MS_PER_NS
Expand Down Expand Up @@ -724,7 +726,7 @@ export class SBEvents {
streamId,
stream
);
let diff = process.hrtime(start);
const diff = process.hrtime(start);
this.log.reportStat(
`sendstream-${plugin.pluginName}-${pluginName}-${event}`,
(diff[0] * NS_PER_SEC + diff[1]) * MS_PER_NS
Expand Down
14 changes: 8 additions & 6 deletions nodejs/src/serviceBase/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class SBLogging {
messageOrKey: T | string,
metaOrValue: LogMeta<T> | number
): Promise<void> {
for (let logger of this.getPluginsMatchingLogEvent(logAs, plugin)) {
for (const logger of this.getPluginsMatchingLogEvent(logAs, plugin)) {
if (logAs === "reportStat") {
await this.triggerLogEventReportStat(
logger.plugin,
Expand Down Expand Up @@ -216,8 +216,8 @@ export class SBLogging {
}
public async init(sbConfig: SBConfig) {
this.log.debug("INIT SBLogging");
let plugins = await sbConfig.getLoggingPlugins();
for (let plugin of Object.keys(plugins)) {
const plugins = await sbConfig.getLoggingPlugins();
for (const plugin of Object.keys(plugins)) {
await this.addLogger(
sbConfig,
{
Expand Down Expand Up @@ -264,7 +264,7 @@ export class SBLogging {
name: plugin.name,
});

let loggerPlugin = new reference.plugin({
const loggerPlugin = new reference.plugin({
appId: this.appId,
mode: this.mode,
pluginName: reference.name,
Expand All @@ -283,8 +283,10 @@ export class SBLogging {
logAsType = "events";
} else if (typeof filter === "object") {
const methods = Object.keys(LoggingEventTypesBase);
for (let method of methods) {
if (filter.hasOwnProperty(method)) {
for (const method of methods) {
if (
(filter as unknown as Record<string, any>)[method] !== undefined
) {
const methodValue = filter[method as keyof typeof filter];
if (typeof methodValue === "boolean") {
logAsType = "eventsState";
Expand Down
4 changes: 2 additions & 2 deletions nodejs/src/serviceBase/serviceBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export class ServiceBase {
this._keeps[stepName] = process.hrtime();
}
private async _outputKeep(stepName: BootStatKeys) {
let diff = process.hrtime(this._keeps[stepName] || undefined);
let logMeta: LogMeta<typeof TIMEKEEPLOG> = {
const diff = process.hrtime(this._keeps[stepName] || undefined);
const logMeta: LogMeta<typeof TIMEKEEPLOG> = {
nsTime: diff[0] * NS_PER_SEC + diff[1],
msTime: (diff[0] * NS_PER_SEC + diff[1]) * MS_PER_NS,
timerName: stepName,
Expand Down
Loading

0 comments on commit 4ec0bf5

Please sign in to comment.