Skip to content

Commit

Permalink
add eslint rule for detecting promise misses.
Browse files Browse the repository at this point in the history
  • Loading branch information
KishiTheMechanic committed Sep 12, 2023
1 parent 087c6b1 commit a130431
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"prettier"
],
"parserOptions": {
"project": "./tsconfig.json",
"sourceType": "module",
"ecmaVersion": "latest"
},
Expand All @@ -17,6 +18,13 @@
"@typescript-eslint/no-unused-vars": 0,
"no-undef": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": [
"error",
{
"checksVoidReturn": false
}
],
"@typescript-eslint/ban-ts-comment": [
"off",
{
Expand Down
2 changes: 1 addition & 1 deletion release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ const fileWrite = async () => {
})
}

fileWrite()
void fileWrite()
4 changes: 2 additions & 2 deletions tests/firestore_spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ describe('Update Collection Item', () => {
const thrownAction = async () => {
await updateCollectionItem<User>(db, path, 'ignore', updatedData)
}
expect(thrownAction).rejects.toThrow()
await expect(thrownAction).rejects.toThrow()
})
})

Expand Down Expand Up @@ -320,6 +320,6 @@ describe('Delete Collection Item', () => {
const thrownAction = async () => {
await deleteCollectionItem(db, path, 'ignore')
}
expect(thrownAction).rejects.toThrow()
await expect(await thrownAction()).toBe(undefined)
})
})
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"baseUrl": ".",
"rootDir": ".",
"sourceMap": true,
Expand All @@ -17,6 +18,6 @@
"@lib/*": ["./lib/*"]
}
},
"include": ["./src/**/*"],
"exclude": ["./test/**/*"]
"include": ["src/**/*", "tests/**/*", "release.ts", "jest.config.js"],
"exclude": ["dist", "node_modules"]
}

0 comments on commit a130431

Please sign in to comment.