Skip to content

Commit 6b37f2c

Browse files
Cleanup
1 parent 918aacb commit 6b37f2c

29 files changed

+253
-89
lines changed

packages/firestore/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
const karmaBase = require('../../config/karma.base');
1919
const { argv } = require('yargs');
2020

21-
module.exports = function (config) {
21+
module.exports = function(config) {
2222
const karmaConfig = Object.assign({}, karmaBase, {
2323
// files to load into karma
2424
files: getTestFiles(argv),

packages/firestore/lite/test/bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import '../register';
2424
* https://github.com/webpack-contrib/karma-webpack#alternative-usage
2525
*/
2626

27-
process.env.TEST_PLATFORM = 'node-lite';
27+
process.env.TEST_PLATFORM = 'browser-lite';
2828

2929
// 'context()' definition requires additional dependency on webpack-env package.
3030
// eslint-disable-next-line @typescript-eslint/no-explicit-any

packages/firestore/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"@firebase/webchannel-wrapper": "0.2.41",
6464
"@grpc/grpc-js": "^1.0.0",
6565
"@grpc/proto-loader": "^0.5.0",
66-
"axios": "^0.19.2",
6766
"node-fetch": "2.6.0",
6867
"tslib": "^1.11.1"
6968
},

packages/firestore/rollup.config.lite.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ const allBuilds = [
111111
format: 'es',
112112
sourcemap: true
113113
},
114-
plugins: [alias(util.generateAliasConfig('browser_lite')), ...browserPlugins],
114+
plugins: [
115+
alias(util.generateAliasConfig('browser_lite')),
116+
...browserPlugins
117+
],
115118
external: util.resolveBrowserExterns,
116119
treeshake: {
117120
moduleSideEffects: false

packages/firestore/rollup.shared.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const pkg = require('./package.json');
2929
* references to platform-specific files with implementations for the provided
3030
* target platform.
3131
*/
32-
exports.generateAliasConfig = function (platform) {
32+
exports.generateAliasConfig = function(platform) {
3333
return {
3434
entries: [
3535
{
@@ -47,12 +47,12 @@ const browserDeps = Object.keys(
4747
const nodeDeps = [...browserDeps, 'util', 'path'];
4848

4949
/** Resolves the external dependencies for the browser build. */
50-
exports.resolveBrowserExterns = function (id) {
50+
exports.resolveBrowserExterns = function(id) {
5151
return browserDeps.some(dep => id === dep || id.startsWith(`${dep}/`));
5252
};
5353

5454
/** Resolves the external dependencies for the Node build. */
55-
exports.resolveNodeExterns = function (id) {
55+
exports.resolveNodeExterns = function(id) {
5656
return nodeDeps.some(dep => id === dep || id.startsWith(`${dep}/`));
5757
};
5858

packages/firestore/src/local/simple_db.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ export class SimpleDb {
218218
static getIOSVersion(ua: string): number {
219219
const iOSVersionRegex = ua.match(/i(?:phone|pad|pod) os ([\d_]+)/i);
220220
const version = iOSVersionRegex
221-
? iOSVersionRegex[1].split('_').slice(0, 2).join('.')
221+
? iOSVersionRegex[1]
222+
.split('_')
223+
.slice(0, 2)
224+
.join('.')
222225
: '-1';
223226
return Number(version);
224227
}
@@ -228,7 +231,10 @@ export class SimpleDb {
228231
static getAndroidVersion(ua: string): number {
229232
const androidVersionRegex = ua.match(/Android ([\d.]+)/i);
230233
const version = androidVersionRegex
231-
? androidVersionRegex[1].split('.').slice(0, 2).join('.')
234+
? androidVersionRegex[1]
235+
.split('.')
236+
.slice(0, 2)
237+
.join('.')
232238
: '-1';
233239
return Number(version);
234240
}

packages/firestore/src/platform/browser/webchannel_connection.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ export class WebChannelConnection extends RestConnection {
130130
default:
131131
fail(
132132
'RPC "' +
133-
rpcName +
134-
'" failed with unanticipated ' +
135-
'webchannel error ' +
136-
xhr.getLastErrorCode() +
137-
': ' +
138-
xhr.getLastError() +
139-
', giving up.'
133+
rpcName +
134+
'" failed with unanticipated ' +
135+
'webchannel error ' +
136+
xhr.getLastErrorCode() +
137+
': ' +
138+
xhr.getLastError() +
139+
', giving up.'
140140
);
141141
}
142142
} finally {
@@ -148,7 +148,7 @@ export class WebChannelConnection extends RestConnection {
148148
xhr.send(url, 'POST', requestString, headers, XHR_TIMEOUT_SECS);
149149
});
150150
}
151-
151+
152152
openStream<Req, Resp>(
153153
rpcName: string,
154154
token: Token | null

packages/firestore/src/platform/browser_lite/fetch_connection.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,24 @@
1818
import { Token } from '../../api/credentials';
1919
import { Stream } from '../../remote/connection';
2020
import { mapCodeFromHttpStatus } from '../../remote/rpc_error';
21-
import { FirestoreError } from '../../util/error';
21+
import { FirestoreError } from '../../util/error';
2222
import { StringMap } from '../../util/types';
2323
import { RestConnection } from '../../remote/rest_connection';
24-
import {DatabaseInfo} from "../../core/database_info";
24+
import { DatabaseInfo } from '../../core/database_info';
2525

26+
/**
27+
* A Rest-based connection that relies on the native HTTP stack
28+
* (e.g. `fetch` or a polyfill).
29+
*/
2630
export class FetchConnection extends RestConnection {
27-
constructor(databaseInfo: DatabaseInfo, private readonly fetchImpl: typeof fetch) {
31+
/**
32+
* @param databaseInfo The connection info.
33+
* @param fetchImpl `fetch` or a Polyfill that implements the fetch API.
34+
*/
35+
constructor(
36+
databaseInfo: DatabaseInfo,
37+
private readonly fetchImpl: typeof fetch
38+
) {
2839
super(databaseInfo);
2940
}
3041

@@ -56,14 +67,14 @@ export class FetchConnection extends RestConnection {
5667
'Request failed with error: ' + err.statusText
5768
);
5869
}
59-
70+
6071
if (!response.ok) {
6172
throw new FirestoreError(
6273
mapCodeFromHttpStatus(response.status),
6374
'Request failed with error: ' + response.statusText
6475
);
6576
}
66-
77+
6778
return response.json();
6879
}
6980
}

packages/firestore/src/platform/browser_lite/serializer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
/** Return the Platform-specific serializer monitor. */
1918
import { JsonProtoSerializer } from '../../remote/serializer';
2019
import { DatabaseId } from '../../core/database_info';
2120

packages/firestore/src/platform/connection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
import {ConnectivityMonitor} from "../remote/connectivity_monitor";
18-
import {DatabaseInfo} from "../core/database_info";
19-
import {Connection} from "../remote/connection";
17+
import { ConnectivityMonitor } from '../remote/connectivity_monitor';
18+
import { DatabaseInfo } from '../core/database_info';
19+
import { Connection } from '../remote/connection';
2020

2121
// This file is only used under ts-node.
2222
// eslint-disable-next-line @typescript-eslint/no-require-imports

packages/firestore/src/platform/format_json.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
// This file is only used under ts-node.
1919
// eslint-disable-next-line @typescript-eslint/no-require-imports
20-
const platform = require(`./${process.env.TEST_PLATFORM ?? 'node'}/format_json`);
20+
const platform = require(`./${process.env.TEST_PLATFORM ??
21+
'node'}/format_json`);
2122

2223
/** Formats an object as a JSON string, suitable for logging. */
2324
export function formatJSON(value: unknown): string {

packages/firestore/src/platform/node_lite/connection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import * as nodeFetch from 'node-fetch';
1919

20-
import {FetchConnection} from "../browser_lite/fetch_connection";
21-
import {DatabaseInfo} from "../../core/database_info";
22-
import {Connection} from "../../remote/connection";
20+
import { FetchConnection } from '../browser_lite/fetch_connection';
21+
import { DatabaseInfo } from '../../core/database_info';
22+
import { Connection } from '../../remote/connection';
2323

2424
export { newConnectivityMonitor } from '../browser/connection';
2525

packages/firestore/src/platform/random_bytes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717

1818
// This file is only used under ts-node.
1919
// eslint-disable-next-line @typescript-eslint/no-require-imports
20-
const platform = require(`./${process.env.TEST_PLATFORM ?? 'node'}/random_bytes`);
20+
const platform = require(`./${process.env.TEST_PLATFORM ??
21+
'node'}/random_bytes`);
2122

2223
/**
2324
* Generates `nBytes` of random bytes.
2425
*
2526
* If `nBytes < 0` , an error will be thrown.
2627
*/
2728
export function randomBytes(nBytes: number): Uint8Array {
28-
return platform.randomBytes(nBytes);
29+
return platform.randomBytes(nBytes);
2930
}

packages/firestore/src/platform/serializer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
import {DatabaseId} from "../core/database_info";
18-
import {JsonProtoSerializer} from "../remote/serializer";
17+
import { DatabaseId } from '../core/database_info';
18+
import { JsonProtoSerializer } from '../remote/serializer';
1919

2020
// This file is only used under ts-node.
2121
// eslint-disable-next-line @typescript-eslint/no-require-imports
2222
const platform = require(`./${process.env.TEST_PLATFORM ?? 'node'}/serializer`);
2323

2424
export function newSerializer(databaseId: DatabaseId): JsonProtoSerializer {
25-
return platform.newSerializer(databaseId);
25+
return platform.newSerializer(databaseId);
2626
}

packages/firestore/src/remote/rest_connection.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import { Indexable } from '../util/misc';
2727

2828
const LOG_TAG = 'RestConnection';
2929

30-
/**
31-
* Maps RPC names to the corresponding REST endpoint name.
32-
*
30+
/**
31+
* Maps RPC names to the corresponding REST endpoint name.
32+
*
3333
* We use array notation to avoid mangling.
3434
*/
3535
const RPC_NAME_URL_MAPPING: StringMap = {};
@@ -92,7 +92,15 @@ export abstract class RestConnection implements Connection {
9292
return response;
9393
},
9494
(err: FirestoreError) => {
95-
logWarn(LOG_TAG, `${rpcName} failed with error: `, err.message, 'url: ', url, 'request:', req);
95+
logWarn(
96+
LOG_TAG,
97+
`${rpcName} failed with error: `,
98+
err.message,
99+
'url: ',
100+
url,
101+
'request:',
102+
req
103+
);
96104
throw err;
97105
}
98106
);
@@ -107,7 +115,7 @@ export abstract class RestConnection implements Connection {
107115
// can just use the normal invoke() method.
108116
return this.invokeRPC<Req, Resp[]>(rpcName, request, token);
109117
}
110-
118+
111119
abstract openStream<Req, Resp>(
112120
rpcName: string,
113121
token: Token | null

packages/firestore/test/integration/api/batch_writes.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ apiDescribe('Database batch writes', (persistence: boolean) => {
7676
return integrationHelpers.withTestDoc(persistence, doc => {
7777
return doc
7878
.set({ foo: 'bar' })
79-
.then(() => doc.firestore.batch().update(doc, { baz: 42 }).commit())
79+
.then(() =>
80+
doc.firestore
81+
.batch()
82+
.update(doc, { baz: 42 })
83+
.commit()
84+
)
8085
.then(() => doc.get())
8186
.then(snapshot => {
8287
expect(snapshot.exists).to.equal(true);
@@ -121,7 +126,12 @@ apiDescribe('Database batch writes', (persistence: boolean) => {
121126
.then(snapshot => {
122127
expect(snapshot.exists).to.equal(true);
123128
})
124-
.then(() => doc.firestore.batch().delete(doc).commit())
129+
.then(() =>
130+
doc.firestore
131+
.batch()
132+
.delete(doc)
133+
.commit()
134+
)
125135
.then(() => doc.get())
126136
.then(snapshot => {
127137
expect(snapshot.exists).to.equal(false);

packages/firestore/test/integration/api/cursor.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ apiDescribe('Cursors', (persistence: boolean) => {
4848
.then(docs => {
4949
expect(toDataArray(docs)).to.deep.equal([{ v: 'a' }, { v: 'b' }]);
5050
const lastDoc = docs.docs[docs.docs.length - 1];
51-
return coll.limit(3).startAfter(lastDoc).get();
51+
return coll
52+
.limit(3)
53+
.startAfter(lastDoc)
54+
.get();
5255
})
5356
.then(docs => {
5457
expect(toDataArray(docs)).to.deep.equal([
@@ -57,12 +60,18 @@ apiDescribe('Cursors', (persistence: boolean) => {
5760
{ v: 'e' }
5861
]);
5962
const lastDoc = docs.docs[docs.docs.length - 1];
60-
return coll.limit(1).startAfter(lastDoc).get();
63+
return coll
64+
.limit(1)
65+
.startAfter(lastDoc)
66+
.get();
6167
})
6268
.then(docs => {
6369
expect(toDataArray(docs)).to.deep.equal([{ v: 'f' }]);
6470
const lastDoc = docs.docs[docs.docs.length - 1];
65-
return coll.limit(3).startAfter(lastDoc).get();
71+
return coll
72+
.limit(3)
73+
.startAfter(lastDoc)
74+
.get();
6675
})
6776
.then(docs => {
6877
expect(toDataArray(docs)).to.deep.equal([]);

packages/firestore/test/integration/api/database.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,16 @@ apiDescribe('Database', (persistence: boolean) => {
660660
it('inequality same as first orderBy works.', () => {
661661
return withTestCollection(persistence, {}, async coll => {
662662
expect(() =>
663-
coll.where('x', '>', 32).orderBy('x').orderBy('y')
663+
coll
664+
.where('x', '>', 32)
665+
.orderBy('x')
666+
.orderBy('y')
664667
).not.to.throw();
665668
expect(() =>
666-
coll.orderBy('x').where('x', '>', 32).orderBy('y')
669+
coll
670+
.orderBy('x')
671+
.where('x', '>', 32)
672+
.orderBy('y')
667673
).not.to.throw();
668674
});
669675
});

0 commit comments

Comments
 (0)