Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@

const setup: Setup = {
config: config.src,
rcfile: config.readProjectFile(".firebaserc", {

Check warning on line 192 in src/commands/init.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
json: true,
fallback: {},
}),
Expand Down Expand Up @@ -249,6 +249,7 @@
setup.features = setup.features.filter((f) => f !== "hosting:github");
}

const productsInitialized = setup.features?.join(",") || "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this is correct, the optional chaining (?.) and the fallback to an empty string (|| "") are redundant here.

Based on the control flow in this function:

  • setup.features is assigned a value at either line 209 or 211.
  • The check at line 229 ensures that setup.features is a non-empty array, otherwise an error is thrown.

Therefore, setup.features is guaranteed to be a string[] with at least one element at this point, so you can safely call .join(',') directly. This makes the code slightly cleaner.

Suggested change
const productsInitialized = setup.features?.join(",") || "";
const productsInitialized = setup.features.join(",");

await init(setup, config, options);

logger.info();
Expand All @@ -257,9 +258,9 @@
if (!fsutils.fileExistsSync(config.path(".gitignore"))) {
config.writeProjectFile(".gitignore", GITIGNORE_TEMPLATE);
}
const duration = Math.floor((process.uptime() - start) * 1000);

await trackGA4("product_init", { products_initialized: setup.features?.join(",") }, duration);
const duration = Math.floor((process.uptime() - start) * 1000);
await trackGA4("product_init", { products_initialized: productsInitialized }, duration);

logger.info();
utils.logSuccess("Firebase initialization complete!");
Expand Down
Loading