Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Don't lint generated typescript declaration files #238

Merged
merged 3 commits into from
Jun 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nodecg-io-core/dashboard/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PersistentData, EncryptedData, decryptData } from "nodecg-io-core/extension/persistenceManager";
import { EventEmitter } from "events";
import { ObjectMap, ServiceInstance, ServiceDependency, Service } from "nodecg-io-core/extension/types";
import { ObjectMap, ServiceInstance, ServiceDependency, Service } from "nodecg-io-core/extension/service";
import { isLoaded } from "./authentication";
import { PasswordMessage } from "nodecg-io-core/extension/messageManager";

Expand All @@ -15,8 +15,8 @@ let password: string | undefined;
* b. having everything at hand using one variable is quite nice so I've added services here to complete it.
*/
interface ConfigData {
instances: ObjectMap<string, ServiceInstance<unknown, unknown>>;
bundles: ObjectMap<string, ServiceDependency<unknown>[]>;
instances: ObjectMap<ServiceInstance<unknown, unknown>>;
bundles: ObjectMap<ServiceDependency<unknown>[]>;
services: Service<unknown, never>[];
}

Expand Down
3 changes: 2 additions & 1 deletion nodecg-io-core/dashboard/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

"lib": ["ES2015", "dom"],
"module": "ES2015",
"sourceMap": true
"sourceMap": true,
"declaration": false
},
"extends": "../../tsconfig.common.json"
}
4 changes: 2 additions & 2 deletions nodecg-io-core/dashboard/utils/selectUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ObjectMap } from "nodecg-io-core/extension/types";
import { ObjectMap } from "nodecg-io-core/extension/service";

