Skip to content

Commit b6bb65d

Browse files
chore: add @typescript-eslint/no-floating-promises rule (#261)
1 parent 1542348 commit b6bb65d

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ Then when running ESLint add `--ext '.js,.ts'` (you might need also `.jsx, .tsx`
9999
yarn eslint --ext '.js,.ts' ./src
100100
```
101101

102+
`parserOptions.project` is set to `./tsconfig.json`. You may need to [adjust that](https://typescript-eslint.io/architecture/parser#project).
103+
104+
To do so, you'll need to override our setup for TS files in your ESLint config:
105+
106+
```json
107+
{
108+
"overrides": [
109+
{
110+
"files": ["*.ts", "*.tsx"],
111+
"parserOptions": {
112+
"project": "./packages/**/tsconfig.json"
113+
}
114+
}
115+
]
116+
}
117+
```
118+
102119
#### VSCode
103120

104121
If you're VSCode user, you may find adding this config to your `.vscode/settings.json` helpful:

node.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ module.exports = {
8080
files: ['*.ts', '*.tsx'],
8181
parser: '@typescript-eslint/parser',
8282
plugins: ['@typescript-eslint/eslint-plugin'],
83+
parserOptions: {
84+
project: './tsconfig.json'
85+
},
8386
settings: {
8487
'import/extensions': [...extensions.TS, ...extensions.JS],
8588
'import/parsers': {
@@ -94,6 +97,7 @@ module.exports = {
9497
rules: {
9598
'@typescript-eslint/no-unused-vars': [ERROR, NO_UNUSED_VARS_OPTIONS],
9699
'@typescript-eslint/prefer-optional-chain': ERROR,
100+
'@typescript-eslint/no-floating-promises': ERROR,
97101
'no-dupe-class-members': OFF,
98102
'no-unused-vars': OFF,
99103
'no-undef': OFF,

test/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function Hook() {
5555

5656
// eslint-disable-next-line require-await
5757
async () => {
58+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
5859
new Promise((resolve) => resolve('test'));
5960
};
6061

0 commit comments

Comments
 (0)