Repository navigation
[AI Improvement] [Task] Fix no-floating-promises in CLI command helpers (open, trackGA4, throttler, cloudbilling) #11467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,8 +25,8 @@ | |
| load: () => void; | ||
| } | ||
|
|
||
| export function isCommandModule(value: unknown): value is CommandModule { | ||
| return typeof value === "function" && typeof (value as any).load === "function"; | ||
|
Check warning on line 29 in src/command.ts
|
||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
|
|
@@ -41,7 +41,7 @@ | |
| export interface CLIClient { | ||
| cli: CommanderStatic; | ||
| errorOut: (e: Error) => void; | ||
| [key: string]: any; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -81,7 +81,7 @@ | |
|
|
||
| /** | ||
| * Sets an alias for a command. | ||
| * @param aliases an alternativre name for the command. Users will be able to call the command via this name. | ||
|
Check warning on line 84 in src/command.ts
|
||
| * @return the command, for chaining. | ||
| */ | ||
| alias(alias: string): Command { | ||
|
|
@@ -90,10 +90,10 @@ | |
| } | ||
|
|
||
| /** | ||
| * Sets any options for the command. | ||
| * | ||
| * @example | ||
| * command.option("-d, --debug", "turn on debugging", false) | ||
| * | ||
| * @param args the commander-style option definition. | ||
| * @return the command, for chaining. | ||
|
|
@@ -105,10 +105,10 @@ | |
| } | ||
|
|
||
| /** | ||
| * Sets up --force flag for the command. | ||
| * | ||
| * @param message overrides the description for --force for this command | ||
| * @returns the command, for chaining | ||
| */ | ||
| withForce(message?: string): Command { | ||
| this.options.push(["-f, --force", message || "automatically accept all interactive prompts"]); | ||
|
|
@@ -132,7 +132,7 @@ | |
| * | ||
| * This text is displayed when: | ||
| * - the `--help` flag is passed to the command, or | ||
| * - the `help <command>` command is used. | ||
| * | ||
| * @param t the human-readable help text. | ||
| * @return the command, for chaining. | ||
|
|
@@ -516,7 +516,7 @@ | |
| if (PROJECT_ID_REGEX.test(project)) { | ||
| return; | ||
| } | ||
| trackGA4("error", { | ||
| void trackGA4("error", { | ||
| error_type: "Error (User)", | ||
| details: "Invalid project ID", | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||||||||
| import * as clc from "colorette"; | ||||||||||||||
| import * as open from "open"; | ||||||||||||||
|
|
||||||||||||||
| import { FirebaseError } from "../error"; | ||||||||||||||
| import { FirebaseError, getErrMsg } from "../error"; | ||||||||||||||
| import * as api from "../api"; | ||||||||||||||
| import { Command } from "../command"; | ||||||||||||||
| import { logger } from "../logger"; | ||||||||||||||
|
|
@@ -114,5 +114,7 @@ export const command = new Command("open [link]") | |||||||||||||
| logger.info(`Opening ${clc.bold(link.name)} link in your default browser:`); | ||||||||||||||
| logger.info(clc.bold(clc.underline(url))); | ||||||||||||||
|
|
||||||||||||||
| open(url); | ||||||||||||||
| open(url).catch((err: unknown) => { | ||||||||||||||
| logger.debug(`Unable to open URL: ${getErrMsg(err)}`); | ||||||||||||||
| }); | ||||||||||||||
|
Comment on lines
+117
to
+119
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of calling You can also remove the unused
Suggested change
References
|
||||||||||||||
| }); | ||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -148,7 +148,7 @@ async function openBillingAccount( | |||||
| ): Promise<boolean> { | ||||||
| if (open) { | ||||||
| try { | ||||||
| opn(url); | ||||||
| await opn(url); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of calling You can also remove the unused
Suggested change
References
|
||||||
| } catch (err: any) { | ||||||
| logger.debug("Unable to open billing URL: " + err.stack); | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of importing and calling
opendirectly from theopenpackage, reuse the existingopenInBrowserutility fromsrc/utils.ts. This utility is specifically designed to wrapopenso that it can be easily stubbed out in unit tests.Please also update the imports at the top of the file to include
openInBrowserfrom../utilsand remove the direct import ofopen.References
src/utils.tsfirst; reuse or extend existing helpers rather than writing bespoke inline logic. (link)