Skip to content

Commit 4016987

Browse files
authored
replace some tslint rules with eslint rules (#2161)
* use eslint no-floating-promise * replace tslint ban with eslint rules * [AUTOMATED]: Prettier Code Styling * eslint disable * fix lint * revert previous changes * fix lint for firestore * [AUTOMATED]: Prettier Code Styling
1 parent 20e8a07 commit 4016987

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+282
-189
lines changed

config/.eslintrc.json

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,37 @@
8282
"boolean"
8383
],
8484
"constructor-super": "error",
85+
"no-restricted-properties": [
86+
"error",
87+
{
88+
"object": "it",
89+
"property": "skip"
90+
}
91+
,
92+
{
93+
"object": "it",
94+
"property": "only"
95+
},
96+
{
97+
"object": "describe",
98+
"property": "skip"
99+
},
100+
{
101+
"object": "describe",
102+
"property": "only"
103+
},
104+
{
105+
"object": "xit"
106+
}
107+
],
108+
"no-restricted-globals": [
109+
"error",
110+
{"name": "xit"},
111+
{"name": "xdescribe"},
112+
{"name": "parseInt", "message": "tsstyle#type-coercion"},
113+
{"name": "parseFloat", "message": "tsstyle#type-coercion"}
114+
],
115+
"no-array-constructor": "error",
85116
"import/no-default-export": "error",
86117
"import/no-duplicates": "error",
87118
"import/no-extraneous-dependencies": [
@@ -166,23 +197,12 @@
166197
"argsIgnorePattern": "^_"
167198
}
168199
],
200+
"@typescript-eslint/no-floating-promises": "error",
169201
"@typescript-eslint/tslint/config": [
170202
"error",
171203
{
172-
"rules": {
173-
"ban": [true,
174-
{"name": ["it", "skip"]},
175-
{"name": ["it", "only"]},
176-
{"name": ["describe", "skip"]},
177-
{"name": ["describe", "only"]},
178-
{"name": ["xit"]},
179-
{"name": ["xdescribe"]},
180-
{"name": "parseInt", "message": "tsstyle#type-coercion"},
181-
{"name": "parseFloat", "message": "tsstyle#type-coercion"},
182-
{"name": "Array", "message": "tsstyle#array-constructor"}
183-
],
204+
"rules": {
184205
"jsdoc-format": true,
185-
"no-floating-promises": true,
186206
"arrow-return-shorthand": true
187207
}
188208
}

packages/app/.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
extends: '../../config/.eslintrc.json',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
// to make vscode-eslint work with monorepo
6+
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
7+
tsconfigRootDir: __dirname
8+
}
9+
};

packages/app/.eslintrc.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"lint": "eslint -c .eslintrc.json '**/*.ts' --ignore-path '../../.gitignore'",
18-
"lint:fix": "eslint --fix -c .eslintrc.json '**/*.ts' --ignore-path '../../.gitignore'",
17+
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
18+
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1919
"build": "rollup -c",
2020
"dev": "rollup -c -w",
2121
"test": "run-p lint test:browser test:node",

packages/app/test/firebaseApp.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function executeFirebaseTests(): void {
5858
const app = firebase.initializeApp({});
5959
// Ensure the hook is called synchronously
6060
assert.equal(hookEvents, 1);
61-
// tslint:disable-next-line:no-floating-promises
61+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
6262
app.delete();
6363
});
6464

@@ -173,7 +173,7 @@ function executeFirebaseTests(): void {
173173
);
174174
// Ensure the hook is called synchronously
175175
assert.equal(hookEvents, 1);
176-
// tslint:disable-next-line:no-floating-promises
176+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
177177
app.delete();
178178
});
179179

