Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
izatop committed Oct 29, 2021
1 parent 9618363 commit a0ef06d
Show file tree
Hide file tree
Showing 50 changed files with 109 additions and 102 deletions.
2 changes: 1 addition & 1 deletion packages/app/src/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Application<C extends Context> {

public add(route: IRoute<ActionAny<C>>): this {
this.logger.debug("add", route);
assert(!this.#unit.has(route.action), `This route was already added`);
assert(!this.#unit.has(route.action), "This route was already added");
this.#unit.add(route.action);
this.#routes.push(route);
return this;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/Payload/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export type ResolverList<A extends ActionAny> = {
};

export type ResolverResolvers<A extends ActionAny> = ResolverFn<A>
| ResolverList<A>;
| ResolverList<A>;
2 changes: 1 addition & 1 deletion packages/app/src/Request/HeadersAbstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {HeaderAssertValue, IHeaders} from "../interfaces";
import {StrictKeyValueMap} from "./StrictKeyValueMap";

export abstract class HeadersAbstract extends StrictKeyValueMap
implements IHeaders, ILogable<{ [key: string]: string }> {
implements IHeaders, ILogable<{[key: string]: string}> {

public assert(header: string, expected: HeaderAssertValue): void {
const clientValue = this.get(header.toLowerCase());
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/Request/KeyValueMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export class KeyValueMap implements IKeyValueMap {
return this.#map.get(name) || defaultValue || "";
}

public toJSON(): { [p: string]: string } {
const object: { [p: string]: string } = {};
public toJSON(): {[p: string]: string} {
const object: {[p: string]: string} = {};
for (const [key, value] of this.#map.entries()) {
object[key] = value;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/Request/RequestAbstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Application} from "../Application";
import {IHeaders, IRequest, IRequestTransform, RequestTransformType} from "../interfaces";
import {fromJsonRequest, fromTextRequest} from "../TransformRequest";

export abstract class RequestAbstract implements IRequest, ILogable<{ route: string }> {
export abstract class RequestAbstract implements IRequest, ILogable<{route: string}> {
public abstract readonly route: string;
public abstract readonly headers: IHeaders;

Expand Down Expand Up @@ -61,7 +61,7 @@ export abstract class RequestAbstract implements IRequest, ILogable<{ route: str

public abstract createReadableStream(): Promisify<NodeJS.ReadableStream>;

public getLogValue(): { route: string } {
public getLogValue(): {route: string} {
return {route: this.route};
}
}
2 changes: 1 addition & 1 deletion packages/app/src/Route/Matcher/EqualMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class EqualMatcher implements IRouteMatcher {
return new EqualMatcher(route);
};

public match(route: string): { route: string } {
public match(route: string): {route: string} {
return {route};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/Route/Route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Ctor, ILogable, isFunction, isString} from "@bunt/util";
import {IRoute, IRouteMatcher, RouteFactory, RouteMatcherFactory, RouteRuleArg, RouteRuleVariants} from "./interfaces";
import {RouteRule} from "./RouteRule";

export class Route<A extends ActionAny> implements IRoute<A>, ILogable<{ route: string }> {
export class Route<A extends ActionAny> implements IRoute<A>, ILogable<{route: string}> {
public readonly route: string;
public readonly action: Ctor<A>;
public readonly payload?: RouteRule<A>;
Expand All @@ -24,7 +24,7 @@ export class Route<A extends ActionAny> implements IRoute<A>, ILogable<{ route:
);
}

public getLogValue(): { route: string } {
public getLogValue(): {route: string} {
return {route: this.route};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/Route/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export interface IRoute<A extends ActionAny> {

export type RouteMatcherFactory = IRouteMatcher | ((route: string) => IRouteMatcher);

export type RouteRuleVariants<A extends ActionAny> = { route: string, payload: undefined }
| { route: string, payload: RouteRule<A> };
export type RouteRuleVariants<A extends ActionAny> = {route: string; payload: undefined}
| {route: string; payload: RouteRule<A>};

export type RouteRuleArg<A extends ActionAny> = ActionState<A> extends null
? string : RouteRule<A>;
Expand Down
28 changes: 14 additions & 14 deletions packages/app/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import {Promisify} from "@bunt/util";
import {Application} from "./Application";

export type ActionResponse = Error
| { stringify(): string }
| NodeJS.ReadableStream
| Buffer
| string
| number
| boolean
| null
| undefined
| void
| any;
| {stringify(): string}
| NodeJS.ReadableStream
| Buffer
| string
| number
| boolean
| null
| undefined
| void
| any;

export interface IKeyValueMap {
has(name: string): boolean;
Expand All @@ -24,7 +24,7 @@ export interface IKeyValueMap {

entries(): [string, string][];

toJSON(): { [key: string]: string };
toJSON(): {[key: string]: string};
}

export interface IRequestBodyTransform<T> {
Expand Down Expand Up @@ -59,9 +59,9 @@ export interface IRequest {
}

export type HeaderAssertValue = |
string |
string[] |
((value: string) => boolean | void);
string |
string[] |
((value: string) => boolean | void);

export interface IHeaders extends IKeyValueMap {
assert(header: string, values: HeaderAssertValue): void;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/test/src/app/Action/BaseTestAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Action} from "@bunt/unit";
import {BaseContext} from "../Context/BaseContext";

export class BaseTestAction extends Action<BaseContext, { name: string }> {
export class BaseTestAction extends Action<BaseContext, {name: string}> {
public run(): string {
return `Hello, ${this.state.name}!`;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/app/test/src/app/Request/Request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Request extends RequestAbstract {
public readonly route: string;
public readonly body: string;

constructor(route: string, headers: { [key: string]: string }, body = "") {
constructor(route: string, headers: {[key: string]: string}, body = "") {
super();
this.route = route;
this.headers = new Headers(Object.entries(headers));
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/Request/RequestCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class RequestCommand extends RequestAbstract {
constructor(args: Argv) {
super();
const [command] = args.getArgs();
assert(command, `Command should be defined`);
assert(command, "Command should be defined");

this.route = command;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/src/app/Action/BaseTestCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Heartbeat, IDisposable, IRunnable} from "@bunt/unit";
import {Command} from "../../../../src";
import {BaseContext} from "../Context/BaseContext";

export class BaseTestCommand extends Command<BaseContext, { name?: string }> {
export class BaseTestCommand extends Command<BaseContext, {name?: string}> {
public run(): void | Result {
if (this.state.name) {
return new Result(this.state.name);
Expand Down
2 changes: 1 addition & 1 deletion packages/fs/src/Storage/Driver/MinIOBucketPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export enum MinIOBucketPolicyEnum {
}

export class MinIOBucketPolicy {
readonly #policies = new Map<MinIOBucketPolicyEnum, (bucket: string) => string>();
readonly #policies = new Map<MinIOBucketPolicyEnum,(bucket: string) => string>();

public constructor() {
this.#policies.set(MinIOBucketPolicyEnum.READONLY, this.publicReadOnlyPolicy);
Expand Down
8 changes: 4 additions & 4 deletions packages/input/src/Assertion/AssertionObjectError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import {TypeAbstract} from "../TypeAbstract";
import {AssertionTypeError, IReadableTypeError} from "./AssertionTypeError";

export interface IReadableObjectError extends IReadableTypeError {
fields: Record<string, IReadableTypeError>
fields: Record<string, IReadableTypeError>;
}

export class AssertionObjectError extends AssertionTypeError {
readonly #fields: Record<string, any>;

constructor(message: string,
type: TypeAbstract<any>,
payload: unknown,
fields: Record<string, IReadableTypeError>) {
type: TypeAbstract<any>,
payload: unknown,
fields: Record<string, IReadableTypeError>) {
super(message, type, payload);
this.#fields = fields;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/input/src/Type/Enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {TypeAbstract} from "../TypeAbstract";
export class Enum<T extends string | number> extends TypeAbstract<T> {
readonly #value: any;

constructor(value: { [key: string]: T }) {
constructor(value: {[key: string]: T}) {
super();
this.#value = value;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/input/src/Type/ToNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ScalarType} from "./ScalarType";
export const ToNumber = new ScalarType<number>({
name: "Int",
validate(payload) {
this.assert(isNumber(payload) || isString(payload), `Wrong payload type`, payload);
this.assert(isNumber(payload) || isString(payload), "Wrong payload type", payload);

return Int.validate(+payload);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/input/test/src/Main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("Test Input", () => {
[false, false, union],
["2020-01-01", new Date("2020-01-01"), union],
[new Date("2020-01-01").getTime(), new Date("2020-01-01"), union],
[`{"foo": "bar"}`, {foo: "bar"}, JSONString],
["{\"foo\": \"bar\"}", {foo: "bar"}, JSONString],
["true", true, JSONString],
["1", 1, JSONString],
["[1]", [1], JSONString],
Expand Down
2 changes: 1 addition & 1 deletion packages/input/test/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface ITestDescription {
}

export interface ITestHobby {
type: string,
type: string;
description?: ITestDescription;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/queue/src/PubSub/Subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ class SubscriptionGenerator<T, TNext = unknown> implements AsyncGenerator<T, und
}

class Defer<T> extends Promise<T> {
#resolve = (value: T | PromiseLike<T>) => {
#resolve = (_value: T | PromiseLike<T>) => {
// noop
};

#reject = (error: Error) => {
#reject = (_error: Error) => {
// noop
};

Expand Down
1 change: 1 addition & 0 deletions packages/queue/src/Queue/fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function tryUnserialize<T = unknown>(message?: string): T | undefined {
return unserialize(message);
} catch (error) {
// skip serialization error
// eslint-disable-next-line
console.warn(error);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/queue/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type HandlerReturn<M extends Message> = M extends TaskAbstract<any, infer
? Promisify<R>
: Promisify<void>;

export type HandlerState<M extends Message> = { payload: MessagePayload<M> };
export type HandlerState<M extends Message> = {payload: MessagePayload<M>};

export interface ITransport extends IDisposable {
send<M extends Message>(message: M): Promisify<void>;
Expand Down
4 changes: 2 additions & 2 deletions packages/unit/src/Runtime/EnvReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ export type EnvRecord = Record<string, string>;
export class EnvReader<T extends EnvRecord> {
readonly #map: Map<keyof T | string, string>;

constructor(config: { [key: string]: string | undefined }) {
constructor(config: {[key: string]: string | undefined}) {
this.#map = new Map(
Object.entries(config)
.map<[keyof T | string, string]>(([k, v]) => [k, v || ""]),
);
}

public static from<T extends EnvRecord>(target: Partial<T>,
...envs: Record<string, string | undefined>[]): EnvReader<T> {
...envs: Record<string, string | undefined>[]): EnvReader<T> {
for (const next of envs) {
Object.assign(target, next);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/unit/src/Unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Unit<C extends Context> {
return this.getContext(await context());
}

assert(isInstanceOf(context, Context), `Wrong context type`);
assert(isInstanceOf(context, Context), "Wrong context type");
return Context.apply(await context);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/unit/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export type ActionCtor<C extends Context,
S extends StateType | null = any,
R = unknown,
A extends Action<C, S, R> = Action<C, S, R>> = {
new(context: ApplyContext<C>, state: S): A;
new(context: ApplyContext<C>, state: S): A;

prototype: A;
};
prototype: A;
};

export type ActionContext<A> = A extends ActionAny<infer T> ? T : never;
export type ActionState<A> = A extends ActionAny<any, infer T> ? T : never;
Expand Down
2 changes: 1 addition & 1 deletion packages/unit/test/src/actions/AsyncServiceTestAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Action} from "../../../src";
import {MainContext} from "../context/MainContext";

export class AsyncServiceTestAction extends Action<MainContext, { key: string }> {
export class AsyncServiceTestAction extends Action<MainContext, {key: string}> {
public async run(): Promise<string> {
const {key} = this.state;
const {memoryDb, randomBytes} = this.context;
Expand Down
2 changes: 1 addition & 1 deletion packages/unit/test/src/actions/BaseTestAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Action} from "../../../src";
import {BaseContext} from "../context/BaseContext";

export class BaseTestAction extends Action<BaseContext, { name: string }> {
export class BaseTestAction extends Action<BaseContext, {name: string}> {
public run(): string {
return `Hello, ${this.state.name}!`;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/unit/test/src/actions/TestExceptionAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {assert} from "@bunt/util";
import {Action} from "../../../src";
import {BaseContext} from "../context/BaseContext";

export class TestExceptionAction extends Action<BaseContext, { error: string }> {
export class TestExceptionAction extends Action<BaseContext, {error: string}> {
public run(): void {
assert(false, this.state.error);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/util/src/Date/DateTimeMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class DateTimeMutation {
}

protected static apply(map: Map<DateTimeKind, TimeMutateFn>,
time: number,
values: [DateTimeKind, number][]): number {
time: number,
values: [DateTimeKind, number][]): number {
for (const [interval, value] of values) {
const fn = map.get(interval);
assert(isFunction(fn));
Expand Down
16 changes: 8 additions & 8 deletions packages/util/src/Logger/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ export interface ILogger {

export type LoggerOwner = Record<any, any> | ILogger | Func;
export type LogableType = string
| Record<any, any>
| number
| bigint
| null
| undefined
| boolean
| Date
| unknown;
| Record<any, any>
| number
| bigint
| null
| undefined
| boolean
| Date
| unknown;

export interface ILogable<T extends LogableType> {
getLogValue(): T;
Expand Down
6 changes: 3 additions & 3 deletions packages/util/src/Node/Program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export class Program {
this.args = new Argv(argv || process.argv.slice(2));
}

public get stdin(): NodeJS.ReadStream & { fd: 0 } {
public get stdin(): NodeJS.ReadStream & {fd: 0} {
return process.stdin;
}

public get stdout(): NodeJS.WriteStream & { fd: 1 } {
public get stdout(): NodeJS.WriteStream & {fd: 1} {
return process.stdout;
}

public get stderr(): NodeJS.WriteStream & { fd: 2 } {
public get stderr(): NodeJS.WriteStream & {fd: 2} {
return process.stderr;
}
}
Loading

0 comments on commit a0ef06d

Please sign in to comment.