Skip to content

chore: Add ESLint rule for curly braces, apply fix #939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {

// Required checks
'indent': ['error', 2],
"object-curly-spacing": [2, "always"],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
Expand Down
2 changes: 1 addition & 1 deletion src/auth/action-code-settings-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as validator from '../utils/validator';
import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error';
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';

/** Defines the ActionCodeSettings interface. */
export interface ActionCodeSettings {
Expand Down
40 changes: 20 additions & 20 deletions src/auth/auth-api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@

import * as validator from '../utils/validator';

import {deepCopy, deepExtend} from '../utils/deep-copy';
import { deepCopy, deepExtend } from '../utils/deep-copy';
import {
UserIdentifier, isUidIdentifier, isEmailIdentifier, isPhoneIdentifier,
isProviderIdentifier, UidIdentifier, EmailIdentifier, PhoneIdentifier,
ProviderIdentifier,
} from './identifier';
import {FirebaseApp} from '../firebase-app';
import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error';
import { FirebaseApp } from '../firebase-app';
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';
import {
ApiSettings, AuthorizedHttpClient, HttpRequestConfig, HttpError,
} from '../utils/api-request';
import {CreateRequest, UpdateRequest} from './user-record';
import { CreateRequest, UpdateRequest } from './user-record';
import {
UserImportBuilder, UserImportOptions, UserImportRecord,
UserImportResult, AuthFactorInfo, convertMultiFactorInfoToServerFormat,
} from './user-import-builder';
import * as utils from '../utils/index';
import {ActionCodeSettings, ActionCodeSettingsBuilder} from './action-code-settings-builder';
import { ActionCodeSettings, ActionCodeSettingsBuilder } from './action-code-settings-builder';
import {
SAMLConfig, OIDCConfig, OIDCConfigServerResponse, SAMLConfigServerResponse,
OIDCConfigServerRequest, SAMLConfigServerRequest, AuthProviderConfig,
OIDCUpdateAuthProviderRequest, SAMLUpdateAuthProviderRequest,
} from './auth-config';
import {Tenant, TenantOptions, TenantServerResponse} from './tenant';
import { Tenant, TenantOptions, TenantServerResponse } from './tenant';


/** Firebase Auth request header. */
Expand Down Expand Up @@ -195,7 +195,7 @@ class TenantAwareAuthResourceUrlBuilder extends AuthResourceUrlBuilder {
public getUrl(api?: string, params?: object): Promise<string> {
return super.getUrl(api, params)
.then((url) => {
return utils.formatString(url, {tenantId: this.tenantId});
return utils.formatString(url, { tenantId: this.tenantId });
});
}
}
Expand Down Expand Up @@ -1039,7 +1039,7 @@ export abstract class AbstractAuthRequestHandler {
*/
public getAccountInfoByIdentifiers(identifiers: UserIdentifier[]): Promise<object> {
if (identifiers.length === 0) {
return Promise.resolve({users: []});
return Promise.resolve({ users: [] });
} else if (identifiers.length > MAX_GET_ACCOUNTS_BATCH_SIZE) {
throw new FirebaseAuthError(
AuthClientErrorCode.MAXIMUM_USER_COUNT_EXCEEDED,
Expand Down Expand Up @@ -1428,7 +1428,7 @@ export abstract class AbstractAuthRequestHandler {
public getEmailActionLink(
requestType: string, email: string,
actionCodeSettings?: ActionCodeSettings): Promise<string> {
let request = {requestType, email, returnOobLink: true};
let request = { requestType, email, returnOobLink: true };
// ActionCodeSettings required for email link sign-in to determine the url where the sign-in will
// be completed.
if (typeof actionCodeSettings === 'undefined' && requestType === 'EMAIL_SIGNIN') {
Expand Down Expand Up @@ -1464,7 +1464,7 @@ export abstract class AbstractAuthRequestHandler {
if (!OIDCConfig.isProviderId(providerId)) {
return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID));
}
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), GET_OAUTH_IDP_CONFIG, {}, {providerId});
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), GET_OAUTH_IDP_CONFIG, {}, { providerId });
}

/**
Expand Down Expand Up @@ -1510,7 +1510,7 @@ export abstract class AbstractAuthRequestHandler {
if (!OIDCConfig.isProviderId(providerId)) {
return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID));
}
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_OAUTH_IDP_CONFIG, {}, {providerId})
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_OAUTH_IDP_CONFIG, {}, { providerId })
.then(() => {
// Return nothing.
});
Expand All @@ -1532,7 +1532,7 @@ export abstract class AbstractAuthRequestHandler {
return Promise.reject(e);
}
const providerId = options.providerId;
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), CREATE_OAUTH_IDP_CONFIG, request, {providerId})
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), CREATE_OAUTH_IDP_CONFIG, request, { providerId })
.then((response: any) => {
if (!OIDCConfig.getProviderIdFromResourceName(response.name)) {
throw new FirebaseAuthError(
Expand Down Expand Up @@ -1565,7 +1565,7 @@ export abstract class AbstractAuthRequestHandler {
}
const updateMask = utils.generateUpdateMask(request);
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), UPDATE_OAUTH_IDP_CONFIG, request,
{providerId, updateMask: updateMask.join(',')})
{ providerId, updateMask: updateMask.join(',') })
.then((response: any) => {
if (!OIDCConfig.getProviderIdFromResourceName(response.name)) {
throw new FirebaseAuthError(
Expand All @@ -1586,7 +1586,7 @@ export abstract class AbstractAuthRequestHandler {
if (!SAMLConfig.isProviderId(providerId)) {
return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID));
}
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), GET_INBOUND_SAML_CONFIG, {}, {providerId});
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), GET_INBOUND_SAML_CONFIG, {}, { providerId });
}

/**
Expand Down Expand Up @@ -1632,7 +1632,7 @@ export abstract class AbstractAuthRequestHandler {
if (!SAMLConfig.isProviderId(providerId)) {
return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID));
}
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_INBOUND_SAML_CONFIG, {}, {providerId})
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_INBOUND_SAML_CONFIG, {}, { providerId })
.then(() => {
// Return nothing.
});
Expand All @@ -1655,7 +1655,7 @@ export abstract class AbstractAuthRequestHandler {
}
const providerId = options.providerId;
return this.invokeRequestHandler(
this.getProjectConfigUrlBuilder(), CREATE_INBOUND_SAML_CONFIG, request, {providerId})
this.getProjectConfigUrlBuilder(), CREATE_INBOUND_SAML_CONFIG, request, { providerId })
.then((response: any) => {
if (!SAMLConfig.getProviderIdFromResourceName(response.name)) {
throw new FirebaseAuthError(
Expand Down Expand Up @@ -1688,7 +1688,7 @@ export abstract class AbstractAuthRequestHandler {
}
const updateMask = utils.generateUpdateMask(request);
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), UPDATE_INBOUND_SAML_CONFIG, request,
{providerId, updateMask: updateMask.join(',')})
{ providerId, updateMask: updateMask.join(',') })
.then((response: any) => {
if (!SAMLConfig.getProviderIdFromResourceName(response.name)) {
throw new FirebaseAuthError(
Expand Down Expand Up @@ -1893,7 +1893,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
if (!validator.isNonEmptyString(tenantId)) {
return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_TENANT_ID));
}
return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, GET_TENANT, {}, {tenantId})
return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, GET_TENANT, {}, { tenantId })
.then((response: any) => {
return response as TenantServerResponse;
});
Expand Down Expand Up @@ -1943,7 +1943,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
if (!validator.isNonEmptyString(tenantId)) {
return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_TENANT_ID));
}
return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, DELETE_TENANT, {}, {tenantId})
return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, DELETE_TENANT, {}, { tenantId })
.then(() => {
// Return nothing.
});
Expand Down Expand Up @@ -1984,7 +1984,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
const request = Tenant.buildServerRequest(tenantOptions, false);
const updateMask = utils.generateUpdateMask(request);
return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, UPDATE_TENANT, request,
{tenantId, updateMask: updateMask.join(',')})
{ tenantId, updateMask: updateMask.join(',') })
.then((response: any) => {
return response as TenantServerResponse;
});
Expand Down
6 changes: 3 additions & 3 deletions src/auth/auth-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

import * as validator from '../utils/validator';
import {deepCopy} from '../utils/deep-copy';
import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error';
import { deepCopy } from '../utils/deep-copy';
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';


/** The filter interface used for listing provider configurations. */
Expand Down Expand Up @@ -306,7 +306,7 @@ export class SAMLConfig implements SAMLAuthProviderConfig {
};
if (options.x509Certificates) {
for (const cert of (options.x509Certificates || [])) {
request.idpConfig!.idpCertificates!.push({x509Certificate: cert});
request.idpConfig!.idpCertificates!.push({ x509Certificate: cert });
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@
* limitations under the License.
*/

import {UserRecord, CreateRequest, UpdateRequest} from './user-record';
import { UserRecord, CreateRequest, UpdateRequest } from './user-record';
import {
UserIdentifier, isUidIdentifier, isEmailIdentifier, isPhoneIdentifier, isProviderIdentifier,
} from './identifier';
import {FirebaseApp} from '../firebase-app';
import {FirebaseTokenGenerator, cryptoSignerFromApp} from './token-generator';
import { FirebaseApp } from '../firebase-app';
import { FirebaseTokenGenerator, cryptoSignerFromApp } from './token-generator';
import {
AbstractAuthRequestHandler, AuthRequestHandler, TenantAwareAuthRequestHandler,
} from './auth-api-request';
import {AuthClientErrorCode, FirebaseAuthError, ErrorInfo, FirebaseArrayIndexError} from '../utils/error';
import {FirebaseServiceInterface, FirebaseServiceInternalsInterface} from '../firebase-service';
import { AuthClientErrorCode, FirebaseAuthError, ErrorInfo, FirebaseArrayIndexError } from '../utils/error';
import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../firebase-service';
import {
UserImportOptions, UserImportRecord, UserImportResult,
} from './user-import-builder';

import * as utils from '../utils/index';
import * as validator from '../utils/validator';
import { FirebaseTokenVerifier, createSessionCookieVerifier, createIdTokenVerifier } from './token-verifier';
import {ActionCodeSettings} from './action-code-settings-builder';
import { ActionCodeSettings } from './action-code-settings-builder';
import {
AuthProviderConfig, AuthProviderConfigFilter, ListProviderConfigResults, UpdateAuthProviderRequest,
SAMLConfig, OIDCConfig, OIDCConfigServerResponse, SAMLConfigServerResponse,
} from './auth-config';
import {TenantManager} from './tenant-manager';
import { TenantManager } from './tenant-manager';


/**
Expand Down
6 changes: 3 additions & 3 deletions src/auth/credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import fs = require('fs');
import os = require('os');
import path = require('path');

import {AppErrorCodes, FirebaseAppError} from '../utils/error';
import {HttpClient, HttpRequestConfig, HttpError, HttpResponse} from '../utils/api-request';
import {Agent} from 'http';
import { AppErrorCodes, FirebaseAppError } from '../utils/error';
import { HttpClient, HttpRequestConfig, HttpError, HttpResponse } from '../utils/api-request';
import { Agent } from 'http';
import * as util from '../utils/validator';

const GOOGLE_TOKEN_AUDIENCE = 'https://accounts.google.com/o/oauth2/token';
Expand Down
8 changes: 4 additions & 4 deletions src/auth/tenant-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

import {AuthRequestHandler} from './auth-api-request';
import {FirebaseApp} from '../firebase-app';
import {TenantAwareAuth} from './auth';
import { AuthRequestHandler } from './auth-api-request';
import { FirebaseApp } from '../firebase-app';
import { TenantAwareAuth } from './auth';
import {
Tenant, TenantServerResponse, ListTenantsResult, TenantOptions,
} from './tenant';
import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error';
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';
import * as validator from '../utils/validator';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/auth/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as validator from '../utils/validator';
import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error';
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';
import {
EmailSignInConfig, EmailSignInConfigServerRequest, EmailSignInProviderConfig,
} from './auth-config';
Expand Down
6 changes: 3 additions & 3 deletions src/auth/token-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

import { FirebaseApp } from '../firebase-app';
import {ServiceAccountCredential} from './credential';
import {AuthClientErrorCode, FirebaseAuthError } from '../utils/error';
import { ServiceAccountCredential } from './credential';
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';
import { AuthorizedHttpClient, HttpError, HttpRequestConfig, HttpClient } from '../utils/api-request';

import * as validator from '../utils/validator';
Expand Down Expand Up @@ -152,7 +152,7 @@ export class IAMSigner implements CryptoSigner {
const request: HttpRequestConfig = {
method: 'POST',
url: `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${serviceAccount}:signBlob`,
data: {payload: buffer.toString('base64')},
data: { payload: buffer.toString('base64') },
};
return this.httpClient.send(request);
}).then((response: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/auth/token-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {AuthClientErrorCode, FirebaseAuthError, ErrorInfo} from '../utils/error';
import { AuthClientErrorCode, FirebaseAuthError, ErrorInfo } from '../utils/error';

import * as util from '../utils/index';
import * as validator from '../utils/validator';
Expand Down
6 changes: 3 additions & 3 deletions src/auth/user-import-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import {deepCopy, deepExtend} from '../utils/deep-copy';
import { deepCopy, deepExtend } from '../utils/deep-copy';
import * as utils from '../utils';
import * as validator from '../utils/validator';
import {AuthClientErrorCode, FirebaseAuthError, FirebaseArrayIndexError} from '../utils/error';
import { AuthClientErrorCode, FirebaseAuthError, FirebaseArrayIndexError } from '../utils/error';

/** Firebase Auth supported hashing algorithms for import operations. */
export type HashAlgorithmType = 'SCRYPT' | 'STANDARD_SCRYPT' | 'HMAC_SHA512' |
Expand Down Expand Up @@ -333,7 +333,7 @@ export class UserImportBuilder {
const users = this.validatedUsers.map((user) => {
return deepCopy(user);
});
return deepExtend({users}, deepCopy(this.validatedOptions)) as UploadAccountRequest;
return deepExtend({ users }, deepCopy(this.validatedOptions)) as UploadAccountRequest;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/auth/user-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import {deepCopy} from '../utils/deep-copy';
import {isNonNullObject} from '../utils/validator';
import { deepCopy } from '../utils/deep-copy';
import { isNonNullObject } from '../utils/validator';
import * as utils from '../utils';
import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error';
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';

/**
* 'REDACTED', encoded as a base64 string.
Expand Down
12 changes: 6 additions & 6 deletions src/database/database.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {URL} from 'url';
import { URL } from 'url';
import * as path from 'path';

import {FirebaseApp} from '../firebase-app';
import {FirebaseDatabaseError, AppErrorCodes, FirebaseAppError} from '../utils/error';
import {FirebaseServiceInterface, FirebaseServiceInternalsInterface} from '../firebase-service';
import {Database} from '@firebase/database';
import { FirebaseApp } from '../firebase-app';
import { FirebaseDatabaseError, AppErrorCodes, FirebaseAppError } from '../utils/error';
import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../firebase-service';
import { Database } from '@firebase/database';

import * as validator from '../utils/validator';
import { AuthorizedHttpClient, HttpRequestConfig, HttpError } from '../utils/api-request';
Expand Down Expand Up @@ -160,7 +160,7 @@ class DatabaseRulesClient {
const req: HttpRequestConfig = {
method: 'GET',
url: this.dbUrl,
data: {format: 'strict'},
data: { format: 'strict' },
};
return this.httpClient.send(req)
.then((resp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/default-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {FirebaseNamespace} from './firebase-namespace';
import { FirebaseNamespace } from './firebase-namespace';

const firebaseAdmin = new FirebaseNamespace();

Expand Down
Loading