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

Commit bc0d3a4

Browse files
authored
Merge pull request #238 from codeoverflow-org/fix/dont-lint-declarations
Don't lint generated typescript declaration files
2 parents ee536dc + 62c9593 commit bc0d3a4

File tree

14 files changed

+43
-39
lines changed

14 files changed

+43
-39
lines changed

nodecg-io-core/dashboard/crypto.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PersistentData, EncryptedData, decryptData } from "nodecg-io-core/extension/persistenceManager";
22
import { EventEmitter } from "events";
3-
import { ObjectMap, ServiceInstance, ServiceDependency, Service } from "nodecg-io-core/extension/types";
3+
import { ObjectMap, ServiceInstance, ServiceDependency, Service } from "nodecg-io-core/extension/service";
44
import { isLoaded } from "./authentication";
55
import { PasswordMessage } from "nodecg-io-core/extension/messageManager";
66

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

nodecg-io-core/dashboard/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
"lib": ["ES2015", "dom"],
66
"module": "ES2015",
7-
"sourceMap": true
7+
"sourceMap": true,
8+
"declaration": false
89
},
910
"extends": "../../tsconfig.common.json"
1011
}

nodecg-io-core/dashboard/utils/selectUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ObjectMap } from "nodecg-io-core/extension/types";
1+
import { ObjectMap } from "nodecg-io-core/extension/service";
22

