Repository navigation
Conversation
…c files (b/582886038)
There was a problem hiding this comment.
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.
| 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.`); |
There was a problem hiding this comment.
Wrapping userList.length in String() is redundant inside a template literal, as template literals automatically convert numbers to strings. Removing it simplifies the code.
| utils.logSuccess(`Exported ${String(userList.length)} account(s) successfully.`); | |
| utils.logSuccess(`Exported ${userList.length} account(s) successfully.`); |
| return { valid: true }; | ||
| } | ||
| const hashAlgo = options.hashAlgo.toUpperCase(); | ||
| const hashAlgoName = String(options.hashAlgo); |
There was a problem hiding this comment.
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
Description
Resolves Buganizer b/582886038 (Wave 3 slice 1 under b/565072516).
Fixes all 27
@typescript-eslint/restrict-plus-operandswarnings across 10 root-levelsrc/*.tsfiles without changing runtime behavior or modifying.eslintrc.js:src/profileReport.ts(9 sites): Convertedbytes + " B"informatBytesto a template literal, typed the_.mergeWithcustomizer parameters inrenderUnindexedData, and added localBandwidthandSpeedStatstypes forcollapsePathscombiners inrenderBandwidthandrenderOperationSpeed.src/profileReport.spec.ts(1 site): Explicitly typedcombinerFuncparameters and return value as{ count: number }.src/accountImporter.ts(6 sites): Boundconst hashAlgoName = String(options.hashAlgo)invalidateRequiredParametersto preserve user-supplied casing in error messages, and converted thesendRequestlog message to a template literal.src/accountExporter.ts(1 site): Converted theserialExportUserslog message to`Exported ${String(userList.length)} account(s) successfully.`.src/accountExporter.spec.ts(3 sites): Wrappeduser.disabled/singleUser.disabledbooleans inString(...)in CSV row assertions.src/localFunction.ts(3 sites): Replaced+concatenation with template literals insubstituteParamsandrequestCallBack(wrappingerr: unknownwithString(err)).src/projectUtils.ts(1 site): Cast synchronousmarked(...)output tostringwith an explanatory comment.src/utils.ts(1 site): ConvertedformatFilesizereturn expression to a template literal.src/profiler.ts(1 site): Convertedspinner.textassignment on stream end to a template literal.src/config.ts(1 site): Replaced+ e.messagewith${getErrMsg(e)}from./error.Scenarios Tested
npx eslint(without--quiet) on all 10 modified files: 0@typescript-eslint/restrict-plus-operandswarnings (down from 27) and 0 new warnings of any rule.npx tsc --noEmit -p tsconfig.json,npm run test:compile,npm run build, andnpm 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-52672EADDRINUSEinsrc/apiv2.spec.tson the shared host).Sample Commands
N/A (internal linter cleanup with no CLI or behavior changes).