Skip to content

Commit 775fd35

Browse files
authored
prettier to enforce pareens in arrow functions (#474)
1 parent 860dd00 commit 775fd35

21 files changed

+73
-69
lines changed

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"arrowParens": "always",
23
"singleQuote": true,
34
"trailingComma": "es5"
45
}

integration_test/functions/src/database-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ export const databaseTests: any = functions.database
2424
(change, context) => !(context as any).app
2525
)
2626

27-
.it('should give refs access to admin data', change =>
27+
.it('should give refs access to admin data', (change) =>
2828
change.after.ref.parent
2929
.child('adminOnly')
3030
.update({ allowed: 1 })
3131
.then(() => true)
3232
)
3333

34-
.it('should have a correct ref url', change => {
34+
.it('should have a correct ref url', (change) => {
3535
const url = change.after.ref.toString();
3636
return Promise.resolve()
3737
.then(() => {

integration_test/functions/src/firestore-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const firestoreTests: any = functions
1515

1616
.it('should not have event.app', (snap, context) => !(context as any).app)
1717

18-
.it('should give refs write access', snap =>
18+
.it('should give refs write access', (snap) =>
1919
snap.ref.set({ allowed: 1 }, { merge: true }).then(() => true)
2020
)
2121

integration_test/functions/src/https-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as functions from 'firebase-functions';
22
import * as _ from 'lodash';
33
import { TestSuite, expectEq } from './testing';
44

5-
export const callableTests: any = functions.https.onCall(d => {
5+
export const callableTests: any = functions.https.onCall((d) => {
66
return new TestSuite('https onCall')
7-
.it('should have the correct data', data =>
7+
.it('should have the correct data', (data) =>
88
expectEq(_.get(data, 'foo'), 'bar')
99
)
1010
.run(d.testId, d);

integration_test/functions/src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ function callHttpsTrigger(name: string, data: any, baseUrl) {
3232
'Content-Type': 'application/json',
3333
},
3434
},
35-
response => {
35+
(response) => {
3636
let body = '';
37-
response.on('data', chunk => {
37+
response.on('data', (chunk) => {
3838
body += chunk;
3939
});
4040
response.on('end', () => resolve(body));
@@ -59,9 +59,9 @@ function callScheduleTrigger(functionName: string, region: string) {
5959
'Content-Type': 'application/json',
6060
},
6161
},
62-
response => {
62+
(response) => {
6363
let body = '';
64-
response.on('data', chunk => {
64+
response.on('data', (chunk) => {
6565
body += chunk;
6666
});
6767
response.on('end', () => resolve(body));
@@ -114,7 +114,7 @@ export const integrationTests: any = functions
114114
password: 'secret',
115115
displayName: `${testId}`,
116116
})
117-
.then(userRecord => {
117+
.then((userRecord) => {
118118
// A user deletion to trigger the Firebase Auth user deletion tests.
119119
admin.auth().deleteUser(userRecord.uid);
120120
}),
@@ -160,7 +160,7 @@ export const integrationTests: any = functions
160160
let ref = admin.database().ref(`testRuns/${testId}`);
161161
return new Promise((resolve, reject) => {
162162
let testsExecuted = 0;
163-
ref.on('child_added', snapshot => {
163+
ref.on('child_added', (snapshot) => {
164164
testsExecuted += 1;
165165
if (snapshot.key != 'timestamp' && !snapshot.val().passed) {
166166
reject(
@@ -185,7 +185,7 @@ export const integrationTests: any = functions
185185
ref.off(); // No more need to listen.
186186
return Promise.resolve();
187187
})
188-
.catch(err => {
188+
.catch((err) => {
189189
ref.off(); // No more need to listen.
190190
return Promise.reject(err);
191191
});
@@ -194,7 +194,7 @@ export const integrationTests: any = functions
194194
console.log('All tests pass!');
195195
resp.status(200).send('PASS \n');
196196
})
197-
.catch(err => {
197+
.catch((err) => {
198198
console.log(`Some tests failed: ${err}`);
199199
resp
200200
.status(500)

integration_test/functions/src/pubsub-tests.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const pubsubTests: any = functions.pubsub
4343
expectEq((context as any).action, undefined)
4444
)
4545

46-
.it('should have pubsub data', message => {
46+
.it('should have pubsub data', (message) => {
4747
const decoded = new Buffer(message.data, 'base64').toString();
4848
const parsed = JSON.parse(decoded);
4949
return evaluate(
@@ -52,7 +52,7 @@ export const pubsubTests: any = functions.pubsub
5252
);
5353
})
5454

55-
.it('should decode JSON payloads with the json helper', message =>
55+
.it('should decode JSON payloads with the json helper', (message) =>
5656
evaluate(message.json.hasOwnProperty('testId'), message.json)
5757
)
5858

@@ -62,15 +62,15 @@ export const pubsubTests: any = functions.pubsub
6262
export const schedule: any = functions.pubsub
6363
.schedule('every 10 hours') // This is a dummy schedule, since we need to put a valid one in.
6464
// For the test, the job is triggered by the jobs:run api
65-
.onRun(context => {
65+
.onRun((context) => {
6666
let testId;
6767
let db = admin.database();
6868
return new Promise(async (resolve, reject) => {
6969
await db
7070
.ref('testRuns')
7171
.orderByChild('timestamp')
7272
.limitToLast(1)
73-
.on('value', snap => {
73+
.on('value', (snap) => {
7474
testId = Object.keys(snap.val())[0];
7575
new TestSuite('pubsub scheduleOnRun')
7676
.it('should trigger when the scheduler fires', () => success())

integration_test/functions/src/testing.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ export class TestSuite<T> {
2828
const run = Promise.resolve()
2929
.then(() => this.tests[testName](data, context))
3030
.then(
31-
result => {
31+
(result) => {
3232
console.log(
3333
`${result ? 'Passed' : 'Failed with successful op'}: ${testName}`
3434
);
3535
return { name: testName, passed: !!result };
3636
},
37-
error => {
37+
(error) => {
3838
console.error(`Failed: ${testName}`, error);
3939
return { name: testName, passed: 0, error: error };
4040
}
4141
);
4242
running.push(run);
4343
}
44-
return Promise.all(running).then(results => {
44+
return Promise.all(running).then((results) => {
4545
let sum = 0;
46-
results.forEach(val => (sum = sum + val.passed));
46+
results.forEach((val) => (sum = sum + val.passed));
4747
const summary = `passed ${sum} of ${running.length}`;
4848
const passed = sum === running.length;
4949
console.log(summary);

spec/apps.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('apps', () => {
3838
});
3939

4040
afterEach(() => {
41-
_.forEach(firebase.apps, app => {
41+
_.forEach(firebase.apps, (app) => {
4242
app.delete();
4343
});
4444
});

spec/cloud-functions.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('makeCloudFunction', () => {
118118
data: 'test data',
119119
};
120120

121-
return cf(test.data, test.context).then(result => {
121+
return cf(test.data, test.context).then((result) => {
122122
expect(result).to.deep.equal({
123123
eventId: '00000',
124124
timestamp: '2016-11-04T21:29:03.496Z',

spec/function-builder.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('FunctionBuilder', () => {
3737
const fn = functions
3838
.region('us-east1')
3939
.auth.user()
40-
.onCreate(user => user);
40+
.onCreate((user) => user);
4141

4242
expect(fn.__trigger.regions).to.deep.equal(['us-east1']);
4343
});
@@ -46,7 +46,7 @@ describe('FunctionBuilder', () => {
4646
const fn = functions
4747
.region('us-east1', 'us-central1')
4848
.auth.user()
49-
.onCreate(user => user);
49+
.onCreate((user) => user);
5050

5151
expect(fn.__trigger.regions).to.deep.equal(['us-east1', 'us-central1']);
5252
});
@@ -62,7 +62,7 @@ describe('FunctionBuilder', () => {
6262
'asia-northeast1'
6363
)
6464
.auth.user()
65-
.onCreate(user => user);
65+
.onCreate((user) => user);
6666

6767
expect(fn.__trigger.regions).to.deep.equal([
6868
'us-central1',
@@ -81,7 +81,7 @@ describe('FunctionBuilder', () => {
8181
memory: '256MB',
8282
})
8383
.auth.user()
84-
.onCreate(user => user);
84+
.onCreate((user) => user);
8585

8686
expect(fn.__trigger.availableMemoryMb).to.deep.equal(256);
8787
expect(fn.__trigger.timeout).to.deep.equal('90s');
@@ -95,7 +95,7 @@ describe('FunctionBuilder', () => {
9595
memory: '256MB',
9696
})
9797
.auth.user()
98-
.onCreate(user => user);
98+
.onCreate((user) => user);
9999

100100
expect(fn.__trigger.regions).to.deep.equal(['europe-west2']);
101101
expect(fn.__trigger.availableMemoryMb).to.deep.equal(256);
@@ -110,7 +110,7 @@ describe('FunctionBuilder', () => {
110110
})
111111
.region('europe-west1')
112112
.auth.user()
113-
.onCreate(user => user);
113+
.onCreate((user) => user);
114114

115115
expect(fn.__trigger.regions).to.deep.equal(['europe-west1']);
116116
expect(fn.__trigger.availableMemoryMb).to.deep.equal(256);

0 commit comments

Comments
 (0)