From d6f4142475f980939d400eff791c9066c1580d3d Mon Sep 17 00:00:00 2001 From: Thijs Vermeir Date: Sun, 29 Oct 2023 09:19:03 +0100 Subject: [PATCH 1/3] chore: remove unnecessary casting --- src/commands/generate/models.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/generate/models.ts b/src/commands/generate/models.ts index e75a0e1de23..79724ca57e3 100644 --- a/src/commands/generate/models.ts +++ b/src/commands/generate/models.ts @@ -322,7 +322,7 @@ export default class Models extends Command { const models = await fileGenerator.generateToFiles( convertedDoc as any, output, - { ...fileOptions, } as any); + { ...fileOptions, }); const generatedModels = models.map((model) => { return model.modelName; }); this.log(`Successfully generated the following models: ${generatedModels.join(', ')}`); return; @@ -330,7 +330,7 @@ export default class Models extends Command { const models = await fileGenerator.generateCompleteModels( convertedDoc as any, - { ...fileOptions } as any); + { ...fileOptions }); const generatedModels = models.map((model) => { return ` ## Model name: ${model.modelName} From 5d7ab9d765769625512fcf49268b76d6c8615cf6 Mon Sep 17 00:00:00 2001 From: Thijs Vermeir Date: Sun, 29 Oct 2023 09:21:40 +0100 Subject: [PATCH 2/3] chore: prefer nullish coalescing operator --- src/flags.ts | 2 +- src/globals.ts | 2 +- src/models/SpecificationFile.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flags.ts b/src/flags.ts index 122bc50b577..9ca21cff9f5 100644 --- a/src/flags.ts +++ b/src/flags.ts @@ -4,6 +4,6 @@ export const watchFlag = (description?: string) => { return Flags.boolean({ default: false, char: 'w', - description: description || 'Enable watch mode', + description: description ?? 'Enable watch mode', }); }; diff --git a/src/globals.ts b/src/globals.ts index b0d5d6113df..47c5acd910f 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -27,7 +27,7 @@ export type SpecWatcherParams = { export const specWatcher = (params: SpecWatcherParams) => { if (!params.spec.getFilePath()) { return WATCH_MESSAGES.logOnAutoDisable(params.docVersion); } - if (CHOKIDAR_INSTANCE_STORE.get(params.label || '_default')) { return; } + if (CHOKIDAR_INSTANCE_STORE.get(params.label ?? '_default')) { return; } const filePath = params.spec.getFilePath() as string; try { diff --git a/src/models/SpecificationFile.ts b/src/models/SpecificationFile.ts index 4d4fe917bf0..e1c55899266 100644 --- a/src/models/SpecificationFile.ts +++ b/src/models/SpecificationFile.ts @@ -64,7 +64,7 @@ export class Specification { } getSource() { - return this.getFilePath() || this.getFileURL(); + return this.getFilePath() ?? this.getFileURL(); } toSourceString() { From 274149098f855deb729e17d6179dc2013f24b3d7 Mon Sep 17 00:00:00 2001 From: Thijs Vermeir Date: Sun, 29 Oct 2023 09:23:29 +0100 Subject: [PATCH 3/3] chore: avoid duplicate import --- src/hooks/command_not_found/myhook.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hooks/command_not_found/myhook.ts b/src/hooks/command_not_found/myhook.ts index ef2698c94b9..c99537fc557 100644 --- a/src/hooks/command_not_found/myhook.ts +++ b/src/hooks/command_not_found/myhook.ts @@ -1,7 +1,6 @@ -import {Hook, toConfiguredId, CliUx} from '@oclif/core'; +import {Help, Hook, toConfiguredId, CliUx} from '@oclif/core'; import chalk from 'chalk'; import {default as levenshtein} from 'fast-levenshtein'; -import { Help } from '@oclif/core'; export const closest = (target: string, possibilities: string[]): string => possibilities