Skip to content

Commit fe7a4ce

Browse files
* fix(types): use correct type order for reducer schema - @rscotten (prescottprue#888) * fix(deps): update prettier to v1.10.0 to v2.0.0 * fix(deps): update eslint from v4.8.0 to v6.8.0 * fix(deps): update dev dependencies including eslint plugins Co-authored-by: Richard Scotten <rscotten@users.noreply.github.com>
1 parent b661fab commit fe7a4ce

35 files changed

+5148
-7433
lines changed

.codeclimate.yml

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1+
version: "2" # required to adjust maintainability checks
2+
13
languages:
24
JavaScript: true
35

4-
exclude_paths:
5-
- "lib/**"
6-
- "test/**"
7-
- "examples/**"
8-
- "LICENSE"
9-
- "LICENSE.md"
10-
- "README.md"
11-
- "package.json"
6+
checks:
7+
file-lines:
8+
enabled: true
9+
config:
10+
threshold: 740
11+
return-statements:
12+
enabled: true
13+
config:
14+
threshold: 6
15+
16+
exclude_patterns:
17+
- "lib/**"
18+
- "test/**"
19+
- "examples/**"
20+
- "LICENSE"
21+
- "LICENSE.md"
22+
- "README.md"
23+
- "package.json"
24+
- "**/*.d.ts"

bin/api-docs-generate.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const fileRenames = {
1919
* @returns {Promise} Resolves after all instances of see parameter are removed
2020
*/
2121
function removeSeeFromMarkdown(filePath) {
22-
return readFilePromise(filePath).then(fileContentsBuffer => {
22+
return readFilePromise(filePath).then((fileContentsBuffer) => {
2323
const fileContents = fileContentsBuffer.toString()
2424
const cleanedContents = fileContents.replace(/\n-.*\*\*See.*/g, '')
2525
return writeFilePromise(filePath, cleanedContents)
@@ -32,18 +32,16 @@ function removeSeeFromMarkdown(filePath) {
3232
*/
3333
function generateDocForFile(file) {
3434
return exec(
35-
`$(npm bin)/documentation build ${SRC_FOLDER}/${
36-
file.src
37-
} -f md -o ${API_DOCS_FOLDER}/${file.dest} --shallow`
35+
`$(npm bin)/documentation build ${SRC_FOLDER}/${file.src} -f md -o ${API_DOCS_FOLDER}/${file.dest} --shallow`
3836
)
39-
.then(res => {
37+
.then((res) => {
4038
console.log('Successfully generated', file.dest || file)
4139
return removeSeeFromMarkdown(
4240
`${process.cwd()}/${API_DOCS_FOLDER}/${file.dest}`
4341
)
4442
// return res
4543
})
46-
.catch(error => {
44+
.catch((error) => {
4745
console.log('error generating doc: ', error.message || error)
4846
return Promise.reject(error)
4947
})
@@ -60,9 +58,9 @@ function getFileNames() {
6058
return reject(err)
6159
}
6260
const cleanedFileNames = files.filter(
63-
fileName => !pathsToSkip.includes(fileName)
61+
(fileName) => !pathsToSkip.includes(fileName)
6462
)
65-
const mappedFileNames = cleanedFileNames.map(fileName => {
63+
const mappedFileNames = cleanedFileNames.map((fileName) => {
6664
const newName = fileRenames[fileName] || fileName
6765
return { src: fileName, dest: `${newName.replace('.js', '')}.md` }
6866
})
@@ -71,7 +69,7 @@ function getFileNames() {
7169
})
7270
}
7371

74-
;(async function() {
72+
;(async function () {
7573
console.log(
7674
'Generating API documentation (docs/api) from JSDoc comments within src...\n'
7775
)

bin/api-docs-upload.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const project = 'docs.react-redux-firebase.com'
2424
* @private
2525
*/
2626
function runCommand(cmd) {
27-
return exec(cmd).catch(err =>
27+
return exec(cmd).catch((err) =>
2828
Promise.reject(
2929
err.message && err.message.indexOf('not found') !== -1
3030
? new Error(`${cmd.split(' ')[0]} must be installed to upload`)
@@ -46,9 +46,8 @@ function upload(entityPath) {
4646
.replace('_book/', '')
4747
.replace('/**', '')}`
4848
const command = `gsutil -m cp -r -a public-read ${entityPath} gs://${uploadPath}`
49-
return runCommand(command).then(
50-
({ stdout, stderr }) =>
51-
stdout ? Promise.reject(stdout) : { output: stderr, uploadPath }
49+
return runCommand(command).then(({ stdout, stderr }) =>
50+
stdout ? Promise.reject(stdout) : { output: stderr, uploadPath }
5251
)
5352
}
5453

@@ -60,29 +59,29 @@ function upload(entityPath) {
6059
*/
6160
function uploadList(files) {
6261
return Promise.all(
63-
files.map(file =>
62+
files.map((file) =>
6463
upload(file)
6564
.then(({ uploadPath, output }) => {
6665
console.log(`Successfully uploaded: ${uploadPath}`) // eslint-disable-line no-console
6766
return output
6867
})
69-
.catch(err => {
68+
.catch((err) => {
7069
console.log('Error uploading:', err.message || err) // eslint-disable-line no-console
7170
return Promise.reject(err)
7271
})
7372
)
7473
)
7574
}
7675

77-
;(function() {
76+
;(function () {
7877
runCommand('gsutil') // check for existence of gsutil
7978
.then(() => uploadList(first))
8079
.then(() => uploadList(second))
8180
.then(() => {
8281
console.log('Docs uploaded successfully') // eslint-disable-line no-console
8382
process.exit(0)
8483
})
85-
.catch(err => {
84+
.catch((err) => {
8685
console.log('Error uploading docs:', err.message) // eslint-disable-line no-console
8786
process.exit(1)
8887
})

index.d.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -809,12 +809,12 @@ export function firebaseConnect<ProfileType, TInner = {}>(
809809
export function firebaseReducer<
810810
UserType,
811811
Schema extends Record<string, Record<string | number, string | number>>
812-
>(state: any, action: any): FirebaseReducer.Reducer<Schema, UserType>
812+
>(state: any, action: any): FirebaseReducer.Reducer<UserType, Schema>
813813

814814
export function makeFirebaseReducer<
815-
Schema extends Record<string, Record<string | number, string | number>>,
816-
UserType = {}
817-
>(): (state: any, action: any) => FirebaseReducer.Reducer<Schema, UserType>
815+
UserType = {},
816+
Schema extends Record<string, Record<string | number, string | number>> = {}
817+
>(): (state: any, action: any) => FirebaseReducer.Reducer<UserType, Schema>
818818

819819
/**
820820
* React HOC that attaches/detaches Cloud Firestore listeners on mount/unmount
@@ -1037,7 +1037,9 @@ export interface ReduxFirestoreConfig {
10371037
preserveOnListenerError: null | object
10381038

10391039
// https://github.com/prescottprue/redux-firestore#onattemptcollectiondelete
1040-
onAttemptCollectionDelete: null | ((queryOption: any, dispatch: any, firebase: any) => void)
1040+
onAttemptCollectionDelete:
1041+
| null
1042+
| ((queryOption: any, dispatch: any, firebase: any) => void)
10411043

10421044
// https://github.com/prescottprue/redux-firestore#mergeordered
10431045
mergeOrdered: boolean
@@ -1128,8 +1130,8 @@ export interface Data<T extends FirestoreTypes.DocumentData> {
11281130

11291131
export namespace FirebaseReducer {
11301132
export interface Reducer<
1131-
Schema extends Record<string, Record<string | number, string | number>>,
1132-
ProfileType = {}
1133+
ProfileType = {},
1134+
Schema extends Record<string, Record<string | number, string | number>> = {}
11331135
> {
11341136
auth: AuthState
11351137
profile: Profile<ProfileType>

0 commit comments

Comments
 (0)