diff --git a/.eslintrc.js b/.eslintrc.js index 211c2b8563..9d2e19f64c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -32,19 +32,11 @@ module.exports = { "@typescript-eslint/no-use-before-define": 0, "@typescript-eslint/explicit-function-return-type": 0, "@typescript-eslint/camelcase": 0, - "@typescript-eslint/no-inferrable-types": 0, "@typescript-eslint/no-non-null-assertion": 0, - "@typescript-eslint/no-inferrable-types": 0, "@typescript-eslint/no-var-requires": 0, - "@typescript-eslint/no-unused-vars": 0, - "@typescript-eslint/member-delimiter-style": 0, - "@typescript-eslint/no-empty-interface": 0, - "@typescript-eslint/no-array-constructor": 0, "@typescript-eslint/ban-types": 0, - "no-case-declarations": 0, "no-useless-escape": 0, "no-prototype-builtins": 0, - "no-var": 0, // Required checks "indent": ["error", 2] diff --git a/src/auth/auth-api-request.ts b/src/auth/auth-api-request.ts index e4ae467369..847cda75ff 100755 --- a/src/auth/auth-api-request.ts +++ b/src/auth/auth-api-request.ts @@ -247,7 +247,7 @@ function validateProviderUserInfo(request: any) { * @param {any} request The create/edit request object. * @param {boolean=} uploadAccountRequest Whether to validate as an uploadAccount request. */ -function validateCreateEditRequest(request: any, uploadAccountRequest: boolean = false) { +function validateCreateEditRequest(request: any, uploadAccountRequest = false) { // Hash set of whitelisted parameters. const validKeys = { displayName: true, @@ -826,7 +826,7 @@ export abstract class AbstractAuthRequestHandler { */ public downloadAccount( maxResults: number = MAX_DOWNLOAD_ACCOUNT_PAGE_SIZE, - pageToken?: string): Promise<{users: object[], nextPageToken?: string}> { + pageToken?: string): Promise<{users: object[]; nextPageToken?: string}> { // Construct request. const request = { maxResults, @@ -842,7 +842,7 @@ export abstract class AbstractAuthRequestHandler { if (!response.users) { response.users = []; } - return response as {users: object[], nextPageToken?: string}; + return response as {users: object[]; nextPageToken?: string}; }); } @@ -885,7 +885,7 @@ export abstract class AbstractAuthRequestHandler { return this.invokeRequestHandler(this.getAuthUrlBuilder(), FIREBASE_AUTH_UPLOAD_ACCOUNT, request) .then((response: any) => { // No error object is returned if no error encountered. - const failedUploads = (response.error || []) as Array<{index: number, message: string}>; + const failedUploads = (response.error || []) as Array<{index: number; message: string}>; // Rewrite response as UserImportResult and re-insert client previously detected errors. return userImportBuilder.buildResponse(failedUploads); }); @@ -1155,7 +1155,7 @@ export abstract class AbstractAuthRequestHandler { public listOAuthIdpConfigs( maxResults: number = MAX_LIST_PROVIDER_CONFIGURATION_PAGE_SIZE, pageToken?: string): Promise { - const request: {pageSize: number, pageToken?: string} = { + const request: {pageSize: number; pageToken?: string} = { pageSize: maxResults, }; // Add next page token if provided. @@ -1168,7 +1168,7 @@ export abstract class AbstractAuthRequestHandler { response.oauthIdpConfigs = []; delete response.nextPageToken; } - return response as {oauthIdpConfigs: object[], nextPageToken?: string}; + return response as {oauthIdpConfigs: object[]; nextPageToken?: string}; }); } @@ -1183,7 +1183,7 @@ export abstract class AbstractAuthRequestHandler { return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID)); } return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_OAUTH_IDP_CONFIG, {}, {providerId}) - .then((response: any) => { + .then(() => { // Return nothing. }); } @@ -1277,7 +1277,7 @@ export abstract class AbstractAuthRequestHandler { public listInboundSamlConfigs( maxResults: number = MAX_LIST_PROVIDER_CONFIGURATION_PAGE_SIZE, pageToken?: string): Promise { - const request: {pageSize: number, pageToken?: string} = { + const request: {pageSize: number; pageToken?: string} = { pageSize: maxResults, }; // Add next page token if provided. @@ -1290,7 +1290,7 @@ export abstract class AbstractAuthRequestHandler { response.inboundSamlConfigs = []; delete response.nextPageToken; } - return response as {inboundSamlConfigs: object[], nextPageToken?: string}; + return response as {inboundSamlConfigs: object[]; nextPageToken?: string}; }); } @@ -1305,7 +1305,7 @@ export abstract class AbstractAuthRequestHandler { return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID)); } return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_INBOUND_SAML_CONFIG, {}, {providerId}) - .then((response: any) => { + .then(() => { // Return nothing. }); } @@ -1586,7 +1586,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler { */ public listTenants( maxResults: number = MAX_LIST_TENANT_PAGE_SIZE, - pageToken?: string): Promise<{tenants: TenantServerResponse[], nextPageToken?: string}> { + pageToken?: string): Promise<{tenants: TenantServerResponse[]; nextPageToken?: string}> { const request = { pageSize: maxResults, pageToken, @@ -1601,7 +1601,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler { response.tenants = []; delete response.nextPageToken; } - return response as {tenants: TenantServerResponse[], nextPageToken?: string}; + return response as {tenants: TenantServerResponse[]; nextPageToken?: string}; }); } @@ -1616,7 +1616,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler { return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_TENANT_ID)); } return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, DELETE_TENANT, {}, {tenantId}) - .then((response: any) => { + .then(() => { // Return nothing. }); } diff --git a/src/auth/auth-config.ts b/src/auth/auth-config.ts index 9842df1023..ed84a8f2d5 100755 --- a/src/auth/auth-config.ts +++ b/src/auth/auth-config.ts @@ -285,7 +285,7 @@ export class SAMLConfig implements SAMLAuthProviderConfig { */ public static buildServerRequest( options: SAMLAuthProviderRequest, - ignoreMissingFields: boolean = false): SAMLConfigServerRequest | null { + ignoreMissingFields = false): SAMLConfigServerRequest | null { const makeRequest = validator.isNonNullObject(options) && (options.providerId || ignoreMissingFields); if (!makeRequest) { @@ -349,7 +349,7 @@ export class SAMLConfig implements SAMLAuthProviderConfig { * @param {SAMLAuthProviderRequest} options The options object to validate. * @param {boolean=} ignoreMissingFields Whether to ignore missing fields. */ - public static validate(options: SAMLAuthProviderRequest, ignoreMissingFields: boolean = false) { + public static validate(options: SAMLAuthProviderRequest, ignoreMissingFields = false) { const validKeys = { enabled: true, displayName: true, @@ -545,7 +545,7 @@ export class OIDCConfig implements OIDCAuthProviderConfig { */ public static buildServerRequest( options: OIDCAuthProviderRequest, - ignoreMissingFields: boolean = false): OIDCConfigServerRequest | null { + ignoreMissingFields = false): OIDCConfigServerRequest | null { const makeRequest = validator.isNonNullObject(options) && (options.providerId || ignoreMissingFields); if (!makeRequest) { @@ -590,7 +590,7 @@ export class OIDCConfig implements OIDCAuthProviderConfig { * @param {OIDCAuthProviderRequest} options The options object to validate. * @param {boolean=} ignoreMissingFields Whether to ignore missing fields. */ - public static validate(options: OIDCAuthProviderRequest, ignoreMissingFields: boolean = false) { + public static validate(options: OIDCAuthProviderRequest, ignoreMissingFields = false) { const validKeys = { enabled: true, displayName: true, diff --git a/src/auth/auth.ts b/src/auth/auth.ts index 434481ea89..b838802a0f 100755 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -142,7 +142,7 @@ export class BaseAuth { * @return {Promise} A Promise that will be fulfilled after a successful * verification. */ - public verifyIdToken(idToken: string, checkRevoked: boolean = false): Promise { + public verifyIdToken(idToken: string, checkRevoked = false): Promise { return this.idTokenVerifier.verifyJWT(idToken) .then((decodedIdToken: DecodedIdToken) => { // Whether to check if the token was revoked. @@ -266,7 +266,7 @@ export class BaseAuth { */ public deleteUser(uid: string): Promise { return this.authRequestHandler.deleteAccount(uid) - .then((response) => { + .then(() => { // Return nothing on success. }); } @@ -296,7 +296,7 @@ export class BaseAuth { */ public setCustomUserClaims(uid: string, customUserClaims: object): Promise { return this.authRequestHandler.setCustomUserClaims(uid, customUserClaims) - .then((existingUid) => { + .then(() => { // Return nothing on success. }); } @@ -313,7 +313,7 @@ export class BaseAuth { */ public revokeRefreshTokens(uid: string): Promise { return this.authRequestHandler.revokeRefreshTokens(uid) - .then((existingUid) => { + .then(() => { // Return nothing on success. }); } @@ -371,7 +371,7 @@ export class BaseAuth { * verification. */ public verifySessionCookie( - sessionCookie: string, checkRevoked: boolean = false): Promise { + sessionCookie: string, checkRevoked = false): Promise { return this.sessionCookieVerifier.verifyJWT(sessionCookie) .then((decodedIdToken: DecodedIdToken) => { // Whether to check if the token was revoked. @@ -639,7 +639,7 @@ export class TenantAwareAuth extends BaseAuth { * @return {Promise} A Promise that will be fulfilled after a successful * verification. */ - public verifyIdToken(idToken: string, checkRevoked: boolean = false): Promise { + public verifyIdToken(idToken: string, checkRevoked = false): Promise { return super.verifyIdToken(idToken, checkRevoked) .then((decodedClaims) => { // Validate tenant ID. @@ -673,7 +673,7 @@ export class TenantAwareAuth extends BaseAuth { } // This will verify the ID token and then match the tenant ID before creating the session cookie. return this.verifyIdToken(idToken) - .then((decodedIdTokenClaims) => { + .then(() => { return super.createSessionCookie(idToken, sessionCookieOptions); }); } @@ -691,7 +691,7 @@ export class TenantAwareAuth extends BaseAuth { * verification. */ public verifySessionCookie( - sessionCookie: string, checkRevoked: boolean = false): Promise { + sessionCookie: string, checkRevoked = false): Promise { return super.verifySessionCookie(sessionCookie, checkRevoked) .then((decodedClaims) => { if (decodedClaims.firebase.tenant !== this.tenantId) { diff --git a/src/auth/tenant-manager.ts b/src/auth/tenant-manager.ts index f92e30fb26..73950a76bd 100644 --- a/src/auth/tenant-manager.ts +++ b/src/auth/tenant-manager.ts @@ -89,7 +89,7 @@ export class TenantManager { maxResults?: number, pageToken?: string): Promise { return this.authRequestHandler.listTenants(maxResults, pageToken) - .then((response: {tenants: TenantServerResponse[], nextPageToken?: string}) => { + .then((response: {tenants: TenantServerResponse[]; nextPageToken?: string}) => { // List of tenants to return. const tenants: Tenant[] = []; // Convert each user response to a Tenant. diff --git a/src/auth/user-import-builder.ts b/src/auth/user-import-builder.ts index 4e22b5a1ef..fdce19c764 100644 --- a/src/auth/user-import-builder.ts +++ b/src/auth/user-import-builder.ts @@ -54,11 +54,11 @@ export interface UserImportRecord { creationTime?: string; }; providerData?: Array<{ - uid: string, - displayName?: string, - email?: string, - photoURL?: string, - providerId: string, + uid: string; + displayName?: string; + email?: string; + photoURL?: string; + providerId: string; }>; customClaims?: object; passwordHash?: Buffer; @@ -261,7 +261,7 @@ export class UserImportBuilder { * uploadAccount response. */ public buildResponse( - failedUploads: Array<{index: number, message: string}>): UserImportResult { + failedUploads: Array<{index: number; message: string}>): UserImportResult { // Initialize user import result. const importResult: UserImportResult = { successCount: this.validatedUsers.length, @@ -343,7 +343,7 @@ export class UserImportBuilder { case 'MD5': case 'SHA1': case 'SHA256': - case 'SHA512': + case 'SHA512': { // MD5 is [0,8192] but SHA1, SHA256, and SHA512 are [1,8192] rounds = getNumberField(options.hash, 'rounds'); const minRounds = options.hash.algorithm === 'MD5' ? 0 : 1; @@ -359,7 +359,7 @@ export class UserImportBuilder { rounds, }; break; - + } case 'PBKDF_SHA1': case 'PBKDF2_SHA256': rounds = getNumberField(options.hash, 'rounds'); @@ -376,7 +376,7 @@ export class UserImportBuilder { }; break; - case 'SCRYPT': + case 'SCRYPT': { if (!validator.isBuffer(options.hash.key)) { throw new FirebaseAuthError( AuthClientErrorCode.INVALID_HASH_KEY, @@ -415,14 +415,14 @@ export class UserImportBuilder { saltSeparator: utils.toWebSafeBase64(options.hash.saltSeparator || Buffer.from('')), }; break; - + } case 'BCRYPT': populatedOptions = { hashAlgorithm: options.hash.algorithm, }; break; - case 'STANDARD_SCRYPT': + case 'STANDARD_SCRYPT': { const cpuMemCost = getNumberField(options.hash, 'memoryCost'); if (isNaN(cpuMemCost)) { throw new FirebaseAuthError( @@ -463,7 +463,7 @@ export class UserImportBuilder { dkLen, }; break; - + } default: throw new FirebaseAuthError( AuthClientErrorCode.INVALID_HASH_ALGORITHM, diff --git a/src/database/database.ts b/src/database/database.ts index c8b07f09fa..379167a694 100644 --- a/src/database/database.ts +++ b/src/database/database.ts @@ -16,7 +16,7 @@ import { AuthorizedHttpClient, HttpRequestConfig, HttpError } from '../utils/api class DatabaseInternals implements FirebaseServiceInternalsInterface { public databases: { - [dbUrl: string]: Database, + [dbUrl: string]: Database; } = {}; /** diff --git a/src/firebase-app.ts b/src/firebase-app.ts index b58f6ac019..aba82b6cd0 100644 --- a/src/firebase-app.ts +++ b/src/firebase-app.ts @@ -225,7 +225,7 @@ export class FirebaseAppInternals { private setTokenRefreshTimeout(delayInMilliseconds: number, numRetries: number): void { this.tokenRefreshTimeout_ = setTimeout(() => { this.getToken(/* forceRefresh */ true) - .catch((error) => { + .catch(() => { // Ignore the error since this might just be an intermittent failure. If we really cannot // refresh the token, an error will be logged once the existing token expires and we try // to fetch a fresh one. diff --git a/src/firebase-namespace.ts b/src/firebase-namespace.ts index f01d3861b2..caf58d439d 100644 --- a/src/firebase-namespace.ts +++ b/src/firebase-namespace.ts @@ -45,7 +45,7 @@ const DEFAULT_APP_NAME = '[DEFAULT]'; * If the environment variable contains a string that starts with '{' it will be parsed as JSON, * otherwise it will be assumed to be pointing to a file. */ -export const FIREBASE_CONFIG_VAR: string = 'FIREBASE_CONFIG'; +export const FIREBASE_CONFIG_VAR = 'FIREBASE_CONFIG'; let globalAppDefaultCred: Credential; diff --git a/src/index.d.ts b/src/index.d.ts index 9a24bba671..8ee67a49fe 100755 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -179,8 +179,8 @@ declare namespace admin { httpAgent?: Agent; } - var SDK_VERSION: string; - var apps: (admin.app.App | null)[]; + const SDK_VERSION: string; + const apps: (admin.app.App | null)[]; function app(name?: string): admin.app.App; @@ -1101,14 +1101,14 @@ declare namespace admin.auth { /** * Interface representing a tenant configuration. - * + * * Multi-tenancy support requires Google Cloud's Identity Platform * (GCIP). To learn more about GCIP, including pricing and features, * see the [GCIP documentation](https://cloud.google.com/identity-platform) - * + * * Before multi-tenancy can be used on a Google Cloud Identity Platform project, * tenants must be allowed on that project via the Cloud Console UI. - * + * * A tenant configuration provides information such as the display name, tenant * identifier and email authentication configuration. * For OIDC/SAML provider configuration management, `TenantAwareAuth` instances should @@ -1145,7 +1145,7 @@ declare namespace admin.auth { * Whether password is required for email sign-in. When not required, * email sign-in can be performed with password or via email link sign-in. */ - passwordRequired?: boolean + passwordRequired?: boolean; }; /** @@ -1185,13 +1185,12 @@ declare namespace admin.auth { /** * Interface representing the properties to set on a new tenant. */ - interface CreateTenantRequest extends UpdateTenantRequest { - } + type CreateTenantRequest = UpdateTenantRequest /** * Interface representing the object returned from a * {@link https://firebase.google.com/docs/reference/admin/node/admin.auth.Auth#listTenants `listTenants()`} - * operation. + * operation. * Contains the list of tenants for the current batch and the next page token if available. */ interface ListTenantsResult { @@ -1654,7 +1653,7 @@ declare namespace admin.auth { importUsers( users: admin.auth.UserImportRecord[], options?: admin.auth.UserImportOptions, - ): Promise + ): Promise; /** * Creates a new Firebase session cookie with the specified options. The created @@ -1997,7 +1996,7 @@ declare namespace admin.auth { * */ interface TenantManager { - /** + /** * @param tenantId The tenant ID whose `TenantAwareAuth` instance is to be returned. * * @return The `TenantAwareAuth` instance corresponding to this tenant identifier. @@ -2037,7 +2036,7 @@ declare namespace admin.auth { */ deleteTenant(tenantId: string): Promise; - /** + /** * Creates a new tenant. * When creating new tenants, tenants that use separate billing and quota will require their * own project and must be defined as `full_service`. @@ -3777,8 +3776,8 @@ declare namespace admin.database { onComplete?: (a: Error | null, b: boolean, c: admin.database.DataSnapshot | null) => any, applyLocally?: boolean ): Promise<{ - committed: boolean, - snapshot: admin.database.DataSnapshot | null + committed: boolean; + snapshot: admin.database.DataSnapshot | null; }>; /** @@ -3839,7 +3838,7 @@ declare namespace admin.database { } declare namespace admin.database.ServerValue { - var TIMESTAMP: number; + const TIMESTAMP: number; } type BaseMessage = { @@ -4006,15 +4005,15 @@ declare namespace admin.messaging { channelId?: string; /** - * Sets the "ticker" text, which is sent to accessibility services. Prior to - * API level 21 (Lollipop), sets the text that is displayed in the status bar + * Sets the "ticker" text, which is sent to accessibility services. Prior to + * API level 21 (Lollipop), sets the text that is displayed in the status bar * when the notification first arrives. */ ticker?: string; /** - * When set to `false` or unset, the notification is automatically dismissed when - * the user clicks it in the panel. When set to `true`, the notification persists + * When set to `false` or unset, the notification is automatically dismissed when + * the user clicks it in the panel. When set to `true`, the notification persists * even when the user clicks it. */ sticky?: boolean; @@ -4027,73 +4026,73 @@ declare namespace admin.messaging { eventTimestamp?: Date; /** - * Sets whether or not this notification is relevant only to the current device. - * Some notifications can be bridged to other devices for remote display, such as - * a Wear OS watch. This hint can be set to recommend this notification not be bridged. + * Sets whether or not this notification is relevant only to the current device. + * Some notifications can be bridged to other devices for remote display, such as + * a Wear OS watch. This hint can be set to recommend this notification not be bridged. * See [Wear OS guides](https://developer.android.com/training/wearables/notifications/bridger#existing-method-of-preventing-bridging) */ localOnly?: boolean; /** - * Sets the relative priority for this notification. Low-priority notifications - * may be hidden from the user in certain situations. Note this priority differs - * from `AndroidMessagePriority`. This priority is processed by the client after - * the message has been delivered. Whereas `AndroidMessagePriority` is an FCM concept + * Sets the relative priority for this notification. Low-priority notifications + * may be hidden from the user in certain situations. Note this priority differs + * from `AndroidMessagePriority`. This priority is processed by the client after + * the message has been delivered. Whereas `AndroidMessagePriority` is an FCM concept * that controls when the message is delivered. */ priority?: ('min' | 'low' | 'default' | 'high' | 'max'); /** - * Sets the vibration pattern to use. Pass in an array of milliseconds to - * turn the vibrator on or off. The first value indicates the duration to wait before - * turning the vibrator on. The next value indicates the duration to keep the - * vibrator on. Subsequent values alternate between duration to turn the vibrator - * off and to turn the vibrator on. If `vibrate_timings` is set and `default_vibrate_timings` + * Sets the vibration pattern to use. Pass in an array of milliseconds to + * turn the vibrator on or off. The first value indicates the duration to wait before + * turning the vibrator on. The next value indicates the duration to keep the + * vibrator on. Subsequent values alternate between duration to turn the vibrator + * off and to turn the vibrator on. If `vibrate_timings` is set and `default_vibrate_timings` * is set to `true`, the default value is used instead of the user-specified `vibrate_timings`. */ vibrateTimingsMillis?: number[]; /** - * If set to `true`, use the Android framework's default vibrate pattern for the - * notification. Default values are specified in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). - * If `default_vibrate_timings` is set to `true` and `vibrate_timings` is also set, + * If set to `true`, use the Android framework's default vibrate pattern for the + * notification. Default values are specified in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). + * If `default_vibrate_timings` is set to `true` and `vibrate_timings` is also set, * the default value is used instead of the user-specified `vibrate_timings`. */ defaultVibrateTimings?: boolean; /** - * If set to `true`, use the Android framework's default sound for the notification. + * If set to `true`, use the Android framework's default sound for the notification. * Default values are specified in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). */ defaultSound?: boolean; /** - * Settings to control the notification's LED blinking rate and color if LED is + * Settings to control the notification's LED blinking rate and color if LED is * available on the device. The total blinking time is controlled by the OS. */ lightSettings?: LightSettings; /** - * If set to `true`, use the Android framework's default LED light settings - * for the notification. Default values are specified in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). - * If `default_light_settings` is set to `true` and `light_settings` is also set, + * If set to `true`, use the Android framework's default LED light settings + * for the notification. Default values are specified in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). + * If `default_light_settings` is set to `true` and `light_settings` is also set, * the user-specified `light_settings` is used instead of the default value. */ defaultLightSettings?: boolean; /** - * Sets the visibility of the notification. Must be either `private`, `public`, + * Sets the visibility of the notification. Must be either `private`, `public`, * or `secret`. If unspecified, defaults to `private`. */ visibility?: ('private' | 'public' | 'secret'); /** - * Sets the number of items this notification represents. May be displayed as a - * badge count for Launchers that support badging. See [`NotificationBadge`(https://developer.android.com/training/notify-user/badges). + * Sets the number of items this notification represents. May be displayed as a + * badge count for Launchers that support badging. See [`NotificationBadge`(https://developer.android.com/training/notify-user/badges). * For example, this might be useful if you're using just one notification to * represent multiple new messages but you want the count here to represent - * the number of total new messages. If zero or unspecified, systems - * that support badging use the default, which is to increment a number + * the number of total new messages. If zero or unspecified, systems + * that support badging use the default, which is to increment a number * displayed on the long-press menu each time a new notification arrives. */ notificationCount?: number; @@ -4115,7 +4114,7 @@ declare namespace admin.messaging { lightOnDurationMillis: number; /** - * Required. Along with `light_on_duration`, defines the blink rate of LED flashes. + * Required. Along with `light_on_duration`, defines the blink rate of LED flashes. */ lightOffDurationMillis: number; } diff --git a/src/instance-id/instance-id-request.ts b/src/instance-id/instance-id-request.ts index e4c95aee68..b683ff038b 100644 --- a/src/instance-id/instance-id-request.ts +++ b/src/instance-id/instance-id-request.ts @@ -87,7 +87,7 @@ export class FirebaseInstanceIdRequestHandler { }; return this.httpClient.send(req); }) - .then((response) => { + .then(() => { // return nothing on success }) .catch((err) => { diff --git a/src/instance-id/instance-id.ts b/src/instance-id/instance-id.ts index a3ebf0a189..27e807528d 100644 --- a/src/instance-id/instance-id.ts +++ b/src/instance-id/instance-id.ts @@ -68,7 +68,7 @@ export class InstanceId implements FirebaseServiceInterface { */ public deleteInstanceId(instanceId: string): Promise { return this.requestHandler.deleteInstanceId(instanceId) - .then((result) => { + .then(() => { // Return nothing on success }); } diff --git a/src/messaging/batch-request.ts b/src/messaging/batch-request.ts index b0b2937a32..0c6995a874 100644 --- a/src/messaging/batch-request.ts +++ b/src/messaging/batch-request.ts @@ -19,7 +19,7 @@ import { } from '../utils/api-request'; import { FirebaseAppError, AppErrorCodes } from '../utils/error'; -const PART_BOUNDARY: string = '__END_OF_PART__'; +const PART_BOUNDARY = '__END_OF_PART__'; const TEN_SECONDS_IN_MILLIS = 10000; /** @@ -85,7 +85,7 @@ export class BatchRequestClient { } private getMultipartPayload(requests: SubRequest[]): Buffer { - let buffer: string = ''; + let buffer = ''; requests.forEach((request: SubRequest, idx: number) => { buffer += createPart(request, PART_BOUNDARY, idx); }); @@ -107,7 +107,7 @@ export class BatchRequestClient { */ function createPart(request: SubRequest, boundary: string, idx: number): string { const serializedRequest: string = serializeSubRequest(request); - let part: string = `--${boundary}\r\n`; + let part = `--${boundary}\r\n`; part += `Content-Length: ${serializedRequest.length}\r\n`; part += 'Content-Type: application/http\r\n'; part += `content-id: ${idx + 1}\r\n`; @@ -127,7 +127,7 @@ function createPart(request: SubRequest, boundary: string, idx: number): string */ function serializeSubRequest(request: SubRequest): string { const requestBody: string = JSON.stringify(request.body); - let messagePayload: string = `POST ${request.url} HTTP/1.1\r\n`; + let messagePayload = `POST ${request.url} HTTP/1.1\r\n`; messagePayload += `Content-Length: ${requestBody.length}\r\n`; messagePayload += 'Content-Type: application/json; charset=UTF-8\r\n'; if (request.headers) { diff --git a/src/messaging/messaging-errors.ts b/src/messaging/messaging-errors.ts index 2d937d6f21..b317404087 100644 --- a/src/messaging/messaging-errors.ts +++ b/src/messaging/messaging-errors.ts @@ -35,7 +35,7 @@ export function createFirebaseError(err: HttpError): FirebaseMessagingError { } // Non-JSON response - let error: {code: string, message: string}; + let error: {code: string; message: string}; switch (err.response.status) { case 400: error = MessagingClientErrorCode.INVALID_ARGUMENT; diff --git a/src/messaging/messaging.ts b/src/messaging/messaging.ts index b37f8c987d..faee5f29a1 100644 --- a/src/messaging/messaging.ts +++ b/src/messaging/messaging.ts @@ -251,7 +251,7 @@ export class Messaging implements FirebaseServiceInterface { } return this.getUrlPath() .then((urlPath) => { - const request: {message: Message, validate_only?: boolean} = {message: copy}; + const request: {message: Message; validate_only?: boolean} = {message: copy}; if (dryRun) { request.validate_only = true; } @@ -304,7 +304,7 @@ export class Messaging implements FirebaseServiceInterface { .then((urlPath) => { const requests: SubRequest[] = copy.map((message) => { validateMessage(message); - const request: {message: Message, validate_only?: boolean} = {message}; + const request: {message: Message; validate_only?: boolean} = {message}; if (dryRun) { request.validate_only = true; } diff --git a/src/security-rules/security-rules-api-client.ts b/src/security-rules/security-rules-api-client.ts index 01bc02baee..37989081fb 100644 --- a/src/security-rules/security-rules-api-client.ts +++ b/src/security-rules/security-rules-api-client.ts @@ -35,7 +35,7 @@ export interface Release { export interface RulesetContent { readonly source: { - readonly files: Array<{ name: string, content: string }>; + readonly files: Array<{ name: string; content: string }>; }; } @@ -45,7 +45,7 @@ export interface RulesetResponse extends RulesetContent { } export interface ListRulesetsResponse { - readonly rulesets: Array<{ name: string, createTime: string }>; + readonly rulesets: Array<{ name: string; createTime: string }>; readonly nextPageToken?: string; } @@ -123,7 +123,7 @@ export class SecurityRulesApiClient { }); } - public listRulesets(pageSize: number = 100, pageToken?: string): Promise { + public listRulesets(pageSize = 100, pageToken?: string): Promise { if (!validator.isNumber(pageSize)) { const err = new FirebaseSecurityRulesError('invalid-argument', 'Invalid page size.'); return Promise.reject(err); diff --git a/src/security-rules/security-rules.ts b/src/security-rules/security-rules.ts index 77fff948fa..21da0eabab 100644 --- a/src/security-rules/security-rules.ts +++ b/src/security-rules/security-rules.ts @@ -303,7 +303,7 @@ export class SecurityRules implements FirebaseServiceInterface { * without any offset. * @returns {Promise} A promise that fulfills a page of rulesets. */ - public listRulesetMetadata(pageSize: number = 100, nextPageToken?: string): Promise { + public listRulesetMetadata(pageSize = 100, nextPageToken?: string): Promise { return this.client.listRulesets(pageSize, nextPageToken) .then((response) => { return new RulesetMetadataListImpl(response); diff --git a/src/utils/api-request.ts b/src/utils/api-request.ts index 17d56790b8..661cc50477 100644 --- a/src/utils/api-request.ts +++ b/src/utils/api-request.ts @@ -274,7 +274,7 @@ export class HttpClient { * @param {number} retryAttempts Number of retries performed up to now. * @return {Promise} A promise that resolves with the response details. */ - private sendWithRetry(config: HttpRequestConfig, retryAttempts: number = 0): Promise { + private sendWithRetry(config: HttpRequestConfig, retryAttempts = 0): Promise { return AsyncHttpCall.invoke(config) .then((resp) => { return this.createHttpResponse(resp); @@ -855,7 +855,7 @@ export class ApiSettings { * @return {ApiSettings} The current API settings instance. */ public setRequestValidator(requestValidator: ApiCallbackFunction | null): ApiSettings { - const nullFunction: (_: object) => void = (_: object) => undefined; + const nullFunction: ApiCallbackFunction = () => undefined; this.requestValidator = requestValidator || nullFunction; return this; } @@ -870,7 +870,7 @@ export class ApiSettings { * @return {ApiSettings} The current API settings instance. */ public setResponseValidator(responseValidator: ApiCallbackFunction | null): ApiSettings { - const nullFunction: (_: object) => void = (_: object) => undefined; + const nullFunction: ApiCallbackFunction = () => undefined; this.responseValidator = responseValidator || nullFunction; return this; } diff --git a/src/utils/deep-copy.ts b/src/utils/deep-copy.ts index 8f2520e36f..2cff483604 100644 --- a/src/utils/deep-copy.ts +++ b/src/utils/deep-copy.ts @@ -46,12 +46,12 @@ export function deepExtend(target: any, source: any): any { } switch (source.constructor) { - case Date: + case Date: { // Treat Dates like scalars; if the target date object had any child // properties - they will be lost! const dateValue = (source as any) as Date; return new Date(dateValue.getTime()); - + } case Object: if (target === undefined) { target = {}; diff --git a/test/integration/auth.spec.ts b/test/integration/auth.spec.ts index 29279d08d0..9e43c92abd 100755 --- a/test/integration/auth.spec.ts +++ b/test/integration/auth.spec.ts @@ -441,7 +441,7 @@ describe('admin.auth', () => { it('generatePasswordResetLink() should return a password reset link', () => { // Ensure old password set on created user. return admin.auth().updateUser(uid, {password: 'password'}) - .then((userRecord) => { + .then(() => { return admin.auth().generatePasswordResetLink(email, actionCodeSettings); }) .then((link) => { @@ -549,7 +549,7 @@ describe('admin.auth', () => { createdTenants.forEach((tenantId) => { promises.push( admin.auth().tenantManager().deleteTenant(tenantId) - .catch((error) => {/** Ignore. */})); + .catch(() => {/** Ignore. */})); }); return Promise.all(promises); }); @@ -595,7 +595,7 @@ describe('admin.auth', () => { // If user successfully created, make sure it is deleted at the end of the test suite. if (createdUserUid) { return tenantAwareAuth.deleteUser(createdUserUid) - .catch((error) => { + .catch(() => { // Ignore error. }); } @@ -782,7 +782,7 @@ describe('admin.auth', () => { after(() => { if (tenantAwareAuth) { return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId) - .catch((error) => { + .catch(() => { // Ignore error. }); } @@ -840,7 +840,7 @@ describe('admin.auth', () => { after(() => { if (tenantAwareAuth) { return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId) - .catch((error) => { + .catch(() => { // Ignore error. }); } @@ -936,7 +936,7 @@ describe('admin.auth', () => { .then(() => { return admin.auth().tenantManager().getTenant(createdTenantId); }) - .then((result) => { + .then(() => { throw new Error('unexpected success'); }) .catch((error) => { @@ -971,8 +971,8 @@ describe('admin.auth', () => { const removeTempConfigs = () => { return Promise.all([ - admin.auth().deleteProviderConfig(authProviderConfig1.providerId).catch((error) => {/* empty */}), - admin.auth().deleteProviderConfig(authProviderConfig2.providerId).catch((error) => {/* empty */}), + admin.auth().deleteProviderConfig(authProviderConfig1.providerId).catch(() => {/* empty */}), + admin.auth().deleteProviderConfig(authProviderConfig2.providerId).catch(() => {/* empty */}), ]); }; @@ -1103,8 +1103,8 @@ describe('admin.auth', () => { const removeTempConfigs = () => { return Promise.all([ - admin.auth().deleteProviderConfig(authProviderConfig1.providerId).catch((error) => {/* empty */}), - admin.auth().deleteProviderConfig(authProviderConfig2.providerId).catch((error) => {/* empty */}), + admin.auth().deleteProviderConfig(authProviderConfig1.providerId).catch(() => {/* empty */}), + admin.auth().deleteProviderConfig(authProviderConfig2.providerId).catch(() => {/* empty */}), ]); }; @@ -1475,7 +1475,7 @@ describe('admin.auth', () => { { name: 'SCRYPT', importOptions: scryptHashOptions as any, - computePasswordHash: (userImportTest: UserImportTest): Buffer => { + computePasswordHash: (): Buffer => { return Buffer.from(scryptPasswordHash, 'base64'); }, rawPassword, @@ -1716,7 +1716,7 @@ function safeDelete(uid: string): Promise { } }); // Suppress errors in delete queue to not spill over to next item in queue. - deleteQueue = deletePromise.catch((error) => { + deleteQueue = deletePromise.catch(() => { // Do nothing. }); return deletePromise; diff --git a/test/integration/database.spec.ts b/test/integration/database.spec.ts index db3fa84e89..1419313416 100644 --- a/test/integration/database.spec.ts +++ b/test/integration/database.spec.ts @@ -174,6 +174,8 @@ describe('admin.database', () => { // Check for type compilation. This method is not invoked by any // tests. But it will trigger a TS compilation failure if the RTDB // typings were not loaded correctly. +// +// eslint-disable-next-line @typescript-eslint/no-unused-vars function addValueEventListener( db: admin.database.Database, callback: (s: admin.database.DataSnapshot | null) => any) { diff --git a/test/integration/firestore.spec.ts b/test/integration/firestore.spec.ts index 085212b9c2..d3bbf51493 100644 --- a/test/integration/firestore.spec.ts +++ b/test/integration/firestore.spec.ts @@ -50,7 +50,7 @@ describe('admin.firestore', () => { it('supports basic data access', () => { return reference.set(mountainView) - .then((result) => { + .then(() => { return reference.get(); }) .then((snapshot) => { @@ -58,7 +58,7 @@ describe('admin.firestore', () => { expect(data).to.deep.equal(mountainView); return reference.delete(); }) - .then((result) => { + .then(() => { return reference.get(); }) .then((snapshot) => { @@ -70,7 +70,7 @@ describe('admin.firestore', () => { const expected: any = clone(mountainView); expected.timestamp = admin.firestore.FieldValue.serverTimestamp(); return reference.set(expected) - .then((result) => { + .then(() => { return reference.get(); }) .then((snapshot) => { @@ -117,10 +117,10 @@ describe('admin.firestore', () => { const source = admin.firestore().collection('cities').doc(); const target = admin.firestore().collection('cities').doc(); return source.set(mountainView) - .then((result) => { + .then(() => { return target.set({name: 'Palo Alto', sisterCity: source}); }) - .then((result) => { + .then(() => { return target.get(); }) .then((snapshot) => { @@ -142,10 +142,10 @@ describe('admin.firestore', () => { logs.push(log); }); return source.set({name: 'San Francisco'}) - .then((result) => { + .then(() => { return source.delete(); }) - .then((result) => { + .then(() => { expect(logs.length).greaterThan(0); }); }); diff --git a/test/integration/setup.ts b/test/integration/setup.ts index aee39257d3..8b5dfcda71 100644 --- a/test/integration/setup.ts +++ b/test/integration/setup.ts @@ -126,7 +126,7 @@ class CertificatelessCredential implements Credential { * @param allowNumbers Whether to allow numbers in the generated string. The default is true. * @return A random string of the provided length. */ -export function generateRandomString(length: number, allowNumbers: boolean = true): string { +export function generateRandomString(length: number, allowNumbers = true): string { const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + (allowNumbers ? '0123456789' : ''); let text = ''; diff --git a/test/integration/storage.spec.ts b/test/integration/storage.spec.ts index de6150f7a7..55e2414580 100644 --- a/test/integration/storage.spec.ts +++ b/test/integration/storage.spec.ts @@ -59,7 +59,7 @@ function verifyBucket(bucket: Bucket, testName: string): Promise { expect(data[0].toString()).to.equal(expected); return file.delete(); }) - .then((resp) => { + .then(() => { return file.exists(); }) .then((data) => { diff --git a/test/resources/mocks.ts b/test/resources/mocks.ts index a8e1cbc807..c2c3dd3aa1 100644 --- a/test/resources/mocks.ts +++ b/test/resources/mocks.ts @@ -222,7 +222,7 @@ export function generateSessionCookie(overrides?: object, expiresIn?: number): s export function firebaseServiceFactory( firebaseApp: FirebaseApp, - extendApp?: (props: object) => void, + extendApp?: (props: object) => void, // eslint-disable-line @typescript-eslint/no-unused-vars ): FirebaseServiceInterface { const result = { app: firebaseApp, @@ -233,7 +233,7 @@ export function firebaseServiceFactory( /** Mock socket emitter class. */ export class MockSocketEmitter extends events.EventEmitter { - public setTimeout: (_: number) => void = (timeout: number) => undefined; + public setTimeout: (_: number) => void = () => undefined; } /** Mock stream passthrough class with dummy abort method. */ diff --git a/test/unit/auth/auth-api-request.spec.ts b/test/unit/auth/auth-api-request.spec.ts index cf29267c1c..5b4cd722ff 100755 --- a/test/unit/auth/auth-api-request.spec.ts +++ b/test/unit/auth/auth-api-request.spec.ts @@ -864,7 +864,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createSessionCookie('', durationInMs) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -877,7 +877,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createSessionCookie('ID_TOKEN', 'invalid' as any) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -891,7 +891,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createSessionCookie('ID_TOKEN', outOfBoundDuration) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -905,7 +905,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createSessionCookie('ID_TOKEN', outOfBoundDuration) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -924,7 +924,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createSessionCookie('invalid-token', durationInMs) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -970,7 +970,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getAccountInfoByEmail('user@example.com') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1010,7 +1010,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getAccountInfoByUid('uid') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1031,7 +1031,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getAccountInfoByUid('uid') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1081,7 +1081,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { stubs.push(stub); const requestHandler = handler.init(mockApp); return requestHandler.getAccountInfoByPhoneNumber('invalid') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1103,7 +1103,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getAccountInfoByPhoneNumber('+11234567890') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1432,7 +1432,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); const userImportBuilder = new UserImportBuilder(users, options); return requestHandler.uploadAccount(users, options) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1510,7 +1510,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.downloadAccount(1001, nextPageToken) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1523,7 +1523,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.downloadAccount(maxResults, '') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1545,7 +1545,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.downloadAccount(maxResults, nextPageToken) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1585,7 +1585,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { stubs.push(stub); const requestHandler = handler.init(mockApp); return requestHandler.deleteAccount('uid') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1746,7 +1746,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send update request with invalid email. return requestHandler.updateExistingAccount(uid, invalidData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Invalid email error should be thrown. @@ -1765,7 +1765,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send update request with tenant ID. return requestHandler.updateExistingAccount(uid, dataWithModifiedTenantId) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Invalid argument error should be thrown. @@ -1779,7 +1779,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send update request with invalid phone number. return requestHandler.updateExistingAccount(uid, invalidPhoneNumberData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Invalid phone number error should be thrown. @@ -1801,7 +1801,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.updateExistingAccount(uid, validData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1868,7 +1868,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send request with invalid uid. return requestHandler.setCustomUserClaims('', claims) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Invalid uid error should be thrown. @@ -1885,7 +1885,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send request with invalid claims. return requestHandler.setCustomUserClaims(uid, 'invalid' as any) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Invalid argument error should be thrown. @@ -1903,7 +1903,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const blacklistedClaims = {admin: true, aud: 'bla'}; // Send request with blacklisted claims. return requestHandler.setCustomUserClaims(uid, blacklistedClaims) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Forbidden claims error should be thrown. @@ -1924,7 +1924,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.setCustomUserClaims(uid, claims) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -1977,7 +1977,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.revokeRefreshTokens(invalidUid as any) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Invalid uid error should be thrown. @@ -2004,7 +2004,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { // Simulate 5 seconds passed. clock.tick(5000); return requestHandler.revokeRefreshTokens(uid) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2096,7 +2096,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Create new account with invalid email. return requestHandler.createNewAccount(invalidData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Expected invalid email error should be thrown. @@ -2115,7 +2115,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Create new account with tenantId. return requestHandler.createNewAccount(validDataWithTenantId) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Expected invalid argument error should be thrown. @@ -2129,7 +2129,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Create new account with invalid phone number. return requestHandler.createNewAccount(invalidPhoneNumberData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Expected invalid phone number error should be thrown. @@ -2152,7 +2152,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { // Send create new account request and simulate a backend error that the user // already exists. return requestHandler.createNewAccount(validData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2176,7 +2176,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { // Send create new account request and simulate a backend error that the email // already exists. return requestHandler.createNewAccount(validData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2199,7 +2199,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send create new account request with valid data but simulate backend error. return requestHandler.createNewAccount(validData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2268,7 +2268,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send create new account request with invalid data. return requestHandler.createNewAccount(invalidData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2282,7 +2282,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send create new account request with invalid data. return requestHandler.createNewAccount(invalidPhoneNumberData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2303,7 +2303,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send valid create new account request and simulate backend error. return requestHandler.createNewAccount(validData) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2412,7 +2412,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getEmailActionLink('PASSWORD_RESET', invalidEmail, actionCodeSettings) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Invalid email error should be thrown. @@ -2429,7 +2429,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getEmailActionLink(invalidRequestType, email, actionCodeSettings) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Invalid argument error should be thrown. @@ -2446,7 +2446,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getEmailActionLink('EMAIL_SIGNIN', email, invalidActionCodeSettings) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Invalid argument error should be thrown. @@ -2470,7 +2470,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getEmailActionLink('VERIFY_EMAIL', email, actionCodeSettings) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2496,7 +2496,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getEmailActionLink('VERIFY_EMAIL', email, actionCodeSettings) - .then((returnedUid: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2534,7 +2534,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getOAuthIdpConfig(invalidProviderId as any) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2554,7 +2554,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getOAuthIdpConfig(providerId) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2637,7 +2637,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.listOAuthIdpConfigs(101, nextPageToken) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2651,7 +2651,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.listOAuthIdpConfigs(maxResults, '') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2674,7 +2674,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.listOAuthIdpConfigs(maxResults, nextPageToken) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2711,7 +2711,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.deleteOAuthIdpConfig(invalidProviderId as any) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2731,7 +2731,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.deleteOAuthIdpConfig(providerId) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2785,7 +2785,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createOAuthIdpConfig(invalidOptions) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2802,7 +2802,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createOAuthIdpConfig(configOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2823,7 +2823,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createOAuthIdpConfig(configOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2930,7 +2930,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.updateOAuthIdpConfig(invalidProviderId as any, configOptions) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2948,7 +2948,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.updateOAuthIdpConfig(providerId, invalidOptions) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2966,7 +2966,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.updateOAuthIdpConfig(providerId, configOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -2988,7 +2988,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.updateOAuthIdpConfig(providerId, configOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3027,7 +3027,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getInboundSamlConfig(invalidProviderId as any) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3047,7 +3047,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getInboundSamlConfig(providerId) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3126,7 +3126,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.listInboundSamlConfigs(101, nextPageToken) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3140,7 +3140,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.listInboundSamlConfigs(maxResults, '') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3163,7 +3163,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.listInboundSamlConfigs(maxResults, nextPageToken) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3198,7 +3198,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.deleteInboundSamlConfig(invalidProviderId as any) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3218,7 +3218,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.deleteInboundSamlConfig(providerId) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3286,7 +3286,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createInboundSamlConfig(invalidOptions) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3303,7 +3303,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createInboundSamlConfig(configOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3324,7 +3324,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.createInboundSamlConfig(configOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3474,7 +3474,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.updateInboundSamlConfig(invalidProviderId as any, configOptions) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3492,7 +3492,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.updateInboundSamlConfig(providerId, invalidOptions) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3510,7 +3510,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.updateInboundSamlConfig(providerId, configOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3532,7 +3532,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.updateInboundSamlConfig(providerId, configOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3570,7 +3570,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.getTenant(invalidTenantId as any) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3590,7 +3590,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.getTenant(tenantId) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3669,7 +3669,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.listTenants(1001, nextPageToken) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3683,7 +3683,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.listTenants(maxResults, '') - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3706,7 +3706,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.listTenants(maxResults, nextPageToken) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3740,7 +3740,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.deleteTenant(invalidTenantId as any) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3760,7 +3760,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.deleteTenant(tenantId) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3810,7 +3810,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.createTenant(invalidOptions) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3827,7 +3827,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.createTenant(tenantOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3847,7 +3847,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.createTenant(tenantOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3871,7 +3871,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.createTenant(tenantOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3961,7 +3961,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.updateTenant(invalidTenantId as any, tenantOptions) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3979,7 +3979,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.updateTenant(tenantId, invalidOptions) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -3997,7 +3997,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.updateTenant(tenantId, tenantOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -4019,7 +4019,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.updateTenant(tenantId, tenantOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); @@ -4045,7 +4045,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.updateTenant(tenantId, tenantOptions) - .then((resp) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { expect(error).to.deep.equal(expectedError); diff --git a/test/unit/auth/auth.spec.ts b/test/unit/auth/auth.spec.ts index 2de8247a8b..fc75b0d2dc 100755 --- a/test/unit/auth/auth.spec.ts +++ b/test/unit/auth/auth.spec.ts @@ -524,7 +524,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(getUserStub); // Verify ID token while checking if revoked. return auth.verifyIdToken(mockIdToken, true) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -561,7 +561,7 @@ AUTH_CONFIGS.forEach((testConfig) => { // Verify ID token while checking if revoked. // This should fail with the underlying RPC error. return auth.verifyIdToken(mockIdToken, true) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -603,7 +603,7 @@ AUTH_CONFIGS.forEach((testConfig) => { // Verify ID token while checking if revoked. // This should fail with the underlying token generator verifyIdToken error. return auth.verifyIdToken(mockIdToken, true) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm expected error returned. @@ -621,7 +621,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .returns(Promise.resolve(getDecodedIdToken(uid, validSince))); // Verify ID token. return auth.verifyIdToken(mockIdToken) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm expected error returned. @@ -638,7 +638,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .returns(Promise.resolve(getDecodedIdToken(uid, validSince, 'otherTenantId'))); // Verify ID token. return auth.verifyIdToken(mockIdToken) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm expected error returned. @@ -768,7 +768,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(getUserStub); // Verify session cookie while checking if revoked. return auth.verifySessionCookie(mockSessionCookie, true) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -805,7 +805,7 @@ AUTH_CONFIGS.forEach((testConfig) => { // Verify session cookie while checking if revoked. // This should fail with the underlying RPC error. return auth.verifySessionCookie(mockSessionCookie, true) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -847,7 +847,7 @@ AUTH_CONFIGS.forEach((testConfig) => { // Verify session cookie while checking if revoked. // This should fail with the underlying token generator verifySessionCookie error. return auth.verifySessionCookie(mockSessionCookie, true) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm expected error returned. @@ -865,7 +865,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .returns(Promise.resolve(getDecodedSessionCookie(uid, validSince))); // Verify session cookie token. return auth.verifySessionCookie(mockSessionCookie) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm expected error returned. @@ -882,7 +882,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .returns(Promise.resolve(getDecodedSessionCookie(uid, validSince, 'otherTenantId'))); // Verify session cookie token. return auth.verifySessionCookie(mockSessionCookie) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm expected error returned. @@ -960,7 +960,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(stub); return auth.getUser(uid) - .then((userRecord) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1039,7 +1039,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(stub); return auth.getUserByEmail(email) - .then((userRecord) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1119,7 +1119,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(stub); return auth.getUserByPhoneNumber(phoneNumber) - .then((userRecord) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1291,7 +1291,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(createUserStub); return auth.createUser(propertiesToCreate) - .then((userRecord) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1312,7 +1312,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(createUserStub); stubs.push(getUserStub); return auth.createUser(propertiesToCreate) - .then((userRecord) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1333,7 +1333,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(createUserStub); stubs.push(getUserStub); return auth.createUser(propertiesToCreate) - .then((userRecord) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1445,7 +1445,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(updateUserStub); return auth.updateUser(uid, propertiesToEdit) - .then((userRecord) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1465,7 +1465,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(updateUserStub); stubs.push(getUserStub); return auth.updateUser(uid, propertiesToEdit) - .then((userRecord) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1709,7 +1709,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(downloadAccountStub); return auth.listUsers(maxResult, pageToken) - .then((results) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1789,7 +1789,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(revokeRefreshTokensStub); return auth.revokeRefreshTokens(uid) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -1870,7 +1870,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedServerError); stubs.push(uploadAccountStub); return auth.importUsers(users, options) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2055,7 +2055,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(createSessionCookieStub); return auth.createSessionCookie(idToken, options) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2073,7 +2073,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .returns(Promise.reject(expectedError)); stubs.push(verifyIdTokenStub); return auth.createSessionCookie(idToken, options) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2191,7 +2191,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(getEmailActionLinkStub); return (auth as any)[emailActionFlow.api](email, actionCodeSettings) - .then((actualLink: string) => { + .then(() => { throw new Error('Unexpected success'); }, (error: any) => { // Confirm underlying API called with expected parameters. @@ -2281,7 +2281,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(stub); return (auth as Auth).getProviderConfig(providerId) - .then((config) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2335,7 +2335,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(stub); return (auth as Auth).getProviderConfig(providerId) - .then((config) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2469,7 +2469,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(listConfigsStub); return auth.listProviderConfigs(filterOptions) - .then((results) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2564,7 +2564,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(listConfigsStub); return auth.listProviderConfigs(filterOptions) - .then((results) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2643,7 +2643,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(stub); return (auth as Auth).deleteProviderConfig(providerId) - .then((config) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2678,7 +2678,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .rejects(expectedError); stubs.push(stub); return (auth as Auth).deleteProviderConfig(providerId) - .then((config) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2789,7 +2789,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(updateConfigStub); return auth.updateProviderConfig(providerId, configOptions) - .then((actualConfig) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2855,7 +2855,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(updateConfigStub); return auth.updateProviderConfig(providerId, configOptions) - .then((actualConfig) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -2955,7 +2955,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(createConfigStub); return (auth as Auth).createProviderConfig(configOptions) - .then((actualConfig) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -3022,7 +3022,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(createConfigStub); return (auth as Auth).createProviderConfig(configOptions) - .then((actualConfig) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. diff --git a/test/unit/auth/tenant-manager.spec.ts b/test/unit/auth/tenant-manager.spec.ts index c39a611f35..82f89599d9 100644 --- a/test/unit/auth/tenant-manager.spec.ts +++ b/test/unit/auth/tenant-manager.spec.ts @@ -158,7 +158,7 @@ describe('TenantManager', () => { .returns(Promise.reject(expectedError)); stubs.push(stub); return tenantManager.getTenant(tenantId) - .then((tenant) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -290,7 +290,7 @@ describe('TenantManager', () => { .returns(Promise.reject(expectedError)); stubs.push(listTenantsStub); return tenantManager.listTenants(maxResult, pageToken) - .then((results) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -365,7 +365,7 @@ describe('TenantManager', () => { .returns(Promise.reject(expectedError)); stubs.push(stub); return tenantManager.deleteTenant(tenantId) - .then((userRecord) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -456,7 +456,7 @@ describe('TenantManager', () => { .returns(Promise.reject(expectedError)); stubs.push(createTenantStub); return tenantManager.createTenant(tenantOptions) - .then((actualTenant) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. @@ -565,7 +565,7 @@ describe('TenantManager', () => { .returns(Promise.reject(expectedError)); stubs.push(updateTenantStub); return tenantManager.updateTenant(tenantId, tenantOptions) - .then((actualTenant) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. diff --git a/test/unit/auth/user-import-builder.spec.ts b/test/unit/auth/user-import-builder.spec.ts index 68685a48ea..91cccaf178 100644 --- a/test/unit/auth/user-import-builder.spec.ts +++ b/test/unit/auth/user-import-builder.spec.ts @@ -32,7 +32,7 @@ const expect = chai.expect; describe('UserImportBuilder', () => { const nowString = new Date().toUTCString(); - const userRequestValidator: ValidatorFunction = (request) => { + const userRequestValidator: ValidatorFunction = () => { // Do not throw an error. }; const userRequestValidatorWithError: ValidatorFunction = (request) => { diff --git a/test/unit/database/database.spec.ts b/test/unit/database/database.spec.ts index a4dc3c7ca1..54d59432a3 100644 --- a/test/unit/database/database.spec.ts +++ b/test/unit/database/database.spec.ts @@ -152,8 +152,8 @@ describe('Database', () => { const rulesPath = '.settings/rules.json'; function callParamsForGet( - strict: boolean = false, - url: string = `https://databasename.firebaseio.com/${rulesPath}`, + strict = false, + url = `https://databasename.firebaseio.com/${rulesPath}`, ): HttpRequestConfig { const params: HttpRequestConfig = { @@ -305,7 +305,7 @@ describe('Database', () => { function callParamsForPut( data: string | Buffer | object, - url: string = `https://databasename.firebaseio.com/${rulesPath}`, + url = `https://databasename.firebaseio.com/${rulesPath}`, ): HttpRequestConfig { return { diff --git a/test/unit/instance-id/instance-id-request.spec.ts b/test/unit/instance-id/instance-id-request.spec.ts index 4f4186adf1..7515f9cd7e 100644 --- a/test/unit/instance-id/instance-id-request.spec.ts +++ b/test/unit/instance-id/instance-id-request.spec.ts @@ -36,7 +36,7 @@ chai.use(chaiAsPromised); const expect = chai.expect; describe('FirebaseInstanceIdRequestHandler', () => { - const projectId: string = 'project_id'; + const projectId = 'project_id'; const mockAccessToken: string = utils.generateRandomAccessToken(); let stubs: sinon.SinonStub[] = []; let getTokenStub: sinon.SinonStub; diff --git a/test/unit/instance-id/instance-id.spec.ts b/test/unit/instance-id/instance-id.spec.ts index c3dc2fdb81..db4a9dcb10 100644 --- a/test/unit/instance-id/instance-id.spec.ts +++ b/test/unit/instance-id/instance-id.spec.ts @@ -164,7 +164,7 @@ describe('InstanceId', () => { .returns(Promise.resolve(null)); stubs.push(stub); return iid.deleteInstanceId(testInstanceId) - .then((result) => { + .then(() => { // Confirm underlying API called with expected parameters. expect(stub).to.have.been.calledOnce.and.calledWith(testInstanceId); }); @@ -176,7 +176,7 @@ describe('InstanceId', () => { .returns(Promise.reject(expectedError)); stubs.push(stub); return iid.deleteInstanceId(testInstanceId) - .then((result) => { + .then(() => { throw new Error('Unexpected success'); }, (error) => { // Confirm underlying API called with expected parameters. diff --git a/test/unit/messaging/batch-requests.spec.ts b/test/unit/messaging/batch-requests.spec.ts index ae5b505d71..9bc11532a0 100644 --- a/test/unit/messaging/batch-requests.spec.ts +++ b/test/unit/messaging/batch-requests.spec.ts @@ -16,7 +16,6 @@ 'use strict'; -import * as _ from 'lodash'; import * as chai from 'chai'; import * as sinon from 'sinon'; import * as sinonChai from 'sinon-chai'; @@ -50,14 +49,14 @@ function getParsedPartData(obj: object): string { function createMultipartResponse(success: object[], failures: object[] = []): HttpResponse { const multipart: Buffer[] = []; success.forEach((part) => { - let payload: string = ''; + let payload = ''; payload += `HTTP/1.1 200 OK\r\n`; payload += `Content-type: application/json\r\n\r\n`; payload += `${JSON.stringify(part)}\r\n`; multipart.push(Buffer.from(payload, 'utf-8')); }); failures.forEach((part) => { - let payload: string = ''; + let payload = ''; payload += `HTTP/1.1 500 Internal Server Error\r\n`; payload += `Content-type: application/json\r\n\r\n`; payload += `${JSON.stringify(part)}\r\n`; diff --git a/test/unit/messaging/messaging.spec.ts b/test/unit/messaging/messaging.spec.ts index 558a5b706d..286f5d2702 100644 --- a/test/unit/messaging/messaging.spec.ts +++ b/test/unit/messaging/messaging.spec.ts @@ -2776,9 +2776,9 @@ describe('Messaging', () => { const whitelistedOptionsKeys: { [name: string]: { - type: string, - underscoreCasedKey?: string, - }, + type: string; + underscoreCasedKey?: string; + }; } = { dryRun: { type: 'boolean', underscoreCasedKey: 'dry_run' }, priority: { type: 'string' }, @@ -2791,7 +2791,7 @@ describe('Messaging', () => { _.forEach(whitelistedOptionsKeys, ({ type, underscoreCasedKey }, camelCasedKey) => { let validValue: any; - let invalidValues: Array<{value: any, text: string}>; + let invalidValues: Array<{value: any; text: string}>; if (type === 'string') { invalidValues = [ { value: true, text: 'non-string' }, diff --git a/test/unit/project-management/project-management-api-request.spec.ts b/test/unit/project-management/project-management-api-request.spec.ts index 2ae4f1c228..59d91b69f5 100644 --- a/test/unit/project-management/project-management-api-request.spec.ts +++ b/test/unit/project-management/project-management-api-request.spec.ts @@ -40,18 +40,18 @@ const VALID_SHA_1_HASH = '0123456789abcdefABCDEF012345678901234567'; describe('ProjectManagementRequestHandler', () => { const HOST = 'firebase.googleapis.com'; const PORT = 443; - const PROJECT_RESOURCE_NAME: string = 'projects/test-project-id'; - const APP_ID: string = 'test-app-id'; - const APP_ID_ANDROID: string = 'test-android-app-id'; - const APP_ID_IOS: string = 'test-ios-app-id'; - const ANDROID_APP_RESOURCE_NAME: string = `projects/-/androidApp/${APP_ID}`; - const IOS_APP_RESOURCE_NAME: string = `projects/-/iosApp/${APP_ID}`; - const PACKAGE_NAME: string = 'test-package-name'; - const BUNDLE_ID: string = 'test-bundle-id'; - const DISPLAY_NAME: string = 'test-display-name'; - const DISPLAY_NAME_ANDROID: string = 'test-display-name-android'; - const DISPLAY_NAME_IOS: string = 'test-display-name-ios'; - const OPERATION_RESOURCE_NAME: string = 'test-operation-resource-name'; + const PROJECT_RESOURCE_NAME = 'projects/test-project-id'; + const APP_ID = 'test-app-id'; + const APP_ID_ANDROID = 'test-android-app-id'; + const APP_ID_IOS = 'test-ios-app-id'; + const ANDROID_APP_RESOURCE_NAME = `projects/-/androidApp/${APP_ID}`; + const IOS_APP_RESOURCE_NAME = `projects/-/iosApp/${APP_ID}`; + const PACKAGE_NAME = 'test-package-name'; + const BUNDLE_ID = 'test-bundle-id'; + const DISPLAY_NAME = 'test-display-name'; + const DISPLAY_NAME_ANDROID = 'test-display-name-android'; + const DISPLAY_NAME_IOS = 'test-display-name-ios'; + const OPERATION_RESOURCE_NAME = 'test-operation-resource-name'; const mockAccessToken: string = utils.generateRandomAccessToken(); let stubs: sinon.SinonStub[] = []; diff --git a/test/unit/project-management/project-management.spec.ts b/test/unit/project-management/project-management.spec.ts index aecfb324bb..bcd02f6d71 100644 --- a/test/unit/project-management/project-management.spec.ts +++ b/test/unit/project-management/project-management.spec.ts @@ -31,12 +31,12 @@ import { AppPlatform, AppMetadata } from '../../../src/project-management/app-me const expect = chai.expect; const APP_ID = 'test-app-id'; -const APP_ID_ANDROID: string = 'test-app-id-android'; -const APP_ID_IOS: string = 'test-app-id-ios'; +const APP_ID_ANDROID = 'test-app-id-android'; +const APP_ID_IOS = 'test-app-id-ios'; const PACKAGE_NAME = 'test-package-name'; const BUNDLE_ID = 'test-bundle-id'; -const DISPLAY_NAME_ANDROID: string = 'test-display-name-android'; -const DISPLAY_NAME_IOS: string = 'test-display-name-ios'; +const DISPLAY_NAME_ANDROID = 'test-display-name-android'; +const DISPLAY_NAME_IOS = 'test-display-name-ios'; const EXPECTED_ERROR = new FirebaseProjectManagementError('internal-error', 'message'); const RESOURCE_NAME = 'projects/test/resources-name'; const RESOURCE_NAME_ANDROID = 'projects/test/resources-name:android'; diff --git a/test/unit/security-rules/security-rules.spec.ts b/test/unit/security-rules/security-rules.spec.ts index e10865d823..45e1f98a87 100644 --- a/test/unit/security-rules/security-rules.spec.ts +++ b/test/unit/security-rules/security-rules.spec.ts @@ -36,9 +36,9 @@ describe('SecurityRules', () => { // to allow easier use from within the tests. An improvement would be to // alter this into a helper that creates customized RulesetResponses based // on the needs of the test, as that would ensure type-safety. - name: string, - createTime: string, - source: object | null, + name: string; + createTime: string; + source: object | null; } = { name: 'projects/test-project/rulesets/foo', createTime: '2019-03-08T23:45:23.288047Z', diff --git a/test/unit/utils.ts b/test/unit/utils.ts index 794b85bf46..6f6dac1a1a 100644 --- a/test/unit/utils.ts +++ b/test/unit/utils.ts @@ -71,7 +71,7 @@ export function stubGetAccessToken(accessToken?: string, app?: FirebaseApp): sin * @param {*=} headers HTTP headers to be included in the ersponse. * @return {HttpResponse} An HTTP response object. */ -export function responseFrom(data: object | string, status: number = 200, headers: any = {}): HttpResponse { +export function responseFrom(data: object | string, status = 200, headers: any = {}): HttpResponse { let responseData: any; let responseText: string; if (typeof data === 'object') { @@ -94,6 +94,6 @@ export function responseFrom(data: object | string, status: number = 200, header }; } -export function errorFrom(data: any, status: number = 500): HttpError { +export function errorFrom(data: any, status = 500): HttpError { return new HttpError(responseFrom(data, status)); } diff --git a/test/unit/utils/api-request.spec.ts b/test/unit/utils/api-request.spec.ts index c20073bab4..7a04df15a6 100644 --- a/test/unit/utils/api-request.spec.ts +++ b/test/unit/utils/api-request.spec.ts @@ -1402,8 +1402,8 @@ describe('ApiSettings', () => { describe('with set properties', () => { const apiSettings: ApiSettings = new ApiSettings('getAccountInfo', 'GET'); // Set all apiSettings properties. - const requestValidator: ApiCallbackFunction = (request) => undefined; - const responseValidator: ApiCallbackFunction = (response) => undefined; + const requestValidator: ApiCallbackFunction = () => undefined; + const responseValidator: ApiCallbackFunction = () => undefined; apiSettings.setRequestValidator(requestValidator); apiSettings.setResponseValidator(responseValidator); it('should return the correct requestValidator', () => { diff --git a/test/unit/utils/validator.spec.ts b/test/unit/utils/validator.spec.ts index 00a0ea6c2b..42f4882731 100644 --- a/test/unit/utils/validator.spec.ts +++ b/test/unit/utils/validator.spec.ts @@ -67,10 +67,12 @@ describe('isArray()', () => { }); it('should return true given an empty array created from Array constructor', () => { + // eslint-disable-next-line @typescript-eslint/no-array-constructor expect(isArray(new Array())).to.be.true; }); it('should return true given a non-empty array created from Array constructor', () => { + // eslint-disable-next-line @typescript-eslint/no-array-constructor expect(isArray(new Array(1, 2, 3))).to.be.true; }); }); @@ -96,10 +98,12 @@ describe('isNonEmptyArray()', () => { }); it('should return false given an empty array created from Array constructor', () => { + // eslint-disable-next-line @typescript-eslint/no-array-constructor expect(isNonEmptyArray(new Array())).to.be.false; }); it('should return true given a non-empty array created from Array constructor', () => { + // eslint-disable-next-line @typescript-eslint/no-array-constructor expect(isNonEmptyArray(new Array(1, 2, 3))).to.be.true; }); });