3-
export function updateOptionsMap(node: HTMLSelectElement, options: ObjectMap<string, unknown>): void {
3+
export function updateOptionsMap(node: HTMLSelectElement, options: ObjectMap<unknown>): void {
44
updateOptionsArr(node, Object.keys(options));
55
}
66

nodecg-io-core/extension/bundleManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NodeCG } from "nodecg/types/server";
2-
import { ObjectMap, Service, ServiceDependency, ServiceInstance } from "./types";
2+
import { ObjectMap, Service, ServiceDependency, ServiceInstance } from "./service";
33
import { emptySuccess, error, Result } from "./utils/result";
44
import { EventEmitter } from "events";
55
import { ServiceProvider } from "./serviceProvider";
@@ -8,17 +8,17 @@ import { ServiceProvider } from "./serviceProvider";
88
* Manages bundles and their dependencies on nodecg-io services.
99
*/
1010
export class BundleManager extends EventEmitter {
11-
private readonly bundles: ObjectMap<string, ServiceDependency<unknown>[]> = {};
11+
private readonly bundles: ObjectMap<ServiceDependency<unknown>[]> = {};
1212

1313
constructor(private readonly nodecg: NodeCG) {
1414
super();
1515
}
1616

1717
/**
1818
* Gets all bundle dependencies
19-
* @return {ObjectMap<string, ServiceDependency<unknown>[]>} all bundle dependencies
19+
* @return {ObjectMap<ServiceDependency<unknown>[]>} all bundle dependencies
2020
*/
21-
getBundleDependencies(): ObjectMap<string, ServiceDependency<unknown>[]> {
21+
getBundleDependencies(): ObjectMap<ServiceDependency<unknown>[]> {
2222
return this.bundles;
2323
}
2424

nodecg-io-core/extension/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ServiceManager } from "./serviceManager";
33
import { BundleManager } from "./bundleManager";
44
import { MessageManager } from "./messageManager";
55
import { InstanceManager } from "./instanceManager";
6-
import { Service } from "./types";
6+
import { Service } from "./service";
77
import { PersistenceManager } from "./persistenceManager";
88
import { ServiceProvider } from "./serviceProvider";
99

nodecg-io-core/extension/instanceManager.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NodeCG } from "nodecg/types/server";
2-
import { ObjectMap, Service, ServiceInstance } from "./types";
2+
import { ObjectMap, Service, ServiceInstance } from "./service";
33
import { emptySuccess, error, Result } from "./utils/result";
44
import { ServiceManager } from "./serviceManager";
55
import { BundleManager } from "./bundleManager";
@@ -10,7 +10,7 @@ import { EventEmitter } from "events";
1010
* Manages instances of services and their configs/clients.
1111
*/
1212
export class InstanceManager extends EventEmitter {
13-
private serviceInstances: ObjectMap<string, ServiceInstance<unknown, unknown>> = {};
13+
private serviceInstances: ObjectMap<ServiceInstance<unknown, unknown>> = {};
1414
private ajv = new Ajv();
1515

1616
constructor(
@@ -35,9 +35,9 @@ export class InstanceManager extends EventEmitter {
3535

3636
/**
3737
* Returns all existing service instances.
38-
* @return {ObjectMap<string, ServiceInstance<unknown, unknown>>} a map of the instance name to the instance.
38+
* @return {ObjectMap<ServiceInstance<unknown, unknown>>} a map of the instance name to the instance.
3939
*/
40-
getServiceInstances(): ObjectMap<string, ServiceInstance<unknown, unknown>> {
40+
getServiceInstances(): ObjectMap<ServiceInstance<unknown, unknown>> {
4141
return this.serviceInstances;
4242
}
4343

@@ -164,9 +164,12 @@ export class InstanceManager extends EventEmitter {
164164

165165
// We need to do validation, spawn a Promise
166166
return (async () => {
167-
const schemaValid = this.ajv.validate(service.result.schema, config);
168-
if (!schemaValid) {
169-
return error("Config invalid: " + this.ajv.errorsText());
167+
// If the service has a schema, check it.
168+
if (service.result.schema) {
169+
const schemaValid = this.ajv.validate(service.result.schema, config);
170+
if (!schemaValid) {
171+
return error("Config invalid: " + this.ajv.errorsText());
172+
}
170173
}
171174

172175
// Validation by the service.

nodecg-io-core/extension/persistenceManager.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { InstanceManager } from "./instanceManager";
33
import { BundleManager } from "./bundleManager";
44
import * as crypto from "crypto-js";
55
import { emptySuccess, error, Result, success } from "./utils/result";
6-
import { ObjectMap, ServiceDependency, ServiceInstance } from "./types";
6+
import { ObjectMap, ServiceDependency, ServiceInstance } from "./service";
77
import { ServiceManager } from "./serviceManager";
88

99
/**
@@ -13,11 +13,11 @@ export interface PersistentData {
1313
/**
1414
* All instance data that is held by the {@link InstanceManager}.
1515
*/
16-
instances: ObjectMap<string, ServiceInstance<unknown, unknown>>;
16+
instances: ObjectMap<ServiceInstance<unknown, unknown>>;
1717
/**
1818
* All bundle dependency data that is held by the {@link BundleManager}.
1919
*/
20-
bundleDependencies: ObjectMap<string, ServiceDependency<unknown>[]>;
20+
bundleDependencies: ObjectMap<ServiceDependency<unknown>[]>;
2121
}
2222

2323
/**
@@ -142,7 +142,7 @@ export class PersistenceManager {
142142
* and then setting the config of the passed object.
143143
* @param instances the service instances that should be loaded.
144144
*/
145-
private loadServiceInstances(instances: ObjectMap<string, ServiceInstance<unknown, unknown>>): Promise<void>[] {
145+
private loadServiceInstances(instances: ObjectMap<ServiceInstance<unknown, unknown>>): Promise<void>[] {
146146
return Object.keys(instances).map((instanceName) => {
147147
const inst = instances[instanceName];
148148
if (inst === undefined) {
@@ -188,7 +188,7 @@ export class PersistenceManager {
188188
* Loads all passed bundle dependencies into the framework by setting them in the bundle manager.
189189
* @param bundles the bundle dependencies that should be set.
190190
*/
191-
private loadBundleDependencies(bundles: ObjectMap<string, ServiceDependency<unknown>[]>): void {
191+
private loadBundleDependencies(bundles: ObjectMap<ServiceDependency<unknown>[]>): void {
192192
Object.keys(bundles).forEach((bundleName) => {
193193
if (!Object.prototype.hasOwnProperty.call(bundles, bundleName)) {
194194
return;
@@ -234,9 +234,9 @@ export class PersistenceManager {
234234
* Creates a copy of all service instances without the service clients, because those
235235
* shouldn't be serialized and don't need to be stored in the encrypted config file.
236236
*/
237-
private getServiceInstances(): ObjectMap<string, ServiceInstance<unknown, unknown>> {
237+
private getServiceInstances(): ObjectMap<ServiceInstance<unknown, unknown>> {
238238
const instances = this.instances.getServiceInstances();
239-
const copy: ObjectMap<string, ServiceInstance<unknown, unknown>> = {};
239+
const copy: ObjectMap<ServiceInstance<unknown, unknown>> = {};
240240

241241
for (const instName in instances) {
242242
if (!Object.prototype.hasOwnProperty.call(instances, instName)) {

nodecg-io-core/extension/types.d.ts renamed to nodecg-io-core/extension/service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Holds generic types for the whole project
1+
// Holds types/interfaces related to services
22

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

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

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

5757
/**
5858
* Stops a client of this service that is not needed anymore.
5959
* Services should close any connections that might exist here.
6060
*
6161
* @param client the client that needs to be stopped.
6262
*/
63-
readonly stopClient(client: C): void;
63+
stopClient(client: C): void;
6464

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

7777
/**
7878
* This flag can be enabled by services if they can't implement {@link removeHandlers} but also have some handlers that

nodecg-io-core/extension/serviceBundle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NodeCGIOCore } from ".";
22
import { NodeCG } from "nodecg/types/server";
3-
import { Service } from "./types";
3+
import { ObjectMap, Service } from "./service";
44
import { Result } from "./utils/result";
55

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

2323
/**
2424
* The default value for the config.
@@ -107,7 +107,7 @@ export abstract class ServiceBundle<R, C> implements Service<R, C> {
107107
*/
108108
requiresNoConfig = false;
109109

110-
private readSchema(pathSegments: string[]): unknown {
110+
private readSchema(pathSegments: string[]): ObjectMap<unknown> | undefined {
111111
const joinedPath = path.resolve(...pathSegments);
112112
try {
113113
const fileContent = fs.readFileSync(joinedPath, "utf8");

nodecg-io-core/extension/serviceManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Service } from "./types";
1+
import { Service } from "./service";
22
import { NodeCG } from "nodecg/types/server";
33
import { error, Result, success } from "./utils/result";
44

0 commit comments

Comments
 (0)