Skip to content

Commit 227af70

Browse files
committed
[AUTOMATED]: Prettier Code Styling
1 parent 25db049 commit 227af70

File tree

7 files changed

+36
-25
lines changed

7 files changed

+36
-25
lines changed

packages/performance/src/resources/trace.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe('Firebase Performance > trace', () => {
117117
expect(trace.getMetric('cacheHits')).to.eql(600);
118118
});
119119

120-
it('throws error if metric doesn\'t exist and has invalid name', () => {
120+
it("throws error if metric doesn't exist and has invalid name", () => {
121121
expect(() => trace.incrementMetric('_invalidMetric', 1)).to.throw();
122122
});
123123
});
@@ -136,7 +136,7 @@ describe('Firebase Performance > trace', () => {
136136
expect(trace.getMetric('cacheHits')).to.eql(400);
137137
});
138138

139-
it('throws error if metric doesn\'t exist and has invalid name', () => {
139+
it("throws error if metric doesn't exist and has invalid name", () => {
140140
expect(() => trace.putMetric('_invalidMetric', 1)).to.throw();
141141
});
142142
});
@@ -186,10 +186,12 @@ describe('Firebase Performance > trace', () => {
186186
});
187187

188188
it('throws error if attribute value is invalid', () => {
189-
const longAttributeValue =
189+
const longAttributeValue =
190190
'too-long-attribute-value-over-one-hundred-characters-too-long-attribute-value-over-one-' +
191191
'hundred-charac';
192-
expect(() => trace.putAttribute('validName', longAttributeValue)).to.throw();
192+
expect(() =>
193+
trace.putAttribute('validName', longAttributeValue)
194+
).to.throw();
193195
});
194196
});
195197

packages/performance/src/resources/trace.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ import {
2727
import { Api } from '../services/api_service';
2828
import { logTrace } from '../services/perf_logger';
2929
import { ERROR_FACTORY, ErrorCode } from '../utils/errors';
30-
import { isValidCustomAttributeName, isValidCustomAttributeValue } from '../utils/attributes_utils';
30+
import {
31+
isValidCustomAttributeName,
32+
isValidCustomAttributeValue
33+
} from '../utils/attributes_utils';
3134
import { isValidCustomMetricName } from '../utils/metric_utils';
3235
import { PerformanceTrace } from '@firebase/performance-types';
3336

@@ -195,12 +198,12 @@ export class Trace implements PerformanceTrace {
195198
return;
196199
}
197200
// Throw appropriate error when the attribute name or value is invalid.
198-
if (!isValidName){
201+
if (!isValidName) {
199202
throw ERROR_FACTORY.create(ErrorCode.INVALID_ATTRIBUTE_NAME, {
200203
attributeName: attr
201204
});
202205
}
203-
if (!isValidValue){
206+
if (!isValidValue) {
204207
throw ERROR_FACTORY.create(ErrorCode.INVALID_ATTRIBUTE_VALUE, {
205208
attributeValue: value
206209
});

packages/performance/src/utils/attribute_utils.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
getServiceWorkerStatus,
2626
getEffectiveConnectionType,
2727
isValidCustomAttributeName,
28-
isValidCustomAttributeValue,
28+
isValidCustomAttributeValue
2929
} from './attributes_utils';
3030

3131
import '../../test/setup';
@@ -181,15 +181,19 @@ describe('Firebase Performance > attribute_utils', () => {
181181
});
182182

183183
it('returns true when name is valid', () => {
184-
expect(isValidCustomAttributeName('validCustom_Attribute_Name')).to.be.true;
184+
expect(isValidCustomAttributeName('validCustom_Attribute_Name')).to.be
185+
.true;
185186
});
186187

187188
it('returns false when name is too long', () => {
188-
expect(isValidCustomAttributeName('invalid_custom_name_over_forty_characters')).to.be.false;
189+
expect(
190+
isValidCustomAttributeName('invalid_custom_name_over_forty_characters')
191+
).to.be.false;
189192
});
190193

191194
it('returns false when name starts with a reserved prefix', () => {
192-
expect(isValidCustomAttributeName('firebase_invalidCustomName')).to.be.false;
195+
expect(isValidCustomAttributeName('firebase_invalidCustomName')).to.be
196+
.false;
193197
});
194198

195199
it('returns false when name does not begin with a letter', () => {
@@ -211,10 +215,10 @@ describe('Firebase Performance > attribute_utils', () => {
211215
});
212216

213217
it('returns false when value is too long', () => {
214-
const longAttributeValue =
218+
const longAttributeValue =
215219
'too_long_attribute_value_over_one_hundred_characters_too_long_attribute_value_over_one_' +
216220
'hundred_charac';
217221
expect(isValidCustomAttributeValue(longAttributeValue)).to.be.false;
218222
});
219223
});
220-
});
224+
});

