Skip to content

chore: Enabling max-len lint rule #1014

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 1 commit into from
Aug 31, 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
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ module.exports = {
// Required checks
'indent': ['error', 2],
'keyword-spacing': ['error'],
'max-len': [
'error',
{
'code': 120,
'ignoreUrls': true
}
],
"object-curly-spacing": [2, "always"],
'@typescript-eslint/explicit-function-return-type': [
'error',
Expand Down
3 changes: 2 additions & 1 deletion src/auth/auth-api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,8 @@ 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
4 changes: 3 additions & 1 deletion src/credential.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export namespace admin.credential {
* @return A credential authenticated via the
* provided service account that can be used to initialize an app.
*/
function cert(serviceAccountPathOrObject: string | _admin.ServiceAccount, httpAgent?: Agent): admin.credential.Credential;
function cert(
serviceAccountPathOrObject: string | _admin.ServiceAccount,
httpAgent?: Agent): admin.credential.Credential;

/**
* Returns a credential created from the provided refresh token that grants
Expand Down
10 changes: 7 additions & 3 deletions test/integration/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,16 @@ describe('admin.auth', () => {
const firstMultiFactor = userRecord.multiFactor!.enrolledFactors[0];
expect(firstMultiFactor.uid).not.to.be.undefined;
expect(firstMultiFactor.enrollmentTime).not.to.be.undefined;
expect((firstMultiFactor as admin.auth.PhoneMultiFactorInfo).phoneNumber).to.equal(enrolledFactors[0].phoneNumber);
expect((firstMultiFactor as admin.auth.PhoneMultiFactorInfo).phoneNumber).to.equal(
enrolledFactors[0].phoneNumber);
expect(firstMultiFactor.displayName).to.equal(enrolledFactors[0].displayName);
expect(firstMultiFactor.factorId).to.equal(enrolledFactors[0].factorId);
// Confirm second enrolled second factor.
const secondMultiFactor = userRecord.multiFactor!.enrolledFactors[1];
expect(secondMultiFactor.uid).not.to.be.undefined;
expect(secondMultiFactor.enrollmentTime).not.to.be.undefined;
expect((secondMultiFactor as admin.auth.PhoneMultiFactorInfo).phoneNumber).to.equal(enrolledFactors[1].phoneNumber);
expect((secondMultiFactor as admin.auth.PhoneMultiFactorInfo).phoneNumber).to.equal(
enrolledFactors[1].phoneNumber);
expect(secondMultiFactor.displayName).to.equal(enrolledFactors[1].displayName);
expect(secondMultiFactor.factorId).to.equal(enrolledFactors[1].factorId);
});
Expand Down Expand Up @@ -218,7 +220,9 @@ describe('admin.auth', () => {
* the uid, email, and phoneNumber fields. Works with at least UserRecord
* and UserImportRecord instances.
*/
function mapUserRecordsToUidEmailPhones(values: Array<{ uid: string; email?: string; phoneNumber?: string}>): Array<{ uid: string; email?: string; phoneNumber?: string}> {
function mapUserRecordsToUidEmailPhones(
values: Array<{ uid: string; email?: string; phoneNumber?: string}>
): Array<{ uid: string; email?: string; phoneNumber?: string}> {
return values.map((ur) => ({ uid: ur.uid, email: ur.email, phoneNumber: ur.phoneNumber }));
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/remote-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ describe('admin.remoteConfig', () => {
INVALID_JSON_STRINGS.forEach((invalidJson) => {
it(`should throw if the json string is ${JSON.stringify(invalidJson)}`, () => {
expect(() => admin.remoteConfig().createTemplateFromJSON(invalidJson))
.to.throw(/^Failed to parse the JSON string: ([\D\w]*)\. SyntaxError: Unexpected token ([\D\w]*) in JSON at position ([0-9]*)$/);
.to.throw(/Failed to parse the JSON string/);
Copy link
Member

Choose a reason for hiding this comment

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

Did this pass integration test? I thought the regex should match the complete message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was because the regex was defined with ^...$ symbols. Without them you don't need to match the whole message.

});
});

Expand Down
8 changes: 4 additions & 4 deletions test/resources/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const certificateObject = require('./mock.key.json');

// Randomly generated key pairs that don't correspond to anything related to Firebase or GCP
export const keyPairs = [
/* tslint:disable:max-line-length */
/* eslint-disable max-len */
// The private key for this key pair is identical to the one used in ./mock.key.json
{
public: '-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAwJENcRev+eXZKvhhWLiV3Lz2MvO+naQRHo59g3vaNQnbgyduN/L4krlrJ5c6\nFiikXdtJNb/QrsAHSyJWCu8j3T9CruiwbidGAk2W0RuViTVspjHUTsIHExx9euWM0UomGvYk\noqXahdhPL/zViVSJt+Rt8bHLsMvpb8RquTIb9iKY3SMV2tCofNmyCSgVbghq/y7lKORtV/IR\nguWs6R22fbkb0r2MCYoNAbZ9dqnbRIFNZBC7itYtUoTEresRWcyFMh0zfAIJycWOJlVLDLqk\nY2SmIx8u7fuysCg1wcoSZoStuDq02nZEMw1dx8HGzE0hynpHlloRLByuIuOAfMCCYwIDAQAB\n-----END RSA PUBLIC KEY-----\n',
Expand All @@ -160,12 +160,12 @@ export const keyPairs = [
public: '-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAzhI/CMRtNO45R0DD4NBXFRDYAjlB/UVGGdMJKbCIrD3Uq7r/ived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XGI+ofA3iggByt2InCU+YIXsw1EbbhH4LGB8yyUA2SIjZybwUMKCkoMxmEumFP/FWgOL2w\nLlClqf9vZg9dBy8bDINJHm+9roYRO0/EhHA6IDSC+0X5BPZOexrBI07HJI7w7Y0WHFU8jK53\n55ps2YGT20n7haRMbbPMrq/3AoGBAOL+pY8bgCnKmeG2inun4FuD+0/aXAySXi70/BAABeHH\npogEfc0jv5SgygTiuC/2T84Jmsg0Y6M2l86srMrMA07xtyMbfRq7zih+K+EDoQ9HAwhDqxX5\nM7E8fPXscDzH2Y361QiGAQpjUcMix3hDV8oK537rYOmCYku18ZsVkjnPAoGAbE1u4fVlVTyA\ntJ0vNq45Q/GAgamS690rVStSMPIyPk02iyx3ryHi5NpGeO+X6KN269SHhiu1ZYiN/N1G/Jeg\nWzaCG4yiZygS/AXMKAQtvL2a7mXYDkCf8nrauiHWsqAg4RxiyA401dPg/kPKV5/fGZLyRbVu\nsup43BkV4n1XRv8CgYAmUIE1dJjfdPkgZiVd1epCyDZFNkBPRu1q06MwODDF+WMcllV9qMkP\nl0xCItqgDd1Ok8RygpVG2VIqam8IFAOC8b3NyTgGqSiVISba5jfrUjsqy/E21kdpZSJaiDwx\npjIMiwgmVigazsTgQSCWJhfNXKXSgHxtLbrVuLI9URjLdQKBgQDProyaG7pspt6uUdqMTa4+\nGVkUg+gIt5aVTf/Lb25K3SHA1baPamtbTDDf6vUjeJtTG+O+RMGqK5mB2MywjVHJdMGcJ44e\nogIh9eWY450oUoVBjEsdUd7Ef5KcpMFDUVFJwzCY371+Loqh2KYAk8WUSRzwGuw2QtLPO/L/\nQkKj4Q==\n-----END RSA PRIVATE KEY-----\n',
},
/* tslint:enable:max-line-length */
/* eslint-enable max-len */
];

// Randomly generated an X.509 certs using https://www.samltool.com/self_signed_certs.php
export const x509CertPairs = [
/* tslint:disable:max-line-length */
/* eslint-disable max-len */
{
public: '-----BEGIN CERTIFICATE-----\nMIICZjCCAc+gAwIBAgIBADANBgkqhkiG9w0BAQ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OrIyHCOzOmNYXcgRT\nhW+ZiSi+46FAYqCKawIwlq2M0GsJaMTdXFQFKTmnxiNvWxxDOeZcIsrc5uwEwr6A\n3I/LAkEAwuFBHurAZOsW20DYy2aMNKmplJx1NBXxAyfWoDDFE2ziJLuyUc2g1J/8\nuH22j7EW0xwjuiKiXeflVUkKTx0JiQJAUQb5OV/YZ88n8J008QHZlRpfLSfVaobA\nZkQ54Y7Rj+mObWvz8s1l63gUMKDP97KCzCCBHhJN8nlegydOxPq0LQJADBjkunGt\nfIGv6A3SG5/5nRYI1gHQsq30BaAPwx6BuDBtnaf5BpzcFvu1JMNHoVFYzmiykpwX\n1zUhaAtcX2BV9g==\n-----END PRIVATE KEY-----\n',
},
/* tslint:enable:max-line-length */
/* eslint-enable max-len */
];

/**
Expand Down
4 changes: 3 additions & 1 deletion test/unit/project-management/android-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import * as _ from 'lodash';
import * as sinon from 'sinon';
import { FirebaseApp } from '../../../src/firebase-app';
import { AndroidApp, ShaCertificate } from '../../../src/project-management/android-app';
import { ProjectManagementRequestHandler } from '../../../src/project-management/project-management-api-request-internal';
import {
ProjectManagementRequestHandler
} from '../../../src/project-management/project-management-api-request-internal';
import { deepCopy } from '../../../src/utils/deep-copy';
import { FirebaseProjectManagementError } from '../../../src/utils/error';
import * as mocks from '../../resources/mocks';
Expand Down
4 changes: 3 additions & 1 deletion test/unit/project-management/ios-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import * as _ from 'lodash';
import * as sinon from 'sinon';
import { FirebaseApp } from '../../../src/firebase-app';
import { IosApp } from '../../../src/project-management/ios-app';
import { ProjectManagementRequestHandler } from '../../../src/project-management/project-management-api-request-internal';
import {
ProjectManagementRequestHandler
} from '../../../src/project-management/project-management-api-request-internal';
import { deepCopy } from '../../../src/utils/deep-copy';
import { FirebaseProjectManagementError } from '../../../src/utils/error';
import * as mocks from '../../resources/mocks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import * as _ from 'lodash';
import * as sinon from 'sinon';
import * as sinonChai from 'sinon-chai';
import { FirebaseApp } from '../../../src/firebase-app';
import { ProjectManagementRequestHandler } from '../../../src/project-management/project-management-api-request-internal';
import {
ProjectManagementRequestHandler
} from '../../../src/project-management/project-management-api-request-internal';
import { HttpClient } from '../../../src/utils/api-request';
import * as mocks from '../../resources/mocks';
import * as utils from '../utils';
Expand Down
4 changes: 3 additions & 1 deletion test/unit/project-management/project-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import * as sinon from 'sinon';
import { FirebaseApp } from '../../../src/firebase-app';
import { AndroidApp } from '../../../src/project-management/android-app';
import { ProjectManagement } from '../../../src/project-management/project-management';
import { ProjectManagementRequestHandler } from '../../../src/project-management/project-management-api-request-internal';
import {
ProjectManagementRequestHandler
} from '../../../src/project-management/project-management-api-request-internal';
import { FirebaseProjectManagementError } from '../../../src/utils/error';
import * as mocks from '../../resources/mocks';
import { IosApp } from '../../../src/project-management/ios-app';
Expand Down
31 changes: 25 additions & 6 deletions test/unit/remote-config/remote-config-api-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import {
ListVersionsResult,
Version,
} from '../../../src/remote-config/remote-config-api-client';
import { FirebaseRemoteConfigError, RemoteConfigApiClient } from '../../../src/remote-config/remote-config-api-client-internal';
import {
FirebaseRemoteConfigError,
RemoteConfigApiClient
} from '../../../src/remote-config/remote-config-api-client-internal';
import { HttpClient } from '../../../src/utils/api-request';
import * as utils from '../utils';
import * as mocks from '../../resources/mocks';
Expand All @@ -47,7 +50,8 @@ describe('RemoteConfigApiClient', () => {
};

const VALIDATION_ERROR_MESSAGES = [
"[VALIDATION_ERROR]: [foo] are not valid condition names. All keys in all conditional value maps must be valid condition names.",
"[VALIDATION_ERROR]: [foo] are not valid condition names. All keys in all conditional value" +
" maps must be valid condition names.",
"[VERSION_MISMATCH]: Expected version 6, found 8 for project: 123456789012"
];

Expand Down Expand Up @@ -529,11 +533,19 @@ describe('RemoteConfigApiClient', () => {
});
});

['', 'abc', 'a123b', 'a123', '123a', 1.2, '70.2', null, NaN, true, [], {}].forEach(
['', null, NaN, true, [], {}].forEach(
(invalidVersion) => {
it(`should throw if the endVersionNumber is: ${invalidVersion}`, () => {
expect(() => apiClient.listVersions({ endVersionNumber: invalidVersion } as any))
.to.throw(/^endVersionNumber must be a non-empty string in int64 format or a number$/);
});
});

['abc', 'a123b', 'a123', '123a', 1.2, '70.2'].forEach(
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! :)

(invalidVersion) => {
it(`should throw if the endVersionNumber is: ${invalidVersion}`, () => {
expect(() => apiClient.listVersions({ endVersionNumber: invalidVersion } as any))
.to.throw(/^endVersionNumber must be (a non-empty string in int64 format or a number|an integer or a string in int64 format)$/);
.to.throw(/^endVersionNumber must be an integer or a string in int64 format$/);
});
});

Expand Down Expand Up @@ -655,10 +667,17 @@ describe('RemoteConfigApiClient', () => {
});

function runTemplateVersionNumberTests(rcOperation: Function): void {
['', 'abc', 'a123b', 'a123', '123a', 1.2, '70.2', null, NaN, true, [], {}].forEach((invalidVersion) => {
['', null, NaN, true, [], {}].forEach((invalidVersion) => {
it(`should reject if the versionNumber is: ${invalidVersion}`, () => {
expect(() => rcOperation(invalidVersion as any))
.to.throw(/^versionNumber must be a non-empty string in int64 format or a number$/);
});
});

['abc', 'a123b', 'a123', '123a', 1.2, '70.2'].forEach((invalidVersion) => {
it(`should reject if the versionNumber is: ${invalidVersion}`, () => {
expect(() => rcOperation(invalidVersion as any))
.to.throw(/^versionNumber must be (a non-empty string in int64 format or a number|an integer or a string in int64 format)$/);
.to.throw(/^versionNumber must be an integer or a string in int64 format$/);
});
});
}
Expand Down
26 changes: 22 additions & 4 deletions test/unit/remote-config/remote-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import {
TagColor,
ListVersionsResult,
} from '../../../src/remote-config/remote-config-api-client';
import { FirebaseRemoteConfigError, RemoteConfigApiClient } from '../../../src/remote-config/remote-config-api-client-internal';
import {
FirebaseRemoteConfigError,
RemoteConfigApiClient
} from '../../../src/remote-config/remote-config-api-client-internal';
import { deepCopy } from '../../../src/utils/deep-copy';

const expect = chai.expect;
Expand Down Expand Up @@ -254,7 +257,21 @@ describe('RemoteConfig', () => {
.should.eventually.be.rejected.and.deep.equal(INTERNAL_ERROR);
});

['', 'abc', 'a123b', 'a123', '123a', 1.2, '70.2', null, NaN, true, [], {}].forEach((invalidVersion) => {
['', null, NaN, true, [], {}].forEach((invalidVersion) => {
it(`should reject if the versionNumber is: ${invalidVersion}`, () => {
const response = deepCopy(REMOTE_CONFIG_LIST_VERSIONS_RESULT);
response.versions[0].versionNumber = invalidVersion as any;
const stub = sinon
.stub(RemoteConfigApiClient.prototype, 'listVersions')
.resolves(response);
stubs.push(stub);
return remoteConfig.listVersions()
.should.eventually.be.rejected
.and.to.match(/^Error: Version number must be a non-empty string in int64 format or a number$/);
});
});

['abc', 'a123b', 'a123', '123a', 1.2, '70.2'].forEach((invalidVersion) => {
Copy link
Member

Choose a reason for hiding this comment

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

Thank you! :)

it(`should reject if the versionNumber is: ${invalidVersion}`, () => {
const response = deepCopy(REMOTE_CONFIG_LIST_VERSIONS_RESULT);
response.versions[0].versionNumber = invalidVersion as any;
Expand All @@ -263,7 +280,8 @@ describe('RemoteConfig', () => {
.resolves(response);
stubs.push(stub);
return remoteConfig.listVersions()
.should.eventually.be.rejected.and.to.match(/^Error: Version number must be (a non-empty string in int64 format or a number|an integer or a string in int64 format)$/);
.should.eventually.be.rejected
.and.to.match(/^Error: Version number must be an integer or a string in int64 format$/);
});
});

Expand Down Expand Up @@ -415,7 +433,7 @@ describe('RemoteConfig', () => {
INVALID_JSON_STRINGS.forEach((invalidJson) => {
it(`should throw if the json string is ${JSON.stringify(invalidJson)}`, () => {
expect(() => remoteConfig.createTemplateFromJSON(invalidJson))
.to.throw(/^Failed to parse the JSON string: ([\D\w]*)\. SyntaxError: Unexpected token ([\D\w]*) in JSON at position ([0-9]*)$/);
.to.throw(/Failed to parse the JSON string: ([\D\w]*)\./);
});
});

Expand Down