Skip to content

Commit 0a857ed

Browse files
committed
πŸ› fix: lint
1 parent 296e1ff commit 0a857ed

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

β€Žpackages/core/src/cli.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,30 @@ export class Clerc<C extends Commands = {}> {
7676
},
7777
};
7878

79-
private constructor(name?: string, description?: string, version?: string) {
79+
private constructor (name?: string, description?: string, version?: string) {
8080
this.#name = name || this.#name;
8181
this.#description = description || this.#description;
8282
this.#version = version || this.#version;
8383
this.#locale = detectLocale();
8484
this.#addCoreLocales();
8585
}
8686

87-
get #hasRootOrAlias() {
87+
get #hasRootOrAlias () {
8888
return this.#usedNames.has(Root);
8989
}
9090

91-
get #hasRoot() {
91+
get #hasRoot () {
9292
return Object.prototype.hasOwnProperty.call(this._commands, Root);
9393
}
9494

95-
get _name() { return this.#name; }
96-
get _description() { return this.#description; }
97-
get _version() { return this.#version; }
98-
get _inspectors() { return this.#inspectors; }
99-
get _commands() { return this.#commands; }
95+
get _name () { return this.#name; }
96+
get _description () { return this.#description; }
97+
get _version () { return this.#version; }
98+
get _inspectors () { return this.#inspectors; }
99+
get _commands () { return this.#commands; }
100100

101-
#addCoreLocales() { this.i18n.add(locales); }
102-
#otherMethodCaled() { this.#isOtherMethodCalled = true; }
101+
#addCoreLocales () { this.i18n.add(locales); }
102+
#otherMethodCaled () { this.#isOtherMethodCalled = true; }
103103

104104
/**
105105
* Create a new cli
@@ -109,7 +109,7 @@ export class Clerc<C extends Commands = {}> {
109109
* const cli = Clerc.create()
110110
* ```
111111
*/
112-
static create(name?: string, description?: string, version?: string) {
112+
static create (name?: string, description?: string, version?: string) {
113113
return new Clerc(name, description, version);
114114
}
115115

@@ -123,7 +123,7 @@ export class Clerc<C extends Commands = {}> {
123123
* .name("test")
124124
* ```
125125
*/
126-
name(name: string) {
126+
name (name: string) {
127127
this.#otherMethodCaled();
128128
this.#name = name;
129129
return this;
@@ -139,7 +139,7 @@ export class Clerc<C extends Commands = {}> {
139139
* .description("test cli")
140140
* ```
141141
*/
142-
description(description: string) {
142+
description (description: string) {
143143
this.#otherMethodCaled();
144144
this.#description = description;
145145
return this;
@@ -155,7 +155,7 @@ export class Clerc<C extends Commands = {}> {
155155
* .version("1.0.0")
156156
* ```
157157
*/
158-
version(version: string) {
158+
version (version: string) {
159159
this.#otherMethodCaled();
160160
this.#version = version;
161161
return this;
@@ -173,7 +173,7 @@ export class Clerc<C extends Commands = {}> {
173173
* .command(...)
174174
* ```
175175
*/
176-
locale(locale: string) {
176+
locale (locale: string) {
177177
if (this.#isOtherMethodCalled) { throw new LocaleNotCalledFirstError(this.i18n.t); }
178178
this.#locale = locale;
179179
return this;
@@ -191,7 +191,7 @@ export class Clerc<C extends Commands = {}> {
191191
* .command(...)
192192
* ```
193193
*/
194-
fallbackLocale(fallbackLocale: string) {
194+
fallbackLocale (fallbackLocale: string) {
195195
if (this.#isOtherMethodCalled) { throw new LocaleNotCalledFirstError(this.i18n.t); }
196196
this.#defaultLocale = fallbackLocale;
197197
return this;
@@ -207,7 +207,7 @@ export class Clerc<C extends Commands = {}> {
207207
* .errorHandler((err) => { console.log(err); })
208208
* ```
209209
*/
210-
errorHandler(handler: (err: any) => void) {
210+
errorHandler (handler: (err: any) => void) {
211211
this.#errorHandlers.push(handler);
212212
return this;
213213
}
@@ -246,12 +246,12 @@ export class Clerc<C extends Commands = {}> {
246246
*/
247247
command<N extends string | RootType, O extends CommandOptions<[...P], A, F>, P extends string[] = string[], A extends MaybeArray<string | RootType> = MaybeArray<string | RootType>, F extends Flags = Flags>(c: CommandWithHandler<N, O & CommandOptions<[...P], A, F>>): this & Clerc<C & Record<N, Command<N, O>>>;
248248
command<N extends string | RootType, O extends CommandOptions<[...P], A, F>, P extends string[] = string[], A extends MaybeArray<string | RootType> = MaybeArray<string | RootType>, F extends Flags = Flags>(name: N, description: string, options?: O & CommandOptions<[...P], A, F>): this & Clerc<C & Record<N, Command<N, O>>>;
249-
command(nameOrCommand: any, description?: any, options: any = {}) {
249+
command (nameOrCommand: any, description?: any, options: any = {}) {
250250
this.#callWithErrorHandling(() => this.#command(nameOrCommand, description, options));
251251
return this;
252252
}
253253

254-
#command(nameOrCommand: any, description?: any, options: any = {}) {
254+
#command (nameOrCommand: any, description?: any, options: any = {}) {
255255
this.#otherMethodCaled();
256256
const { t } = this.i18n;
257257
const checkIsCommandObject = (nameOrCommand: any): nameOrCommand is CommandWithHandler => !(typeof nameOrCommand === "string" || nameOrCommand === Root);
@@ -329,7 +329,7 @@ export class Clerc<C extends Commands = {}> {
329329
* })
330330
* ```
331331
*/
332-
inspector(inspector: Inspector) {
332+
inspector (inspector: Inspector) {
333333
this.#otherMethodCaled();
334334
this.#inspectors.push(inspector);
335335
return this;
@@ -345,7 +345,7 @@ export class Clerc<C extends Commands = {}> {
345345
* .parse(process.argv.slice(2)) // Optional
346346
* ```
347347
*/
348-
parse(optionsOrArgv: string[] | ParseOptions = resolveArgv()) {
348+
parse (optionsOrArgv: string[] | ParseOptions = resolveArgv()) {
349349
this.#otherMethodCaled();
350350
const { argv, run }: ParseOptions = Array.isArray(optionsOrArgv)
351351
? {
@@ -364,7 +364,7 @@ export class Clerc<C extends Commands = {}> {
364364
return this;
365365
}
366366

367-
#validateMeta() {
367+
#validateMeta () {
368368
const { t } = this.i18n;
369369
if (!this.#name) {
370370
throw new NameNotSetError(t);
@@ -377,7 +377,7 @@ export class Clerc<C extends Commands = {}> {
377377
}
378378
}
379379

380-
#getContext(getCommand: () => ReturnType<typeof resolveCommand>) {
380+
#getContext (getCommand: () => ReturnType<typeof resolveCommand>) {
381381
const argv = this.#argv!;
382382
const { t } = this.i18n;
383383
const [command, called] = getCommand();
@@ -433,7 +433,7 @@ export class Clerc<C extends Commands = {}> {
433433
return context;
434434
}
435435

436-
#callWithErrorHandling(fn: () => void) {
436+
#callWithErrorHandling (fn: () => void) {
437437
try {
438438
fn();
439439
} catch (e) {
@@ -445,7 +445,7 @@ export class Clerc<C extends Commands = {}> {
445445
}
446446
}
447447

448-
#runMatchedCommand() {
448+
#runMatchedCommand () {
449449
this.#otherMethodCaled();
450450
const { t } = this.i18n;
451451
const argv = this.#argv;
@@ -485,7 +485,7 @@ export class Clerc<C extends Commands = {}> {
485485
* .runMatchedCommand()
486486
* ```
487487
*/
488-
runMatchedCommand() {
488+
runMatchedCommand () {
489489
this.#callWithErrorHandling(() => this.#runMatchedCommand());
490490
process.title = this.#name;
491491
return this;

β€Žpackages/core/src/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Root } from "./cli";
77
import type { Command, CommandAlias, CommandType, Commands, Inspector, InspectorContext, InspectorFn, InspectorObject, TranslateFn } from "./types";
88
import { CommandNameConflictError } from "./errors";
99

10-
function setCommand(commandsMap: Map<string[] | RootType, CommandAlias>, commands: Commands, command: Command, t: TranslateFn) {
10+
function setCommand (commandsMap: Map<string[] | RootType, CommandAlias>, commands: Commands, command: Command, t: TranslateFn) {
1111
if (command.alias) {
1212
const aliases = toArray(command.alias);
1313
for (const alias of aliases) {
@@ -19,7 +19,7 @@ function setCommand(commandsMap: Map<string[] | RootType, CommandAlias>, command
1919
}
2020
}
2121

22-
export function resolveFlattenCommands(commands: Commands, t: TranslateFn) {
22+
export function resolveFlattenCommands (commands: Commands, t: TranslateFn) {
2323
const commandsMap = new Map<string[] | RootType, CommandAlias>();
2424
if (commands[Root]) {
2525
commandsMap.set(Root, commands[Root]);
@@ -32,7 +32,7 @@ export function resolveFlattenCommands(commands: Commands, t: TranslateFn) {
3232
return commandsMap;
3333
}
3434

35-
export function resolveCommand(commands: Commands, argv: string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined] {
35+
export function resolveCommand (commands: Commands, argv: string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined] {
3636
const commandsMap = resolveFlattenCommands(commands, t);
3737
for (const [name, command] of commandsMap.entries()) {
3838
const parsed = typeFlag(command?.flags || {}, [...argv]);
@@ -48,7 +48,7 @@ export function resolveCommand(commands: Commands, argv: string[], t: TranslateF
4848
return [undefined, undefined];
4949
}
5050

51-
export function resolveCommandStrict(commands: Commands, name: CommandType | string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined] {
51+
export function resolveCommandStrict (commands: Commands, name: CommandType | string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined] {
5252
if (name === Root) { return [commands[Root], Root]; }
5353
const nameArr = toArray(name) as string[];
5454
const commandsMap = resolveFlattenCommands(commands, t);
@@ -66,7 +66,7 @@ export function resolveCommandStrict(commands: Commands, name: CommandType | str
6666
return [current, currentName];
6767
}
6868

69-
export function resolveSubcommandsByParent(commands: Commands, parent: string | string[], depth = Infinity) {
69+
export function resolveSubcommandsByParent (commands: Commands, parent: string | string[], depth = Infinity) {
7070
const parentArr = parent === ""
7171
? []
7272
: Array.isArray(parent)
@@ -89,7 +89,7 @@ export const resolveArgv = (): string[] =>
8989
? Deno.args
9090
: [];
9191

92-
export function compose(inspectors: Inspector[]) {
92+
export function compose (inspectors: Inspector[]) {
9393
const inspectorMap = {
9494
pre: [] as InspectorFn[],
9595
normal: [] as InspectorFn[],

0 commit comments

Comments
Β (0)