1
0
Fork 0

lint: type naming for new rules

This commit is contained in:
ssube 2020-07-29 08:22:32 -05:00 committed by Sean Sube
parent 8db6b436c7
commit 131c9bf530
7 changed files with 29 additions and 18 deletions

View File

@ -106,6 +106,15 @@
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid"
},
{
"selector": "enumMember",
"format": [
"camelCase",
"UPPER_CASE"
],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid"
},
{
"selector": "typeLike",
"format": [
@ -120,10 +129,7 @@
"PascalCase"
],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid",
"prefix": [
"I"
]
"trailingUnderscore": "forbid"
}
],
"@typescript-eslint/no-empty-function": "error",

View File

@ -9,14 +9,14 @@ Get the constructor name from an instance.
<b>Signature:</b>
```typescript
export declare function constructorName(val: object): string;
export declare function constructorName(val: Reflectable): string;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| val | object | |
| val | Reflectable | |
<b>Returns:</b>

View File

@ -9,14 +9,14 @@ Get the constructor from an instance.
<b>Signature:</b>
```typescript
export declare function getConstructor(val: object): Function;
export declare function getConstructor(val: Reflectable): Function;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| val | object | |
| val | Reflectable | |
<b>Returns:</b>

View File

@ -9,7 +9,7 @@ Get the methods from an instance and its prototypes.
<b>Signature:</b>
```typescript
export declare function getMethods<TValue extends object>(value: TValue): Set<Function>;
export declare function getMethods<TValue extends Reflectable>(value: TValue): Set<Method<TValue>>;
```
## Parameters
@ -20,5 +20,5 @@ export declare function getMethods<TValue extends object>(value: TValue): Set<Fu
<b>Returns:</b>
Set&lt;Function&gt;
Set&lt;Method&lt;TValue&gt;&gt;

View File

@ -9,7 +9,7 @@ Reject after a set amount of time if the original promise has not yet resolved.
<b>Signature:</b>
```typescript
export declare function timeout<T>(ms: number, oper: Promise<T>): Promise<Optional<T>>;
export declare function timeout<T>(ms: number, oper: Promise<T>): Promise<T>;
```
## Parameters
@ -21,5 +21,5 @@ export declare function timeout<T>(ms: number, oper: Promise<T>): Promise<Option
<b>Returns:</b>
Promise&lt;[Optional](./js-utils.optional.md)<!-- -->&lt;T&gt;&gt;
Promise&lt;T&gt;

View File

@ -2,12 +2,17 @@ import { isFunction } from 'lodash';
import { doesExist, isNil } from './Maybe';
/* eslint-disable-next-line @typescript-eslint/ban-types */
type Reflectable = object;
type Method<TClass> = (this: TClass, ...args: Array<unknown>) => unknown;
/**
* Get the constructor from an instance.
*
* @public
*/
export function getConstructor(val: object) {
export function getConstructor(val: Reflectable) {
return val.constructor;
}
@ -16,8 +21,8 @@ export function getConstructor(val: object) {
*
* @public
*/
export function getMethods<TValue extends object>(value: TValue): Set<Function> {
const methods = new Set<Function>();
export function getMethods<TValue extends Reflectable>(value: TValue): Set<Method<TValue>> {
const methods = new Set<Method<TValue>>();
for (const name of Object.getOwnPropertyNames(value)) {
const desc = Object.getOwnPropertyDescriptor(value, name);
@ -46,6 +51,6 @@ export function getMethods<TValue extends object>(value: TValue): Set<Function>
*
* @public
*/
export function constructorName(val: object) {
export function constructorName(val: Reflectable) {
return getConstructor(Reflect.getPrototypeOf(val)).name;
}

View File

@ -3,7 +3,7 @@ export const SIGNAL_RESET: NodeJS.Signals = 'SIGINT';
export const SIGNAL_STOP: NodeJS.Signals = 'SIGTERM';
export function signal(...signals: Array<NodeJS.Signals>): Promise<NodeJS.Signals> {
return new Promise((res, _) => {
return new Promise((res, rej) => {
function handler(fired: NodeJS.Signals) {
for (const s of signals) {
process.removeListener(s, handler);