From d065c5666ee2d2bf31e2d89bfa32b863c6d493ef Mon Sep 17 00:00:00 2001 From: Jordan Janzen Date: Thu, 17 May 2018 17:51:13 -0700 Subject: [PATCH] Fix linting errors. --- types/re-base/index.d.ts | 96 ++++++++++--------------------------- types/re-base/tsconfig.json | 14 ++---- types/re-base/tslint.json | 8 +++- 3 files changed, 36 insertions(+), 82 deletions(-) diff --git a/types/re-base/index.d.ts b/types/re-base/index.d.ts index 928bca7c47..5934b67295 100644 --- a/types/re-base/index.d.ts +++ b/types/re-base/index.d.ts @@ -3,27 +3,7 @@ // Definitions by: jordandrako // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface QueryOptions {} - -interface RebaseBinding {} - -declare namespace firebase { - -} - -declare namespace firebase.app { - interface App {} -} - -declare namespace firebase.database { - interface Database {} -} - -declare namespace firebase.firestore { - class Firestore {} -} - -declare namespace rebase { +export namespace rebase { interface SyncStateOptions { /** * The context of your component. @@ -53,7 +33,7 @@ declare namespace rebase { /** * Queries to be used with your read operations. See [Query Options](https://github.com/tylermcginnis/re-base#queries) for more details. */ - queries?: QueryOptions; + queries?: {}; /** * The callback function that will be invoked when the initial listener is established with Firebase. Typically used (with syncState) to change this.state.loading to false. @@ -85,7 +65,7 @@ declare namespace rebase { /** * Queries to be used with your read operations. See [Query Options](https://github.com/tylermcginnis/re-base#queries) for more details. */ - queries?: QueryOptions; + queries?: {}; /** * The callback function that will be invoked when the initial listener is established with Firebase. Typically used (with bindToState) to change this.state.loading to false. @@ -122,7 +102,7 @@ declare namespace rebase { /** * Queries to be used with your read operations. See [Query Options](https://github.com/tylermcginnis/re-base#queries) for more details. */ - queries?: QueryOptions; + queries?: {}; } interface FetchOptions { @@ -149,7 +129,7 @@ declare namespace rebase { /** * Queries to be used with your read operations. See [Query Options](https://github.com/tylermcginnis/re-base#queries) for more details. */ - queries?: QueryOptions; + queries?: {}; } interface PostOptions { @@ -188,10 +168,6 @@ declare namespace rebase { then?: (result: any) => void; } - interface DocumentReference {} - - interface CollectionReference {} - interface bindDocOptions { /** * Your react component. @@ -350,7 +326,7 @@ declare namespace rebase { /** * This property contains the initialized firebase app that was passed into re-base. You can access any of the firebase services that you are using off this object. For instance, if you want to use some firebase database methods that re-base doesn't have helpers for or if you are using the auth service and want to quickly access it off of re-base. */ - initializedApp: firebase.app.App; + initializedApp: {}; /** * This property contains an object that you can use when adding data that will be converted to a timestamp by Firebase. See [the docs](https://firebase.google.com/docs/reference/js/firebase.database.ServerValue) for more info. @@ -363,7 +339,7 @@ declare namespace rebase { * @param options syncState Options. * @returns An object which you can pass to `removeBinding` if you want to remove the listener while the component is still mounted. */ - syncState(endpoint: string, options: SyncStateOptions): RebaseBinding; + syncState(endpoint: string, options: SyncStateOptions): {}; /** * One way data binding from Firebase to your component's state. Allows you to bind a component's state property to a Firebase endpoint so whenever that Firebase endpoint changes, your component's state will be updated with that change. @@ -371,10 +347,7 @@ declare namespace rebase { * @param options bindToState Options. * @returns An object which you can pass to removeBinding if you want to remove the listener while the component is still mounted. */ - bindToState( - endpoint: string, - options: BindToStateOptions - ): RebaseBinding; + bindToState(endpoint: string, options: BindToStateOptions): {}; /** * Allows you to listen to Firebase endpoints without binding those changes to a state property. Instead, a callback will be invoked with the newly updated data. @@ -382,7 +355,7 @@ declare namespace rebase { * @param options listenTo Options. * @returns An object which you can pass to removeBinding when your component unmounts to remove the Firebase listeners. */ - listenTo(endpoint: string, options: ListenToOptions): RebaseBinding; + listenTo(endpoint: string, options: ListenToOptions): {}; /** * Allows you to retrieve the data from a Firebase endpoint just once without subscribing or listening for data changes. @@ -433,10 +406,7 @@ declare namespace rebase { * @param options bindDoc Options. * @returns An object which you can pass to `removeBinding` if you want to remove the listener while the component is still mounted. */ - bindDoc( - refOrPath: DocumentReference | string, - options: bindDocOptions - ): RebaseBinding; + bindDoc(refOrPath: {} | string, options: bindDocOptions): {}; /** * Listen to a document, when the data changes it will invoke a callback passing it the new data from Firestore. @@ -444,10 +414,7 @@ declare namespace rebase { * @param options listenToDoc Options. * @returns An object which you can pass to `removeBinding` if you want to remove the listener while the component is still mounted. */ - listenToDoc( - refOrPath: DocumentReference | string, - options: listenToDocOptions - ): RebaseBinding; + listenToDoc(refOrPath: {} | string, options: listenToDocOptions): {}; /** * Bind a collection to a state property in your component. When then collection changes in firestore, your component will re-render with the latest data. @@ -456,9 +423,9 @@ declare namespace rebase { * @returns An object which you can pass to `removeBinding` if you want to remove the listener while the component is still mounted. */ bindCollection( - refOrPath: CollectionReference | string, + refOrPath: {} | string, options: bindCollectionOptions - ): RebaseBinding; + ): {}; /** * Listen to a collection, when the data changes it will invoke a callback passing it the new data from Firestore. @@ -467,9 +434,9 @@ declare namespace rebase { * @returns An object which you can pass to `removeBinding` if you want to remove the listener while the component is still mounted. */ listenToCollection( - refOrPath: CollectionReference | string, + refOrPath: {} | string, options: listenToCollectionOptions - ): RebaseBinding; + ): {}; /** * Fetch either a Collection or Document. @@ -478,7 +445,7 @@ declare namespace rebase { * @returns A Promise thats resolve with the resulting data or rejects if the document/collection does not exist or there are any read errors. */ get( - refOrPath: CollectionReference | DocumentReference | string, + refOrPath: {} | {} | string, options: listenToCollectionOptions ): Promise; @@ -490,7 +457,7 @@ declare namespace rebase { * @returns A Promise thats resolve with the resulting data or rejects if the document/collection does not exist or there are any read errors. */ addToCollection( - refOrPath: CollectionReference | string, + refOrPath: {} | string, data: {}, id?: string ): Promise; @@ -501,10 +468,7 @@ declare namespace rebase { * @param data The document data. * @returns A Promise thats resolve with the resulting data or rejects if the document/collection does not exist or there are any read errors. */ - updateDoc( - refOrPath: DocumentReference | string, - data: {} - ): Promise; + updateDoc(refOrPath: {} | string, data: {}): Promise; /** * Deletes a document. @@ -512,10 +476,7 @@ declare namespace rebase { * @param data The document data. * @returns A Promise thats resolve with the resulting data or rejects if the document/collection does not exist or there are any read errors. */ - removeDoc( - refOrPath: DocumentReference | string, - data: {} - ): Promise; + removeDoc(refOrPath: {} | string, data: {}): Promise; /** * Removes documents from a collection. If no query is supplied, it will remove all the documents. If a query is supplied, it will only remove documents that match the query. @@ -524,7 +485,7 @@ declare namespace rebase { * @returns A Promise thats resolve with the resulting data or rejects if the document/collection does not exist or there are any read errors. */ removeFromCollection( - refOrPath: CollectionReference | string, + refOrPath: {} | string, options: removeFromCollectionOptions ): Promise; @@ -534,16 +495,13 @@ declare namespace rebase { * @param options removeFromCollection Options. * @returns A Promise thats resolve with the resulting data or rejects if the document/collection does not exist or there are any read errors. */ - syncDoc( - refOrPath: DocumentReference | string, - options: syncDocOptions - ): RebaseBinding; + syncDoc(refOrPath: {} | string, options: syncDocOptions): {}; /** * Clean up a listener. Listeners are automatically cleaned up when components unmount, however if you wish to remove a listener while the component is still mounted this will allow you to do that. An example would be if you want to start listening to a new document or change a query on all collection in response to a prop change. * @param ref The return value of syncState`, `bindToState`, `listenTo`, `listenToCollection`, `bindCollection`, `listenToDoc`, `bindDoc` or `syncDoc`. */ - removeBinding(ref: RebaseBinding): void; + removeBinding(ref: {}): void; /** * Removes every Firebase/Firestore listener. @@ -555,13 +513,9 @@ declare namespace rebase { declare module "re-base" { /** * Accepts an initialized firebase database or firestore database object. - * @param {object} firebaseDatabase Initialized firebase or firestore + * @param firebaseDatabase Initialized firebase or firestore * database. - * @return {Rebase} An instance of re-base. + * @return An instance of re-base. */ - export function createClass( - firebaseDatabase: - | firebase.database.Database - | firebase.firestore.Firestore - ): rebase.Rebase; + function createClass(firebaseDatabase: {}): rebase.Rebase; } diff --git a/types/re-base/tsconfig.json b/types/re-base/tsconfig.json index eb916d27f6..ff88a407d4 100644 --- a/types/re-base/tsconfig.json +++ b/types/re-base/tsconfig.json @@ -1,22 +1,16 @@ { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6" - ], + "lib": ["es6"], "noImplicitAny": true, "noImplicitThis": true, + "strictFunctionTypes": true, "strictNullChecks": true, "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, - "files": [ - "index.d.ts", - "re-base-tests.ts" - ] + "files": ["index.d.ts", "re-base-tests.ts"] } diff --git a/types/re-base/tslint.json b/types/re-base/tslint.json index 3db14f85ea..c077883976 100644 --- a/types/re-base/tslint.json +++ b/types/re-base/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "max-line-length": false, + "no-declare-current-package": false + } +}