Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* New: `require-await` rule (fixes #6820) * Fixes fileoverview tag. * extracts `isEmptyFunction` to ast-utils.
- Loading branch information
1 parent
b7432bd
commit 89bd8de
Showing
7 changed files
with
692 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Disallow async functions which have no `await` expression (require-await) | ||
|
||
Async functions which have no `await` expression may be the unintentional result of refactoring. | ||
|
||
## Rule Details | ||
|
||
This rule warns async functions which have no `await` expression. | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
/*eslint require-await: "error"*/ | ||
|
||
async function foo() { | ||
doSomething(); | ||
} | ||
|
||
bar(async () => { | ||
doSomething(); | ||
}); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
/*eslint require-await: "error"*/ | ||
|
||
async function foo() { | ||
await doSomething(); | ||
} | ||
|
||
bar(async () => { | ||
await doSomething(); | ||
}); | ||
|
||
function foo() { | ||
doSomething(); | ||
} | ||
|
||
bar(() => { | ||
doSomething(); | ||
}); | ||
|
||
// Allow empty functions. | ||
async function noop() {} | ||
``` | ||
|
||
## When Not To Use It | ||
|
||
If you don't want to notify async functions which have no `await` expression, then it's safe to disable this rule. | ||
|
||
## Related Rules | ||
|
||
* [require-yield](require-yield.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
that have => that do not have ?