Skip to content

chore: Enabled quotes rule in eslint config #1067

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 3 commits into from
Oct 21, 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
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = {
'ignoreUrls': true
}
],
"object-curly-spacing": [2, "always"],
'object-curly-spacing': [2, 'always'],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
Expand All @@ -54,6 +54,7 @@ module.exports = {
}
],
'no-unused-vars': 'off', // Must be disabled to enable the next rule
'@typescript-eslint/no-unused-vars': ['error']
'@typescript-eslint/no-unused-vars': ['error'],
'quotes': ['error', 'single', {'avoidEscape': true}]
}
};
24 changes: 12 additions & 12 deletions src/auth/auth-api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class AuthResourceUrlBuilder {
constructor(protected app: FirebaseApp, protected version: string = 'v1') {
const emulatorHost = process.env.FIREBASE_AUTH_EMULATOR_HOST;
if (emulatorHost) {
this.urlFormat = utils.formatString(FIREBASE_AUTH_EMULATOR_BASE_URL_FORMAT, {
this.urlFormat = utils.formatString(FIREBASE_AUTH_EMULATOR_BASE_URL_FORMAT, {
host: emulatorHost
});
} else {
Expand Down Expand Up @@ -212,7 +212,7 @@ class TenantAwareAuthResourceUrlBuilder extends AuthResourceUrlBuilder {
super(app, version);
const emulatorHost = process.env.FIREBASE_AUTH_EMULATOR_HOST
if (emulatorHost) {
this.urlFormat = utils.formatString(FIREBASE_AUTH_EMULATOR_TENANT_URL_FORMAT, {
this.urlFormat = utils.formatString(FIREBASE_AUTH_EMULATOR_TENANT_URL_FORMAT, {
host: emulatorHost
});
} else {
Expand Down Expand Up @@ -266,7 +266,7 @@ function validateAuthFactorInfo(request: AuthFactorInfo, writeOperationType: Wri
!validator.isNonEmptyString(request.mfaEnrollmentId)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_UID,
`The second factor "uid" must be a valid non-empty string.`,
'The second factor "uid" must be a valid non-empty string.',
);
}
if (typeof request.displayName !== 'undefined' &&
Expand All @@ -282,7 +282,7 @@ function validateAuthFactorInfo(request: AuthFactorInfo, writeOperationType: Wri
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ENROLLMENT_TIME,
`The second factor "enrollmentTime" for "${authFactorInfoIdentifier}" must be a valid ` +
`UTC date string.`);
'UTC date string.');
}
// Validate required fields depending on second factor type.
if (typeof request.phoneInfo !== 'undefined') {
Expand All @@ -291,14 +291,14 @@ function validateAuthFactorInfo(request: AuthFactorInfo, writeOperationType: Wri
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_PHONE_NUMBER,
`The second factor "phoneNumber" for "${authFactorInfoIdentifier}" must be a non-empty ` +
`E.164 standard compliant identifier string.`);
'E.164 standard compliant identifier string.');
}
} else {
// Invalid second factor. For example, a phone second factor may have been provided without
// a phone number. A TOTP based second factor may require a secret key, etc.
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ENROLLED_FACTORS,
`MFAInfo object provided is invalid.`);
'MFAInfo object provided is invalid.');
}
}

Expand Down Expand Up @@ -601,7 +601,7 @@ export const FIREBASE_AUTH_DOWNLOAD_ACCOUNT = new ApiSettings('/accounts:batchGe
request.maxResults > MAX_DOWNLOAD_ACCOUNT_PAGE_SIZE) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`Required "maxResults" must be a positive integer that does not exceed ` +
'Required "maxResults" must be a positive integer that does not exceed ' +
`${MAX_DOWNLOAD_ACCOUNT_PAGE_SIZE}.`,
);
}
Expand Down Expand Up @@ -742,14 +742,14 @@ export const FIREBASE_AUTH_SIGN_UP_NEW_USER = new ApiSettings('/accounts', 'POST
if (typeof request.customAttributes !== 'undefined') {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`"customAttributes" cannot be set when creating a new user.`,
'"customAttributes" cannot be set when creating a new user.',
);
}
// signupNewUser does not support validSince.
if (typeof request.validSince !== 'undefined') {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`"validSince" cannot be set when creating a new user.`,
'"validSince" cannot be set when creating a new user.',
);
}
// Throw error when tenantId is passed in POST body.
Expand Down Expand Up @@ -852,7 +852,7 @@ const LIST_OAUTH_IDP_CONFIGS = new ApiSettings('/oauthIdpConfigs', 'GET')
request.pageSize > MAX_LIST_PROVIDER_CONFIGURATION_PAGE_SIZE) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`Required "maxResults" must be a positive integer that does not exceed ` +
'Required "maxResults" must be a positive integer that does not exceed ' +
`${MAX_LIST_PROVIDER_CONFIGURATION_PAGE_SIZE}.`,
);
}
Expand Down Expand Up @@ -915,7 +915,7 @@ const LIST_INBOUND_SAML_CONFIGS = new ApiSettings('/inboundSamlConfigs', 'GET')
request.pageSize > MAX_LIST_PROVIDER_CONFIGURATION_PAGE_SIZE) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`Required "maxResults" must be a positive integer that does not exceed ` +
'Required "maxResults" must be a positive integer that does not exceed ' +
`${MAX_LIST_PROVIDER_CONFIGURATION_PAGE_SIZE}.`,
);
}
Expand Down Expand Up @@ -1865,7 +1865,7 @@ const LIST_TENANTS = new ApiSettings('/tenants', 'GET')
request.pageSize > MAX_LIST_TENANT_PAGE_SIZE) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`Required "maxResults" must be a positive non-zero number that does not exceed ` +
'Required "maxResults" must be a positive non-zero number that does not exceed ' +
`the allowed ${MAX_LIST_TENANT_PAGE_SIZE}.`,
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ export class BaseAuth<T extends AbstractAuthRequestHandler> implements BaseAuthI
return Promise.reject(
new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`"AuthProviderConfigFilter.type" must be either "saml' or "oidc"`));
'"AuthProviderConfigFilter.type" must be either "saml" or "oidc"'));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/auth/token-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ export class IAMSigner implements CryptoSigner {
}).catch((err) => {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_CREDENTIAL,
`Failed to determine service account. Make sure to initialize ` +
`the SDK with a service account credential. Alternatively specify a service ` +
'Failed to determine service account. Make sure to initialize ' +
'the SDK with a service account credential. Alternatively specify a service ' +
`account with iam.serviceAccounts.signBlob permission. Original error: ${err}`,
);
});
Expand Down
36 changes: 18 additions & 18 deletions src/auth/token-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,47 +83,47 @@ export class FirebaseTokenVerifier {
if (!validator.isURL(clientCertUrl)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`The provided public client certificate URL is an invalid URL.`,
'The provided public client certificate URL is an invalid URL.',
);
} else if (!validator.isNonEmptyString(algorithm)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`The provided JWT algorithm is an empty string.`,
'The provided JWT algorithm is an empty string.',
);
} else if (!validator.isURL(issuer)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`The provided JWT issuer is an invalid URL.`,
'The provided JWT issuer is an invalid URL.',
);
} else if (!validator.isNonNullObject(tokenInfo)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`The provided JWT information is not an object or null.`,
'The provided JWT information is not an object or null.',
);
} else if (!validator.isURL(tokenInfo.url)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`The provided JWT verification documentation URL is invalid.`,
'The provided JWT verification documentation URL is invalid.',
);
} else if (!validator.isNonEmptyString(tokenInfo.verifyApiName)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`The JWT verify API name must be a non-empty string.`,
'The JWT verify API name must be a non-empty string.',
);
} else if (!validator.isNonEmptyString(tokenInfo.jwtName)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`The JWT public full name must be a non-empty string.`,
'The JWT public full name must be a non-empty string.',
);
} else if (!validator.isNonEmptyString(tokenInfo.shortName)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`The JWT public short name must be a non-empty string.`,
'The JWT public short name must be a non-empty string.',
);
} else if (!validator.isNonNullObject(tokenInfo.expiredErrorCode) || !('code' in tokenInfo.expiredErrorCode)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
`The JWT expiration error code must be a non-null ErrorInfo object.`,
'The JWT expiration error code must be a non-null ErrorInfo object.',
);
}
this.shortNameArticle = tokenInfo.shortName.charAt(0).match(/[aeiou]/i) ? 'an' : 'a';
Expand Down Expand Up @@ -164,7 +164,7 @@ export class FirebaseTokenVerifier {
if (!validator.isNonEmptyString(projectId)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_CREDENTIAL,
`Must initialize app with a cert credential or set your Firebase project ID as the ` +
'Must initialize app with a cert credential or set your Firebase project ID as the ' +
`GOOGLE_CLOUD_PROJECT environment variable to call ${this.tokenInfo.verifyApiName}.`,
);
}
Expand All @@ -177,7 +177,7 @@ export class FirebaseTokenVerifier {
const payload = fullDecodedToken && fullDecodedToken.payload;

const projectIdMatchMessage = ` Make sure the ${this.tokenInfo.shortName} comes from the same ` +
`Firebase project as the service account used to authenticate this SDK.`;
'Firebase project as the service account used to authenticate this SDK.';
const verifyJwtTokenDocsMessage = ` See ${this.tokenInfo.url} ` +
`for details on how to retrieve ${this.shortNameArticle} ${this.tokenInfo.shortName}.`;

Expand All @@ -201,16 +201,16 @@ export class FirebaseTokenVerifier {

errorMessage += verifyJwtTokenDocsMessage;
} else if (header.alg !== this.algorithm) {
errorMessage = `${this.tokenInfo.jwtName} has incorrect algorithm. Expected "` + this.algorithm + `" but got ` +
`"` + header.alg + `".` + verifyJwtTokenDocsMessage;
errorMessage = `${this.tokenInfo.jwtName} has incorrect algorithm. Expected "` + this.algorithm + '" but got ' +
'"' + header.alg + '".' + verifyJwtTokenDocsMessage;
} else if (payload.aud !== projectId) {
errorMessage = `${this.tokenInfo.jwtName} has incorrect "aud" (audience) claim. Expected "` +
projectId + `" but got "` + payload.aud + `".` + projectIdMatchMessage +
projectId + '" but got "' + payload.aud + '".' + projectIdMatchMessage +
verifyJwtTokenDocsMessage;
} else if (payload.iss !== this.issuer + projectId) {
errorMessage = `${this.tokenInfo.jwtName} has incorrect "iss" (issuer) claim. Expected ` +
`"${this.issuer}"` + projectId + `" but got "` +
payload.iss + `".` + projectIdMatchMessage + verifyJwtTokenDocsMessage;
`"${this.issuer}"` + projectId + '" but got "' +
payload.iss + '".' + projectIdMatchMessage + verifyJwtTokenDocsMessage;
} else if (typeof payload.sub !== 'string') {
errorMessage = `${this.tokenInfo.jwtName} has no "sub" (subject) claim.` + verifyJwtTokenDocsMessage;
} else if (payload.sub === '') {
Expand All @@ -236,7 +236,7 @@ export class FirebaseTokenVerifier {
AuthClientErrorCode.INVALID_ARGUMENT,
`${this.tokenInfo.jwtName} has "kid" claim which does not correspond to a known public key. ` +
`Most likely the ${this.tokenInfo.shortName} is expired, so get a fresh token from your ` +
`client app and try again.`,
'client app and try again.',
),
);
} else {
Expand All @@ -257,7 +257,7 @@ export class FirebaseTokenVerifier {
const verifyJwtTokenDocsMessage = ` See ${this.tokenInfo.url} ` +
`for details on how to retrieve ${this.shortNameArticle} ${this.tokenInfo.shortName}.`;
return new Promise((resolve, reject) => {
jwt.verify(jwtToken, publicKey || "", {
jwt.verify(jwtToken, publicKey || '', {
algorithms: [this.algorithm],
}, (error: jwt.VerifyErrors | null, decodedToken: object | undefined) => {
if (error) {
Expand Down
26 changes: 13 additions & 13 deletions src/auth/user-import-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function convertMultiFactorInfoToServerFormat(multiFactorInfo: UpdateMult
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ENROLLMENT_TIME,
`The second factor "enrollmentTime" for "${multiFactorInfo.uid}" must be a valid ` +
`UTC date string.`);
'UTC date string.');
}
}
// Currently only phone second factors are supported.
Expand Down Expand Up @@ -334,14 +334,14 @@ export class UserImportBuilder {
if (!validator.isNonNullObject(options.hash)) {
throw new FirebaseAuthError(
AuthClientErrorCode.MISSING_HASH_ALGORITHM,
`"hash.algorithm" is missing from the provided "UserImportOptions".`,
'"hash.algorithm" is missing from the provided "UserImportOptions".',
);
}
if (typeof options.hash.algorithm === 'undefined' ||
!validator.isNonEmptyString(options.hash.algorithm)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_ALGORITHM,
`"hash.algorithm" must be a string matching the list of supported algorithms.`,
'"hash.algorithm" must be a string matching the list of supported algorithms.',
);
}

Expand All @@ -354,7 +354,7 @@ export class UserImportBuilder {
if (!validator.isBuffer(options.hash.key)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_KEY,
`A non-empty "hash.key" byte buffer must be provided for ` +
'A non-empty "hash.key" byte buffer must be provided for ' +
`hash algorithm ${options.hash.algorithm}.`,
);
}
Expand Down Expand Up @@ -390,7 +390,7 @@ export class UserImportBuilder {
if (isNaN(rounds) || rounds < 0 || rounds > 120000) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_ROUNDS,
`A valid "hash.rounds" number between 0 and 120000 must be provided for ` +
'A valid "hash.rounds" number between 0 and 120000 must be provided for ' +
`hash algorithm ${options.hash.algorithm}.`,
);
}
Expand All @@ -404,31 +404,31 @@ export class UserImportBuilder {
if (!validator.isBuffer(options.hash.key)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_KEY,
`A "hash.key" byte buffer must be provided for ` +
'A "hash.key" byte buffer must be provided for ' +
`hash algorithm ${options.hash.algorithm}.`,
);
}
rounds = getNumberField(options.hash, 'rounds');
if (isNaN(rounds) || rounds <= 0 || rounds > 8) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_ROUNDS,
`A valid "hash.rounds" number between 1 and 8 must be provided for ` +
'A valid "hash.rounds" number between 1 and 8 must be provided for ' +
`hash algorithm ${options.hash.algorithm}.`,
);
}
const memoryCost = getNumberField(options.hash, 'memoryCost');
if (isNaN(memoryCost) || memoryCost <= 0 || memoryCost > 14) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_MEMORY_COST,
`A valid "hash.memoryCost" number between 1 and 14 must be provided for ` +
'A valid "hash.memoryCost" number between 1 and 14 must be provided for ' +
`hash algorithm ${options.hash.algorithm}.`,
);
}
if (typeof options.hash.saltSeparator !== 'undefined' &&
!validator.isBuffer(options.hash.saltSeparator)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_SALT_SEPARATOR,
`"hash.saltSeparator" must be a byte buffer.`,
'"hash.saltSeparator" must be a byte buffer.',
);
}
populatedOptions = {
Expand All @@ -451,31 +451,31 @@ export class UserImportBuilder {
if (isNaN(cpuMemCost)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_MEMORY_COST,
`A valid "hash.memoryCost" number must be provided for ` +
'A valid "hash.memoryCost" number must be provided for ' +
`hash algorithm ${options.hash.algorithm}.`,
);
}
const parallelization = getNumberField(options.hash, 'parallelization');
if (isNaN(parallelization)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_PARALLELIZATION,
`A valid "hash.parallelization" number must be provided for ` +
'A valid "hash.parallelization" number must be provided for ' +
`hash algorithm ${options.hash.algorithm}.`,
);
}
const blockSize = getNumberField(options.hash, 'blockSize');
if (isNaN(blockSize)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_BLOCK_SIZE,
`A valid "hash.blockSize" number must be provided for ` +
'A valid "hash.blockSize" number must be provided for ' +
`hash algorithm ${options.hash.algorithm}.`,
);
}
const dkLen = getNumberField(options.hash, 'derivedKeyLength');
if (isNaN(dkLen)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_DERIVED_KEY_LENGTH,
`A valid "hash.derivedKeyLength" number must be provided for ` +
'A valid "hash.derivedKeyLength" number must be provided for ' +
`hash algorithm ${options.hash.algorithm}.`,
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/firebase-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class FirebaseApp implements app.App {
if (!validator.isNonNullObject(this.options_)) {
throw new FirebaseAppError(
AppErrorCodes.INVALID_APP_OPTIONS,
`Invalid Firebase app options passed as the first argument to initializeApp() for the ` +
'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
`app named "${this.name_}". Options must be a non-null object.`,
);
}
Expand All @@ -261,9 +261,9 @@ export class FirebaseApp implements app.App {
if (typeof credential !== 'object' || credential === null || typeof credential.getAccessToken !== 'function') {
throw new FirebaseAppError(
AppErrorCodes.INVALID_APP_OPTIONS,
`Invalid Firebase app options passed as the first argument to initializeApp() for the ` +
'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
`app named "${this.name_}". The "credential" property must be an object which implements ` +
`the Credential interface.`,
'the Credential interface.',
);
}

Expand Down
Loading