packages/firestore/.eslintrc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
extends: '../../config/.eslintrc.json',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
// to make vscode-eslint work with monorepo
6+
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
7+
tsconfigRootDir: __dirname
8+
},
9+
plugins: ['import'],
10+
rules: {
11+
'no-console': ['error', { allow: ['warn', 'error'] }],
12+
'import/no-default-export': 'error',
13+
'@typescript-eslint/no-unused-vars': [
14+
'error',
15+
{
16+
varsIgnorePattern: '^_',
17+
args: 'none'
18+
}
19+
]
20+
},
21+
overrides: [
22+
{
23+
files: ['**/*.test.ts', '**/test/**/*.ts'],
24+
rules: {
25+
'@typescript-eslint/no-explicit-any': 'error'
26+
}
27+
}
28+
]
29+
};

packages/firestore/.eslintrc.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/firestore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"build": "rollup -c",
88
"build:console": "node tools/console.build.js",
99
"dev": "rollup -c -w",
10-
"lint": "eslint -c .eslintrc.json '**/*.ts' --ignore-path '../../.gitignore'",
11-
"lint:fix": "eslint --fix -c .eslintrc.json '**/*.ts' --ignore-path '../../.gitignore'",
10+
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
11+
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1212
"prettier": "prettier --write 'src/**/*.js' 'test/**/*.js' 'src/**/*.ts' 'test/**/*.ts'",
1313
"test": "run-s lint test:all",
1414
"test:all": "run-p test:browser test:travis",