export function updateOptionsMap(node: HTMLSelectElement, options: ObjectMap<string, unknown>): void {
export function updateOptionsMap(node: HTMLSelectElement, options: ObjectMap<unknown>): void {
updateOptionsArr(node, Object.keys(options));
}

Expand Down
8 changes: 4 additions & 4 deletions nodecg-io-core/extension/bundleManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NodeCG } from "nodecg/types/server";
import { ObjectMap, Service, ServiceDependency, ServiceInstance } from "./types";
import { ObjectMap, Service, ServiceDependency, ServiceInstance } from "./service";
import { emptySuccess, error, Result } from "./utils/result";
import { EventEmitter } from "events";
import { ServiceProvider } from "./serviceProvider";
Expand All @@ -8,17 +8,17 @@ import { ServiceProvider } from "./serviceProvider";
* Manages bundles and their dependencies on nodecg-io services.
*/
export class BundleManager extends EventEmitter {
private readonly bundles: ObjectMap<string, ServiceDependency<unknown>[]> = {};
private readonly bundles: ObjectMap<ServiceDependency<unknown>[]> = {};

constructor(private readonly nodecg: NodeCG) {
super();
}

/**
* Gets all bundle dependencies
* @return {ObjectMap<string, ServiceDependency<unknown>[]>} all bundle dependencies
* @return {ObjectMap<ServiceDependency<unknown>[]>} all bundle dependencies
*/
getBundleDependencies(): ObjectMap<string, ServiceDependency<unknown>[]> {
getBundleDependencies(): ObjectMap<ServiceDependency<unknown>[]> {
return this.bundles;
}

Expand Down
2 changes: 1 addition & 1 deletion nodecg-io-core/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ServiceManager } from "./serviceManager";
import { BundleManager } from "./bundleManager";
import { MessageManager } from "./messageManager";
import { InstanceManager } from "./instanceManager";
import { Service } from "./types";
import { Service } from "./service";
import { PersistenceManager } from "./persistenceManager";
import { ServiceProvider } from "./serviceProvider";

Expand Down
17 changes: 10 additions & 7 deletions nodecg-io-core/extension/instanceManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NodeCG } from "nodecg/types/server";
import { ObjectMap, Service, ServiceInstance } from "./types";
import { ObjectMap, Service, ServiceInstance } from "./service";
import { emptySuccess, error, Result } from "./utils/result";
import { ServiceManager } from "./serviceManager";
import { BundleManager } from "./bundleManager";
Expand All @@ -10,7 +10,7 @@ import { EventEmitter } from "events";
* Manages instances of services and their configs/clients.
*/
export class InstanceManager extends EventEmitter {
private serviceInstances: ObjectMap<string, ServiceInstance<unknown, unknown>> = {};
private serviceInstances: ObjectMap<ServiceInstance<unknown, unknown>> = {};
private ajv = new Ajv();

constructor(
Expand All @@ -35,9 +35,9 @@ export class InstanceManager extends EventEmitter {

/**
* Returns all existing service instances.
* @return {ObjectMap<string, ServiceInstance<unknown, unknown>>} a map of the instance name to the instance.
* @return {ObjectMap<ServiceInstance<unknown, unknown>>} a map of the instance name to the instance.
*/
getServiceInstances(): ObjectMap<string, ServiceInstance<unknown, unknown>> {
getServiceInstances(): ObjectMap<ServiceInstance<unknown, unknown>> {
return this.serviceInstances;
}

Expand Down Expand Up @@ -164,9 +164,12 @@ export class InstanceManager extends EventEmitter {

// We need to do validation, spawn a Promise
return (async () => {
const schemaValid = this.ajv.validate(service.result.schema, config);
if (!schemaValid) {
return error("Config invalid: " + this.ajv.errorsText());
// If the service has a schema, check it.
if (service.result.schema) {
const schemaValid = this.ajv.validate(service.result.schema, config);
if (!schemaValid) {
return error("Config invalid: " + this.ajv.errorsText());
}
}

// Validation by the service.
Expand Down
14 changes: 7 additions & 7 deletions nodecg-io-core/extension/persistenceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { InstanceManager } from "./instanceManager";
import { BundleManager } from "./bundleManager";
import * as crypto from "crypto-js";
import { emptySuccess, error, Result, success } from "./utils/result";
import { ObjectMap, ServiceDependency, ServiceInstance } from "./types";
import { ObjectMap, ServiceDependency, ServiceInstance } from "./service";
import { ServiceManager } from "./serviceManager";

/**
Expand All @@ -13,11 +13,11 @@ export interface PersistentData {
/**
* All instance data that is held by the {@link InstanceManager}.
*/
instances: ObjectMap<string, ServiceInstance<unknown, unknown>>;
instances: ObjectMap<ServiceInstance<unknown, unknown>>;
/**
* All bundle dependency data that is held by the {@link BundleManager}.
*/
bundleDependencies: ObjectMap<string, ServiceDependency<unknown>[]>;
bundleDependencies: ObjectMap<ServiceDependency<unknown>[]>;
}

/**
Expand Down Expand Up @@ -142,7 +142,7 @@ export class PersistenceManager {
* and then setting the config of the passed object.
* @param instances the service instances that should be loaded.
*/
private loadServiceInstances(instances: ObjectMap<string, ServiceInstance<unknown, unknown>>): Promise<void>[] {
private loadServiceInstances(instances: ObjectMap<ServiceInstance<unknown, unknown>>): Promise<void>[] {
return Object.keys(instances).map((instanceName) => {
const inst = instances[instanceName];
if (inst === undefined) {
Expand Down Expand Up @@ -188,7 +188,7 @@ export class PersistenceManager {
* Loads all passed bundle dependencies into the framework by setting them in the bundle manager.
* @param bundles the bundle dependencies that should be set.
*/
private loadBundleDependencies(bundles: ObjectMap<string, ServiceDependency<unknown>[]>): void {
private loadBundleDependencies(bundles: ObjectMap<ServiceDependency<unknown>[]>): void {
Object.keys(bundles).forEach((bundleName) => {
if (!Object.prototype.hasOwnProperty.call(bundles, bundleName)) {
return;
Expand Down Expand Up @@ -234,9 +234,9 @@ export class PersistenceManager {
* Creates a copy of all service instances without the service clients, because those
* shouldn't be serialized and don't need to be stored in the encrypted config file.
*/
private getServiceInstances(): ObjectMap<string, ServiceInstance<unknown, unknown>> {
private getServiceInstances(): ObjectMap<ServiceInstance<unknown, unknown>> {
const instances = this.instances.getServiceInstances();
const copy: ObjectMap<string, ServiceInstance<unknown, unknown>> = {};
const copy: ObjectMap<ServiceInstance<unknown, unknown>> = {};

for (const instName in instances) {
if (!Object.prototype.hasOwnProperty.call(instances, instName)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Holds generic types for the whole project
// Holds types/interfaces related to services

import { Result } from "./utils/result";
import { ServiceProvider } from "./serviceProvider";
Expand All @@ -12,15 +12,15 @@ import { ServiceProvider } from "./serviceProvider";
* A normal es6 map would use a iterator which can't be serialized by the NodeCG Replicant and thus
* can't be used to give the gui access to the data in this map.
*/
export type ObjectMap<K, V> = Record<K, V | undefined>;
export type ObjectMap<V> = Record<string, V | undefined>;

/**
* Models a service that a bundle can depend upon and use to access e.g. a twitch chat or similar.
* @typeParam R a interface type that describes the user provided config for the service.
* Intended to hold configurations and authentication information that the service needs to provide a client.
* @typeParam C the type of a client that the service will provide to bundles using {@link createClient}.
*/
export interface Service<R, C extends ServiceClient<unknown>> {
export interface Service<R, C> {
/**
* User friendly name of the service that should explain the type of service, e.g. "twitch".
*/
Expand All @@ -43,7 +43,7 @@ export interface Service<R, C extends ServiceClient<unknown>> {
* @param config the config which should be validated.
* @return void if the config passes validation and an error string describing the issue if not.
*/
readonly validateConfig(config: R): Promise<Result<void>>;
validateConfig(config: R): Promise<Result<void>>;

/**
* Creates a client to the service using the validated config.
Expand All @@ -52,15 +52,15 @@ export interface Service<R, C extends ServiceClient<unknown>> {
* @param config the user provided config for the service.
* @return the client if everything went well and an error string describing the issue if a error occured.
*/
readonly createClient(config: R): Promise<Result<C>>;
createClient(config: R): Promise<Result<C>>;

/**
* Stops a client of this service that is not needed anymore.
* Services should close any connections that might exist here.
*
* @param client the client that needs to be stopped.
*/
readonly stopClient(client: C): void;
stopClient(client: C): void;

/**
* Removes all handlers from a service client.
Expand All @@ -72,7 +72,7 @@ export interface Service<R, C extends ServiceClient<unknown>> {
* Can be left unimplemented if the serivce doesn't has any handlers e.g. a http wrapper
* @param client the client of which all handlers should be removed
*/
readonly removeHandlers?(client: C): void;
removeHandlers?(client: C): void;

/**
* This flag can be enabled by services if they can't implement {@link removeHandlers} but also have some handlers that
Expand Down
6 changes: 3 additions & 3 deletions nodecg-io-core/extension/serviceBundle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NodeCGIOCore } from ".";
import { NodeCG } from "nodecg/types/server";
import { Service } from "./types";
import { ObjectMap, Service } from "./service";
import { Result } from "./utils/result";

import * as fs from "fs";
Expand All @@ -18,7 +18,7 @@ export abstract class ServiceBundle<R, C> implements Service<R, C> {
public core: NodeCGIOCore | undefined;
public nodecg: NodeCG;
public serviceType: string;
public schema: unknown;
public schema?: ObjectMap<unknown>;

/**
* The default value for the config.
Expand Down Expand Up @@ -107,7 +107,7 @@ export abstract class ServiceBundle<R, C> implements Service<R, C> {
*/
requiresNoConfig = false;

private readSchema(pathSegments: string[]): unknown {
private readSchema(pathSegments: string[]): ObjectMap<unknown> | undefined {
const joinedPath = path.resolve(...pathSegments);
try {
const fileContent = fs.readFileSync(joinedPath, "utf8");
Expand Down
2 changes: 1 addition & 1 deletion nodecg-io-core/extension/serviceManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Service } from "./types";
import { Service } from "./service";
import { NodeCG } from "nodecg/types/server";
import { error, Result, success } from "./utils/result";

Expand Down
2 changes: 1 addition & 1 deletion nodecg-io-core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This can be used by services and bundles to import everything by just using "nodecg-io-core" and they don't need to know paths
// or where the thing they want to import is located.
// You can obviously still provide the full path if you wish.
export type { ObjectMap, Service, ServiceDependency, ServiceInstance } from "./extension/types";
export type { ObjectMap, Service, ServiceDependency, ServiceInstance } from "./extension/service";
export * from "./extension/utils/result";
export * from "./extension/serviceBundle";
export * from "./extension/serviceProvider";
2 changes: 1 addition & 1 deletion nodecg-io-streamelements/extension/StreamElements.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import io = require("socket.io-client");
import { Result, emptySuccess, error } from "nodecg-io-core";
import { StreamElementsEvent } from "./types";
import { StreamElementsEvent } from "./StreamElementsEvent";
import { EventEmitter } from "events";

export class StreamElementsServiceClient extends EventEmitter {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"bsb": "npm run bootstrap && npm run build",
"rebuild": "npm run clean && npm run build",
"watch": "lerna run --parallel watch",
"lint": "eslint . --ext ts",
"lint": "eslint . --ext ts --ignore-pattern '**/*.d.ts'",
"format": "prettier --write \"./**/*.{ts,html,css,json}\"",
"format-pre-commit": "pretty-quick --staged --pattern '*/**/*.{ts,html,css,json}'",
"prepare": "husky install"
Expand Down