-
Notifications
You must be signed in to change notification settings - Fork 945
migrate Firestore to eslint #1859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
71f6e1c
ca4d4ec
92e04b1
3451ae5
6976753
1e83960
eb9fe81
f458b0f
2d4fd4b
8e5c68e
555119a
4ef6600
44cf6d1
d6c38c7
939e754
5ca728b
580bf03
bc5cc65
0f25fdf
540bbef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,9 @@ import { | |
validateStringEnum, | ||
valueDescription | ||
} from '../util/input_validation'; | ||
// eslint-disable-next-line import/no-duplicates | ||
import * as log from '../util/log'; | ||
// eslint-disable-next-line import/no-duplicates | ||
import { LogLevel } from '../util/log'; | ||
import { AutoId } from '../util/misc'; | ||
import * as objUtils from '../util/obj'; | ||
|
@@ -103,11 +105,6 @@ import { | |
UserDataConverter | ||
} from './user_data_converter'; | ||
|
||
// The objects that are a part of this API are exposed to third-parties as | ||
// compiled javascript so we want to flag our private members with a leading | ||
// underscore to discourage their use. | ||
// tslint:disable:strip-private-property-underscore | ||
|
||
// settings() defaults: | ||
const DEFAULT_HOST = 'firestore.googleapis.com'; | ||
const DEFAULT_SSL = true; | ||
|
@@ -158,7 +155,7 @@ class FirestoreSettings { | |
readonly forceLongPolling: boolean; | ||
|
||
// Can be a google-auth-library or gapi client. | ||
// tslint:disable-next-line:no-any | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
credentials?: any; | ||
|
||
constructor(settings: PrivateSettings) { | ||
|
@@ -298,6 +295,9 @@ class FirestoreConfig { | |
* The root reference to the database. | ||
*/ | ||
export class Firestore implements firestore.FirebaseFirestore, FirebaseService { | ||
// The objects that are a part of this API are exposed to third-parties as | ||
// compiled javascript so we want to flag our private members with a leading | ||
// underscore to discourage their use. | ||
private readonly _config: FirestoreConfig; | ||
readonly _databaseId: DatabaseId; | ||
|
||
|
@@ -480,7 +480,7 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService { | |
|
||
const databaseInfo = this.makeDatabaseInfo(); | ||
|
||
const preConverter = (value: unknown) => { | ||
const preConverter = (value: unknown): unknown => { | ||
if (value instanceof DocumentReference) { | ||
const thisDb = this._config.databaseId; | ||
const otherDb = value.firestore._config.databaseId; | ||
|
@@ -1116,7 +1116,7 @@ export class DocumentReference implements firestore.DocumentReference { | |
options: ListenOptions, | ||
observer: PartialObserver<firestore.DocumentSnapshot> | ||
): Unsubscribe { | ||
let errHandler = (err: Error) => { | ||
let errHandler = (err: Error): void => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to turn off the return-type enforcement for very simple functions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rule doesn't provide an option to do that currently. type ErrorHandler = (err: Error) => void;
let errHandler: ErrorHandler = (err) => {
...
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I vote option #1 then (leave as is in the current PR). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The TSLint rule had an option to ignore arrow functions, which I was using in Messaging and Installations. If this rule has a similar option, I think it's safe to enable that. |
||
console.error('Uncaught Error in onSnapshot:', err); | ||
}; | ||
if (observer.error) { | ||
|
@@ -1387,16 +1387,6 @@ export class DocumentSnapshot implements firestore.DocumentSnapshot { | |
|
||
export class QueryDocumentSnapshot extends DocumentSnapshot | ||
implements firestore.QueryDocumentSnapshot { | ||
constructor( | ||
firestore: Firestore, | ||
key: DocumentKey, | ||
document: Document, | ||
fromCache: boolean, | ||
hasPendingWrites: boolean | ||
) { | ||
super(firestore, key, document, fromCache, hasPendingWrites); | ||
} | ||
|
||
data(options?: SnapshotOptions): firestore.DocumentData { | ||
const data = super.data(options); | ||
assert( | ||
|
@@ -1860,7 +1850,7 @@ export class Query implements firestore.Query { | |
options: ListenOptions, | ||
observer: PartialObserver<firestore.QuerySnapshot> | ||
): Unsubscribe { | ||
let errHandler = (err: Error) => { | ||
let errHandler = (err: Error): void => { | ||
console.error('Uncaught Error in onSnapshot:', err); | ||
}; | ||
if (observer.error) { | ||
|
@@ -1882,7 +1872,7 @@ export class Query implements firestore.Query { | |
asyncObserver, | ||
options | ||
); | ||
return () => { | ||
return (): void => { | ||
asyncObserver.mute(); | ||
firestoreClient.unlisten(internalListener); | ||
}; | ||
|
@@ -2417,7 +2407,6 @@ function resultChangeType(type: ChangeType): firestore.DocumentChangeType { | |
|
||
// We're treating the variables as class names, so disable checking for lower | ||
// case variable names. | ||
// tslint:disable:variable-name | ||
export const PublicFirestore = makeConstructorPrivate( | ||
Firestore, | ||
'Use firebase.firestore() instead.' | ||
|
@@ -2444,4 +2433,3 @@ export const PublicCollectionReference = makeConstructorPrivate( | |
CollectionReference, | ||
'Use firebase.firestore().collection() instead.' | ||
); | ||
// tslint:enable:variable-name |
Uh oh!
There was an error while loading. Please reload this page.