Skip to content

[AI Improvement] [Task] Fix restrict-plus-operands in 10 root-level src/*.ts files (slice 1) - #11468

Draft
joehan wants to merge 1 commit into
mainfrom
ai-improve-582886038-task-fix-restrict-plus-operands-in-
Draft

joehan wants to merge 1 commit into
mainfrom
ai-improve-582886038-task-fix-restrict-plus-operands-in-

Conversation

@joehan

@joehan joehan commented Nov 6, 2026

Copy link
Copy Markdown
Member

Description

Resolves Buganizer b/582886038 (Wave 3 slice 1 under b/565072516).

Fixes all 27 @typescript-eslint/restrict-plus-operands warnings across 10 root-level src/*.ts files without changing runtime behavior or modifying .eslintrc.js:

  • src/profileReport.ts (9 sites): Converted bytes + " B" in formatBytes to a template literal, typed the _.mergeWith customizer parameters in renderUnindexedData, and added local Bandwidth and SpeedStats types for collapsePaths combiners in renderBandwidth and renderOperationSpeed.
  • src/profileReport.spec.ts (1 site): Explicitly typed combinerFunc parameters and return value as { count: number }.
  • src/accountImporter.ts (6 sites): Bound const hashAlgoName = String(options.hashAlgo) in validateRequiredParameters to preserve user-supplied casing in error messages, and converted the sendRequest log message to a template literal.
  • src/accountExporter.ts (1 site): Converted the serialExportUsers log message to `Exported ${String(userList.length)} account(s) successfully.`.
  • src/accountExporter.spec.ts (3 sites): Wrapped user.disabled / singleUser.disabled booleans in String(...) in CSV row assertions.
  • src/localFunction.ts (3 sites): Replaced + concatenation with template literals in substituteParams and requestCallBack (wrapping err: unknown with String(err)).
  • src/projectUtils.ts (1 site): Cast synchronous marked(...) output to string with an explanatory comment.
  • src/utils.ts (1 site): Converted formatFilesize return expression to a template literal.
  • src/profiler.ts (1 site): Converted spinner.text assignment on stream end to a template literal.
  • src/config.ts (1 site): Replaced + e.message with ${getErrMsg(e)} from ./error.

Scenarios Tested

  • npx eslint (without --quiet) on all 10 modified files: 0 @typescript-eslint/restrict-plus-operands warnings (down from 27) and 0 new warnings of any rule.
  • npx tsc --noEmit -p tsconfig.json, npm run test:compile, npm run build, and npm run lint:quiet: Passed with 0 errors.
  • npx mocha src/profileReport.spec.ts src/accountExporter.spec.ts src/accountImporter.spec.ts src/localFunction.spec.ts src/utils.spec.ts src/config.spec.ts src/projectUtils.spec.ts: 147 passing.
  • npm run mocha: 5934 passing, 11 pending (only failure is the pre-existing port-52672 EADDRINUSE in src/apiv2.spec.ts on the shared host).

Sample Commands

N/A (internal linter cleanup with no CLI or behavior changes).

@joehan joehan self-assigned this Nov 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors several files to improve type safety, modernize string formatting using template literals, and handle errors more robustly. Key changes include replacing string concatenation with template literals, replacing any types with explicit types in profileReport.ts and profileReport.spec.ts, and using getErrMsg for error messages in config.ts. Feedback on these changes suggests removing redundant String() conversions inside template literals and refactoring the temporary hashAlgoName variable in accountImporter.ts to use template literals directly within the FirebaseError constructors.

Comment thread src/accountExporter.ts
if (userList && userList.length > 0) {
options.writeUsersToFile(userList, options.format, options.writeStream);
utils.logSuccess("Exported " + userList.length + " account(s) successfully.");
utils.logSuccess(`Exported ${String(userList.length)} account(s) successfully.`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Wrapping userList.length in String() is redundant inside a template literal, as template literals automatically convert numbers to strings. Removing it simplifies the code.

Suggested change
utils.logSuccess(`Exported ${String(userList.length)} account(s) successfully.`);
utils.logSuccess(`Exported ${userList.length} account(s) successfully.`);

Comment thread src/accountImporter.ts
return { valid: true };
}
const hashAlgo = options.hashAlgo.toUpperCase();
const hashAlgoName = String(options.hashAlgo);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Instead of introducing the temporary hashAlgoName variable and using string concatenation with +, you can use template literals directly in the FirebaseError constructors. This is much more idiomatic in TypeScript and avoids the need for hashAlgoName entirely.\n\nFor example, you can refactor the error throws like this:\n\ntypescript\nthrow new FirebaseError(`Must provide hash key(base64 encoded) for hash algorithm ${options.hashAlgo}`);\n

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant