Skip to content

Commit 9611fd7

Browse files
renovate[bot]renovate-botFeiyang1
authored
Update typescript-eslint monorepo to v3 (major) (firebase#3524)
* Update typescript-eslint monorepo to v3 * Update typescript-eslint monorepo to v3 * fix lint * fix more lint * remove reference to the removed file * revert file deletion Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Feiyang1 <[email protected]>
1 parent e749ab8 commit 9611fd7

File tree

29 files changed

+196
-63
lines changed

29 files changed

+196
-63
lines changed

config/.eslintrc.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
const path = require('path');
219

320
module.exports = {
@@ -128,12 +145,29 @@ module.exports = {
128145
'Object': "Use {} or 'object' instead.",
129146
'String': "Use 'string' instead.",
130147
'Number': "Use 'number' instead.",
131-
'Boolean': "Use 'boolean' instead."
148+
'Boolean': "Use 'boolean' instead.",
149+
'Function': `Avoid the Function type, as it provides little safety for the following reasons:
150+
It provides no type safety when calling the value, which means it's easy to provide the wrong arguments.
151+
It accepts class declarations, which will fail when called, as they are called without the new keyword.`
152+
},
153+
'extendDefaults': false
154+
}
155+
],
156+
'@typescript-eslint/naming-convention': [
157+
'error',
158+
{
159+
'selector': 'class',
160+
'format': ['PascalCase']
161+
},
162+
{
163+
'selector': 'interface',
164+
'format': ['PascalCase'],
165+
'custom': {
166+
'regex': '^I[A-Z]',
167+
'match': false
132168
}
133169
}
134170
],
135-
'@typescript-eslint/class-name-casing': 'error',
136-
'@typescript-eslint/interface-name-prefix': ['error', 'never'],
137171
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
138172
'@typescript-eslint/explicit-member-accessibility': [
139173
'error',

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
"@types/sinon-chai": "3.2.4",
8484
"@types/tmp": "0.2.0",
8585
"@types/yargs": "15.0.5",
86-
"@typescript-eslint/eslint-plugin": "2.34.0",
87-
"@typescript-eslint/eslint-plugin-tslint": "2.34.0",
88-
"@typescript-eslint/parser": "2.34.0",
86+
"@typescript-eslint/eslint-plugin": "3.10.1",
87+
"@typescript-eslint/eslint-plugin-tslint": "3.10.1",
88+
"@typescript-eslint/parser": "3.10.1",
8989
"babel-loader": "8.1.0",
9090
"chai": "4.2.0",
9191
"chai-as-promised": "7.1.1",

packages-exp/functions-exp/src/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export function _errorForResponse(
151151

152152
details = errorJSON.details;
153153
if (details !== undefined) {
154-
details = decode(details as {} | null);
154+
details = decode(details);
155155
}
156156
}
157157
} catch (e) {

packages-exp/functions-exp/src/serializer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function encode(data: unknown): unknown {
6060
return data.map(x => encode(x));
6161
}
6262
if (typeof data === 'function' || typeof data === 'object') {
63-
return mapValues(data as object, x => encode(x));
63+
return mapValues(data!, x => encode(x));
6464
}
6565
// If we got this far, the data is not encodable.
6666
throw new Error('Data cannot be encoded in JSON: ' + data);
@@ -99,7 +99,7 @@ export function decode(json: unknown): unknown {
9999
return json.map(x => decode(x));
100100
}
101101
if (typeof json === 'function' || typeof json === 'object') {
102-
return mapValues(json as object, x => decode(x as {} | null));
102+
return mapValues(json!, x => decode(x));
103103
}
104104
// Anything else is safe to return.
105105
return json;

packages-exp/functions-exp/src/service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class FunctionsService implements _FirebaseService {
7474
readonly contextProvider: ContextProvider;
7575
emulatorOrigin: string | null = null;
7676
cancelAllRequests: Promise<void>;
77-
deleteService!: Function;
77+
deleteService!: () => Promise<void>;
7878

7979
/**
8080
* Creates a new Functions service for the given app.
@@ -90,7 +90,7 @@ export class FunctionsService implements _FirebaseService {
9090
// Cancels all ongoing requests when resolved.
9191
this.cancelAllRequests = new Promise(resolve => {
9292
this.deleteService = () => {
93-
return resolve();
93+
return Promise.resolve(resolve());
9494
};
9595
});
9696
}
@@ -154,7 +154,7 @@ export function httpsCallable(
154154
*/
155155
async function postJSON(
156156
url: string,
157-
body: {},
157+
body: unknown,
158158
headers: Headers
159159
): Promise<HttpResponse> {
160160
headers.append('Content-Type', 'application/json');
@@ -176,7 +176,7 @@ async function postJSON(
176176
json: null
177177
};
178178
}
179-
let json: {} | null = null;
179+
let json: HttpResponseBody | null = null;
180180
try {
181181
json = await response.json();
182182
} catch (e) {
@@ -254,7 +254,7 @@ async function call(
254254
}
255255

256256
// Decode any special types, such as dates, in the returned data.
257-
const decodedData = decode(responseData as {} | null);
257+
const decodedData = decode(responseData);
258258

259259
return { data: decodedData };
260260
}

packages/analytics/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function getOrCreateDataLayer(dataLayerName: string): DataLayer {
9595
function wrapGtag(
9696
gtagCore: Gtag,
9797
initializedIdPromisesMap: { [gaId: string]: Promise<void> }
98-
): Function {
98+
): Gtag {
9999
return (
100100
command: 'config' | 'set' | 'event',
101101
idOrNameOrParams: string | ControlParams,

packages/analytics/testing/get-fake-firebase-services.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export function getFakeApp(measurementId?: string): FirebaseApp {
4242

4343
export function getFakeInstallations(
4444
fid: string = 'fid-1234',
45+
// eslint-disable-next-line @typescript-eslint/ban-types
4546
onFidResolve?: Function
4647
): FirebaseInstallations {
4748
return {

packages/database/.eslintrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
module.exports = {
219
extends: '../../config/.eslintrc.js',
320
parserOptions: {

packages/database/src/core/util/util.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ export function each(obj: object, fn: (k: string, v: unknown) => void) {
428428
export const bindCallback = function (
429429
callback: (a: unknown) => void,
430430
context?: object | null
431-
): Function {
431+
): (a: unknown) => void {
432432
return context ? callback.bind(context) : callback;
433433
};
434434

@@ -609,6 +609,7 @@ export const exceptionGuard = function (fn: () => void) {
609609
* @param {...*} varArgs Arbitrary args to be passed to opt_onComplete
610610
*/
611611
export const callUserCallback = function (
612+
// eslint-disable-next-line @typescript-eslint/ban-types
612613
callback?: Function | null,
613614
...varArgs: unknown[]
614615
) {
@@ -665,7 +666,7 @@ export const exportPropGetter = function (
665666
* @return {number|Object} The setTimeout() return value.
666667
*/
667668
export const setTimeoutNonBlocking = function (
668-
fn: Function,
669+
fn: () => void,
669670
time: number
670671
): number | object {
671672
const timeout: number | object = setTimeout(fn, time);

packages/database/src/core/view/CompleteChildSource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface CompleteChildSource {
5656
* @constructor
5757
* @implements CompleteChildSource
5858
*/
59-
// eslint-disable-next-line @typescript-eslint/class-name-casing
59+
// eslint-disable-next-line @typescript-eslint/naming-convention
6060
export class NoCompleteChildSource_ implements CompleteChildSource {
6161
/**
6262
* @inheritDoc

0 commit comments

Comments
 (0)