Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
version: "2" # required to adjust maintainability checks

languages:
JavaScript: true

exclude_paths:
- "lib/**"
- "test/**"
- "examples/**"
- "LICENSE"
- "LICENSE.md"
- "README.md"
- "package.json"
checks:
file-lines:
enabled: true
config:
threshold: 740
return-statements:
enabled: true
config:
threshold: 6

exclude_patterns:
- "lib/**"
- "test/**"
- "examples/**"
- "LICENSE"
- "LICENSE.md"
- "README.md"
- "package.json"
- "**/*.d.ts"
16 changes: 7 additions & 9 deletions bin/api-docs-generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const fileRenames = {
* @returns {Promise} Resolves after all instances of see parameter are removed
*/
function removeSeeFromMarkdown(filePath) {
return readFilePromise(filePath).then(fileContentsBuffer => {
return readFilePromise(filePath).then((fileContentsBuffer) => {
const fileContents = fileContentsBuffer.toString()
const cleanedContents = fileContents.replace(/\n-.*\*\*See.*/g, '')
return writeFilePromise(filePath, cleanedContents)
Expand All @@ -32,18 +32,16 @@ function removeSeeFromMarkdown(filePath) {
*/
function generateDocForFile(file) {
return exec(
`$(npm bin)/documentation build ${SRC_FOLDER}/${
file.src
} -f md -o ${API_DOCS_FOLDER}/${file.dest} --shallow`
`$(npm bin)/documentation build ${SRC_FOLDER}/${file.src} -f md -o ${API_DOCS_FOLDER}/${file.dest} --shallow`
)
.then(res => {
.then((res) => {
console.log('Successfully generated', file.dest || file)
return removeSeeFromMarkdown(
`${process.cwd()}/${API_DOCS_FOLDER}/${file.dest}`
)
// return res
})
.catch(error => {
.catch((error) => {
console.log('error generating doc: ', error.message || error)
return Promise.reject(error)
})
Expand All @@ -60,9 +58,9 @@ function getFileNames() {
return reject(err)
}
const cleanedFileNames = files.filter(
fileName => !pathsToSkip.includes(fileName)
(fileName) => !pathsToSkip.includes(fileName)
)
const mappedFileNames = cleanedFileNames.map(fileName => {
const mappedFileNames = cleanedFileNames.map((fileName) => {
const newName = fileRenames[fileName] || fileName
return { src: fileName, dest: `${newName.replace('.js', '')}.md` }
})
Expand All @@ -71,7 +69,7 @@ function getFileNames() {
})
}

;(async function() {
;(async function () {
console.log(
'Generating API documentation (docs/api) from JSDoc comments within src...\n'
)
Expand Down
15 changes: 7 additions & 8 deletions bin/api-docs-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const project = 'docs.react-redux-firebase.com'
* @private
*/
function runCommand(cmd) {
return exec(cmd).catch(err =>
return exec(cmd).catch((err) =>
Promise.reject(
err.message && err.message.indexOf('not found') !== -1
? new Error(`${cmd.split(' ')[0]} must be installed to upload`)
Expand All @@ -46,9 +46,8 @@ function upload(entityPath) {
.replace('_book/', '')
.replace('/**', '')}`
const command = `gsutil -m cp -r -a public-read ${entityPath} gs://${uploadPath}`
return runCommand(command).then(
({ stdout, stderr }) =>
stdout ? Promise.reject(stdout) : { output: stderr, uploadPath }
return runCommand(command).then(({ stdout, stderr }) =>
stdout ? Promise.reject(stdout) : { output: stderr, uploadPath }
)
}

Expand All @@ -60,29 +59,29 @@ function upload(entityPath) {
*/
function uploadList(files) {
return Promise.all(
files.map(file =>
files.map((file) =>
upload(file)
.then(({ uploadPath, output }) => {
console.log(`Successfully uploaded: ${uploadPath}`) // eslint-disable-line no-console
return output
})
.catch(err => {
.catch((err) => {
console.log('Error uploading:', err.message || err) // eslint-disable-line no-console
return Promise.reject(err)
})
)
)
}

;(function() {
;(function () {
runCommand('gsutil') // check for existence of gsutil
.then(() => uploadList(first))
.then(() => uploadList(second))
.then(() => {
console.log('Docs uploaded successfully') // eslint-disable-line no-console
process.exit(0)
})
.catch(err => {
.catch((err) => {
console.log('Error uploading docs:', err.message) // eslint-disable-line no-console
process.exit(1)
})
Expand Down
16 changes: 9 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,12 +809,12 @@ export function firebaseConnect<ProfileType, TInner = {}>(
export function firebaseReducer<
UserType,
Schema extends Record<string, Record<string | number, string | number>>
>(state: any, action: any): FirebaseReducer.Reducer<Schema, UserType>
>(state: any, action: any): FirebaseReducer.Reducer<UserType, Schema>

export function makeFirebaseReducer<
Schema extends Record<string, Record<string | number, string | number>>,
UserType = {}
>(): (state: any, action: any) => FirebaseReducer.Reducer<Schema, UserType>
UserType = {},
Schema extends Record<string, Record<string | number, string | number>> = {}
>(): (state: any, action: any) => FirebaseReducer.Reducer<UserType, Schema>

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

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

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

export namespace FirebaseReducer {
export interface Reducer<
Schema extends Record<string, Record<string | number, string | number>>,
ProfileType = {}
ProfileType = {},
Schema extends Record<string, Record<string | number, string | number>> = {}
> {
auth: AuthState
profile: Profile<ProfileType>
Expand Down
Loading