Skip to content

Commit bd4c662

Browse files
committed
enable no-explicit-any in test files
1 parent 38e9b99 commit bd4c662

20 files changed

+43
-29
lines changed

packages/firestore/.eslintrc.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,16 @@
1616
"args": "none"
1717
}
1818
]
19-
}
19+
},
20+
"overrides": [
21+
{
22+
"files": [
23+
"**/*.test.ts",
24+
"**/test/**/*.ts"
25+
],
26+
"rules": {
27+
"@typescript-eslint/no-explicit-any": "error"
28+
}
29+
}
30+
]
2031
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,9 @@ apiDescribe('Database', (persistence: boolean) => {
517517
for (const val of invalidDocValues) {
518518
it('set/update should reject: ' + val, () => {
519519
return withTestDoc(persistence, async doc => {
520-
// tslint:disable-next-line:no-any Intentionally passing bad types.
520+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, Intentionally passing bad types.
521521
expect(() => doc.set(val as any)).to.throw();
522-
// tslint:disable-next-line:no-any Intentionally passing bad types.
522+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, Intentionally passing bad types.
523523
expect(() => doc.update(val as any)).to.throw();
524524
});
525525
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const FieldPath = firebase.firestore!.FieldPath;
3131
const FieldValue = firebase.firestore!.FieldValue;
3232
const Timestamp = firebase.firestore!.Timestamp;
3333

34-
// tslint:disable-next-line:no-any Allow custom types for testing.
34+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, Allow custom types for testing.
3535
type AnyTestData = any;
3636

3737
apiDescribe('Nested Fields', (persistence: boolean) => {
@@ -346,7 +346,7 @@ apiDescribe('Fields with special characters', (persistence: boolean) => {
346346
});
347347

348348
apiDescribe('Timestamp Fields in snapshots', (persistence: boolean) => {
349-
// tslint:disable-next-line:no-any Figure out how to pass in the Timestamp type
349+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, Figure out how to pass in the Timestamp type
350350
const testDataWithTimestamps = (ts: any): AnyTestData => {
351351
return { timestamp: ts, nested: { timestamp2: ts } };
352352
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ apiDescribe('Queries', (persistence: boolean) => {
627627
const expectedError =
628628
'QuerySnapshot.docChanges has been changed from a property into a method';
629629

630-
// tslint:disable-next-line:no-any We are testing invalid API usage.
630+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, We are testing invalid API usage.
631631
const docChange = querySnap.docChanges as any;
632632
expect(() => docChange.length).to.throw(expectedError);
633633
expect(() => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { apiDescribe, withTestDoc } from '../util/helpers';
2424

2525
// tslint:disable:no-floating-promises
2626

27-
// tslint:disable-next-line:no-any Allow custom types for testing.
27+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, Allow custom types for testing.
2828
type AnyTestData = any;
2929

3030
const Timestamp = firebase.firestore!.Timestamp;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ apiDescribe('Database transactions', (persistence: boolean) => {
487487

488488
for (const badReturn of badReturns) {
489489
it(badReturn + ' is rejected', () => {
490-
// tslint:disable-next-line:no-any Intentionally returning bad type.
490+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, Intentionally returning bad type.
491491
const fn = ((txn: firestore.Transaction) => badReturn) as any;
492492
return integrationHelpers.withTestDb(persistence, db => {
493493
return db

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const FieldPath = firebase.firestore!.FieldPath;
3838
const FieldValue = firebase.firestore!.FieldValue;
3939

4040
// We're using 'as any' to pass invalid values to APIs for testing purposes.
41-
// tslint:disable:no-any
41+
/* eslint-disable @typescript-eslint/no-explicit-any */
4242

4343
interface ValidationIt {
4444
(

packages/firestore/test/integration/bootstrap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import '../../index';
2525
*/
2626

2727
// 'context()' definition requires additional dependency on webpack-env package.
28+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2829
const testsContext = (require as any).context('.', true, /.test$/);
2930
const browserTests = testsContext
3031
.keys()

packages/firestore/test/integration/util/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import firebase from './firebase_export';
2424
* dependencies on src/ files.
2525
*/
2626

27-
// __karma__ is an untyped global
27+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, __karma__ is an untyped global
2828
declare const __karma__: any;
2929

3030
// eslint-disable-next-line @typescript-eslint/no-require-imports

packages/firestore/test/unit/api/blob.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('Blob', () => {
5858
});
5959

6060
it('Blob throws on using the public constructor', () => {
61-
// tslint:disable-next-line:no-any allow using constructor with any
61+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, allow using constructor with any
6262
expect(() => new (PublicBlob as any)('')).to.throw(
6363
'This constructor is private. Use Blob.fromUint8Array() or ' +
6464
'Blob.fromBase64String() instead.'

packages/firestore/test/unit/bootstrap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import '../../src/platform_browser/browser_init';
2525
*/
2626

2727
// 'context()' definition requires additional dependency on webpack-env package.
28+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2829
const testsContext = (require as any).context('.', true, /.test$/);
2930
const browserTests = testsContext
3031
.keys()

packages/firestore/test/unit/core/event_manager.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
} from '../../util/helpers';
4040

4141
describe('EventManager', () => {
42-
// tslint:disable-next-line:no-any mock object.
42+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, mock object.
4343
function fakeQueryListener(query: Query): any {
4444
return {
4545
query,
@@ -49,7 +49,7 @@ describe('EventManager', () => {
4949
};
5050
}
5151

52-
// tslint:disable-next-line:no-any mock object.
52+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, mock object.
5353
function makeSyncEngineSpy(): any {
5454
const stub = {
5555
listen: sinon.stub().returns(Promise.resolve(0)),
@@ -115,9 +115,9 @@ describe('EventManager', () => {
115115
await eventManager.listen(fakeListener3);
116116
expect(syncEngineSpy.listen.callCount).to.equal(2);
117117

118-
// tslint:disable-next-line:no-any mock ViewSnapshot.
118+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, mock ViewSnapshot.
119119
const viewSnap1: any = { query: query1 };
120-
// tslint:disable-next-line:no-any mock ViewSnapshot.
120+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, mock ViewSnapshot.
121121
const viewSnap2: any = { query: query2 };
122122
eventManager.onWatchChange([viewSnap1, viewSnap2]);
123123

packages/firestore/test/unit/local/indexeddb_persistence.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => {
228228

229229
return (
230230
targets
231-
// tslint:disable-next-line:no-any
231+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
232232
.put({ targetId, canonicalId: 'foo' } as any)
233233
.next(() =>
234234
targetGlobal.put(DbTargetGlobal.key, dummyTargetGlobal)
@@ -335,7 +335,7 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => {
335335
);
336336
p = p.next(() => {
337337
store
338-
.add({} as any) // tslint:disable-line:no-any
338+
.add({} as any) // eslint-disable-line @typescript-eslint/no-explicit-any
339339
.next(batchId => {
340340
expect(batchId).to.equal(43);
341341
});

packages/firestore/test/unit/local/lru_garbage_collector.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function genericLruGarbageCollectorTests(
122122
);
123123
const referenceDelegate = persistence.referenceDelegate;
124124
referenceDelegate.setInMemoryPins(new ReferenceSet());
125-
// tslint:disable-next-line:no-any
125+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
126126
garbageCollector = ((referenceDelegate as any) as LruDelegate)
127127
.garbageCollector;
128128
}

packages/firestore/test/unit/local/web_storage_shared_client_state.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ describe('WebStorageSharedClientState', () => {
645645
new MutationMetadata(
646646
AUTHENTICATED_USER,
647647
1,
648-
'invalid' as any // tslint:disable-line:no-any
648+
'invalid' as any // eslint-disable-line @typescript-eslint/no-explicit-any
649649
).toWebStorageJSON()
650650
);
651651
}).then(clientState => {
@@ -802,7 +802,7 @@ describe('WebStorageSharedClientState', () => {
802802
targetKey(firstClientTargetId),
803803
new QueryTargetMetadata(
804804
firstClientTargetId,
805-
'invalid' as any // tslint:disable-line:no-any
805+
'invalid' as any // eslint-disable-line @typescript-eslint/no-explicit-any
806806
).toWebStorageJSON()
807807
);
808808
}).then(clientState => {

packages/firestore/test/unit/remote/node/serializer.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ describe('Serializer', () => {
11811181
addEqualityMatcher();
11821182

11831183
it('contains all Operators', () => {
1184-
// tslint:disable-next-line:no-any giant hack
1184+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, giant hack
11851185
obj.forEach(Operator as any, (name, op) => {
11861186
if (op instanceof Operator) {
11871187
expect(s.toOperatorName(op), 'for name').to.exist;
@@ -1195,7 +1195,7 @@ describe('Serializer', () => {
11951195
addEqualityMatcher();
11961196

11971197
it('contains all Directions', () => {
1198-
// tslint:disable-next-line:no-any giant hack
1198+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, giant hack
11991199
obj.forEach(Direction as any, (name, dir) => {
12001200
if (dir instanceof Direction) {
12011201
expect(s.toDirection(dir), 'for ' + name).to.exist;

packages/firestore/test/unit/specs/spec_test_runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class MockConnection implements Connection {
258258
}
259259
});
260260
this.writeStream = writeStream;
261-
// Replace 'any' with conditional types.
261+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, Replace 'any' with conditional types.
262262
return writeStream as any;
263263
} else {
264264
assert(rpcName === 'Listen', 'Unexpected rpc name: ' + rpcName);
@@ -292,7 +292,7 @@ class MockConnection implements Connection {
292292
}
293293
});
294294
this.watchStream = watchStream;
295-
// Replace 'any' with conditional types.
295+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, Replace 'any' with conditional types.
296296
return this.watchStream as any;
297297
}
298298
}

packages/firestore/test/util/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ export class DocComparator {
556556
/**
557557
* Two helper functions to simplify testing isEqual() method.
558558
*/
559-
// use any type so we can dynamically call .isEqual().
559+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, so we can dynamically call .isEqual().
560560
export function expectEqual(left: any, right: any, message?: string): void {
561561
message = message || '';
562562
if (typeof left.isEqual !== 'function') {
@@ -573,7 +573,7 @@ export function expectEqual(left: any, right: any, message?: string): void {
573573
expect(right.isEqual(left)).to.equal(true, message);
574574
}
575575

576-
// use any so we can dynamically call .isEqual().
576+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, so we can dynamically call .isEqual().
577577
export function expectNotEqual(left: any, right: any, message?: string): void {
578578
expect(left.isEqual(right)).to.equal(false, message || '');
579579
expect(right.isEqual(left)).to.equal(false, message || '');

packages/firestore/test/util/node_persistence.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { FakeWindow, SharedFakeWebStorage } from './test_platform';
2929
// To use this code to run persistence-based tests in Node, include this module
3030
// and set the environment variable `USE_MOCK_PERSISTENCE` to `YES`.
3131

32+
// eslint-disable-next-line @typescript-eslint/no-explicit-any,
3233
const globalAny = global as any;
3334

3435
const dbDir = fs.mkdtempSync(os.tmpdir() + '/firestore_tests');

packages/firestore/test/util/test_platform.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export class SharedFakeWebStorage {
199199
oldValue,
200200
newValue,
201201
storageArea: client.storageArea
202-
} as any); // Not mocking entire Event type.
202+
} as any); // eslint-disable-line @typescript-eslint/no-explicit-any, Not mocking entire Event type.
203203
});
204204
}
205205
}
@@ -220,12 +220,12 @@ export class TestPlatform implements Platform {
220220
}
221221

222222
get document(): Document | null {
223-
// FakeWindow doesn't support full Document interface.
223+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, FakeWindow doesn't support full Document interface.
224224
return this.mockDocument as any;
225225
}
226226

227227
get window(): Window | null {
228-
// FakeWindow doesn't support full Window interface.
228+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, FakeWindow doesn't support full Window interface.
229229
return this.mockWindow as any;
230230
}
231231

0 commit comments

Comments
 (0)