packages/performance/src/utils/attributes_utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ export function isValidCustomAttributeName(name: string): boolean {
9898
if (name.length > MAX_ATTRIBUTE_NAME_LENGTH) {
9999
return false;
100100
}
101-
const matchesReservedPrefix = RESERVED_ATTRIBUTE_PREFIXES.some(prefix => name.startsWith(prefix));
101+
const matchesReservedPrefix = RESERVED_ATTRIBUTE_PREFIXES.some(prefix =>
102+
name.startsWith(prefix)
103+
);
102104
return !matchesReservedPrefix && !!name.match(ATTRIBUTE_FORMAT_REGEX);
103105
}
104106

105107
export function isValidCustomAttributeValue(value: string): boolean {
106108
return value.length <= MAX_ATTRIBUTE_VALUE_LENGTH;
107-
}
109+
}

packages/performance/src/utils/errors.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const enum ErrorCode {
3030
RC_NOT_OK = 'RC response not ok',
3131
INVALID_ATTRIBUTE_NAME = 'invalid attribute name',
3232
INVALID_ATTRIBUTE_VALUE = 'invalid attribute value',
33-
INVALID_CUSTOM_METRIC_NAME = 'invalide custom metric name',
33+
INVALID_CUSTOM_METRIC_NAME = 'invalide custom metric name'
3434
}
3535

3636
const ERROR_DESCRIPTION_MAP: { readonly [key in ErrorCode]: string } = {
@@ -44,9 +44,12 @@ const ERROR_DESCRIPTION_MAP: { readonly [key in ErrorCode]: string } = {
4444
[ErrorCode.FB_NOT_DEFAULT]:
4545
'Performance can only start when Firebase app instance is the default one.',
4646
[ErrorCode.RC_NOT_OK]: 'RC response is not ok',
47-
[ErrorCode.INVALID_ATTRIBUTE_NAME]: 'Attribute name {$attributeName} is invalid.',
48-
[ErrorCode.INVALID_ATTRIBUTE_VALUE]: 'Attribute value {$attributeValue} is invalid.',
49-
[ErrorCode.INVALID_CUSTOM_METRIC_NAME]: 'Custom metric name {$customMetricName} is invalid',
47+
[ErrorCode.INVALID_ATTRIBUTE_NAME]:
48+
'Attribute name {$attributeName} is invalid.',
49+
[ErrorCode.INVALID_ATTRIBUTE_VALUE]:
50+
'Attribute value {$attributeValue} is invalid.',
51+
[ErrorCode.INVALID_CUSTOM_METRIC_NAME]:
52+
'Custom metric name {$customMetricName} is invalid'
5053
};
5154

5255
interface ErrorParams {

packages/performance/src/utils/metric_utils.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@
1818
import { restore } from 'sinon';
1919
import { expect } from 'chai';
2020

21-
import {
22-
isValidCustomMetricName,
23-
} from './metric_utils';
21+
import { isValidCustomMetricName } from './metric_utils';
2422

2523
import '../../test/setup';
2624

2725
describe('Firebase Performance > metric_utils', () => {
28-
2926
describe('#isValidCustomMetricName', () => {
3027
afterEach(() => {
3128
restore();
@@ -46,4 +43,4 @@ describe('Firebase Performance > metric_utils', () => {
4643
expect(isValidCustomMetricName('_invalidMetricName')).to.be.false;
4744
});
4845
});
49-
});
46+
});

packages/performance/src/utils/metric_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ export function isValidCustomMetricName(name: string): boolean {
2323
return false;
2424
}
2525
return !name.startsWith(RESERVED_AUTO_PREFIX);
26-
}
26+
}

0 commit comments

Comments
 (0)