packages/firestore/src/api/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService {
507507
ensureClientConfigured(): FirestoreClient {
508508
if (!this._firestoreClient) {
509509
// Kick off starting the client but don't actually wait for it.
510-
// tslint:disable-next-line:no-floating-promises
510+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
511511
this.configureClient(new MemoryPersistenceSettings());
512512
}
513513
return this._firestoreClient as FirestoreClient;

packages/firestore/src/util/async_queue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export class AsyncQueue {
223223
* we ignore the Promise result).
224224
*/
225225
enqueueAndForget<T extends unknown>(op: () => Promise<T>): void {
226-
// tslint:disable-next-line:no-floating-promises
226+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
227227
this.enqueue(op);
228228
}
229229

@@ -235,7 +235,7 @@ export class AsyncQueue {
235235
op: () => Promise<T>
236236
): void {
237237
this.verifyNotFailed();
238-
// tslint:disable-next-line:no-floating-promises
238+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
239239
this.enqueueInternal(op);
240240
}
241241

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ apiDescribe('Array Transforms:', (persistence: boolean) => {
152152
* an updated document via watch). As such they also rely on persistence
153153
* being enabled so documents remain in the cache after the write.
154154
*/
155+
// eslint-disable-next-line no-restricted-properties
155156
(persistence ? describe : describe.skip)('Server Application: ', () => {
156157
it('set() with no cached base doc', async () => {
157158
await withTestDoc(persistence, async docRef => {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ apiDescribe('Database batch writes', (persistence: boolean) => {
163163
.then(initialSnap => {
164164
expect(initialSnap.docs.length).to.equal(0);
165165

166-
// Atomically write two documents.
166+
// eslint-disable-next-line @typescript-eslint/no-floating-promises, Atomically write two documents.
167167
collection.firestore
168168
.batch()
169169
.set(docA, { a: 1 })
@@ -275,7 +275,7 @@ apiDescribe('Database batch writes', (persistence: boolean) => {
275275
.then(initialSnap => {
276276
expect(initialSnap.docs.length).to.equal(0);
277277

278-
// Atomically write 2 documents with server timestamps.
278+
// eslint-disable-next-line @typescript-eslint/no-floating-promises, Atomically write 2 documents with server timestamps.
279279
collection.firestore
280280
.batch()
281281
.set(docA, {
@@ -325,7 +325,7 @@ apiDescribe('Database batch writes', (persistence: boolean) => {
325325
.awaitEvent()
326326
.then(initialSnap => {
327327
expect(initialSnap.exists).to.equal(false);
328-
328+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
329329
doc.firestore
330330
.batch()
331331
.delete(doc)

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ apiDescribe('Database', (persistence: boolean) => {
126126
});
127127
});
128128

129+
// eslint-disable-next-line no-restricted-properties
129130
(persistence ? it : it.skip)('can update an unknown document', () => {
130131
return withTestDbs(persistence, 2, async ([reader, writer]) => {
131132
const writerRef = writer.collection('collection').doc();
@@ -346,6 +347,7 @@ apiDescribe('Database', (persistence: boolean) => {
346347
it("can't specify a field mask for a missing field using set", () => {
347348
return withTestDoc(persistence, async docRef => {
348349
expect(() => {
350+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
349351
docRef.set(
350352
{ desc: 'NewDescription' },
351353
{ mergeFields: ['desc', 'owner'] }
@@ -775,6 +777,7 @@ apiDescribe('Database', (persistence: boolean) => {
775777
const doc = coll.doc();
776778
const deferred1 = new Deferred<void>();
777779
const deferred2 = new Deferred<void>();
780+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
778781
doc.set({ foo: 'bar' }).then(() => {
779782
doc.onSnapshot(snap => {
780783
deferred1.resolve();
@@ -802,8 +805,9 @@ apiDescribe('Database', (persistence: boolean) => {
802805
}
803806
}
804807
});
805-
808+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
806809
docRef.set({ a: 1 }).then(() => {
810+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
807811
docRef.set({ b: 1 });
808812
});
809813
return secondUpdateFound.promise.then(() => {
@@ -815,7 +819,7 @@ apiDescribe('Database', (persistence: boolean) => {
815819
// TODO(mikelehen): We need a way to create a query that will pass
816820
// client-side validation but fail remotely. May need to wait until we
817821
// have security rules support or something?
818-
// tslint:disable-next-line:ban
822+
// eslint-disable-next-line no-restricted-properties
819823
describe.skip('Listens are rejected remotely:', () => {
820824
const queryForRejection = query('foo');
821825

@@ -998,12 +1002,14 @@ apiDescribe('Database', (persistence: boolean) => {
9981002
return withTestDb(persistence, db => {
9991003
return db.INTERNAL.delete().then(() => {
10001004
expect(() => {
1005+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
10011006
db.disableNetwork();
10021007
}).to.throw('The client has already been terminated.');
10031008
});
10041009
});
10051010
});
10061011

1012+
// eslint-disable-next-line no-restricted-properties
10071013
(persistence ? it : it.skip)(
10081014
'maintains persistence after restarting app',
10091015
async () => {
@@ -1024,6 +1030,7 @@ apiDescribe('Database', (persistence: boolean) => {
10241030
}
10251031
);
10261032

1033+
// eslint-disable-next-line no-restricted-properties
10271034
(persistence ? it : it.skip)(
10281035
'can clear persistence if the client has not been initialized',
10291036
async () => {
@@ -1047,6 +1054,7 @@ apiDescribe('Database', (persistence: boolean) => {
10471054
}
10481055
);
10491056

1057+
// eslint-disable-next-line no-restricted-properties
10501058
(persistence ? it : it.skip)(
10511059
'will reject the promise if clear persistence fails',
10521060
async () => {
@@ -1144,6 +1152,7 @@ apiDescribe('Database', (persistence: boolean) => {
11441152
await firestore.terminate();
11451153

11461154
expect(() => {
1155+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
11471156
firestore.doc(docRef.path).set({ foo: 'bar' });
11481157
}).to.throw('The client has already been terminated.');
11491158
});
@@ -1156,6 +1165,7 @@ apiDescribe('Database', (persistence: boolean) => {
11561165
await firestore.terminate();
11571166

11581167
expect(() => {
1168+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
11591169
firestore.doc(docRef.path).set({ foo: 'bar' });
11601170
}).to.throw();
11611171
});
@@ -1198,6 +1208,7 @@ apiDescribe('Database', (persistence: boolean) => {
11981208
async (db, mockCredentialsProvider) => {
11991209
// Prevent pending writes receiving acknowledgement.
12001210
await db.disableNetwork();
1211+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
12011212
db.doc('abc/123').set({ foo: 'bar' });
12021213
const awaitPendingWrite = db.waitForPendingWrites();
12031214

0 commit comments

Comments
 (0)