Commit 7a49c58
authored
feat(valid-expect-in-promise): re-implement rule (#916)
* feat(valid-expect-in-promise): re-write implementation
* fix(valid-expect-in-promise): check number of arguments being passed
* fix(valid-expect-in-promise): bailout if `done` callback is present
* fix(valid-expect-in-promise): allow awaited promises
* fix(valid-expect-in-promise): handle multi-chained promises properly
Method call chains are represented in AST in a nested fashion, meaning
it's not enough to just separately track if we're both in a promise
chain call and then if we've found an `expect` call, because when we
exit another CallExpression in the same chain it'll look like that has
an `expect` call.
Instead, we need to track our depth as we enter CallExpression nodes so
that when we exit those nodes we can check if we encountered an `expect`
call at that same depth.
* fix(valid-expect-in-promise): handle promises assigned to variables
* refactor(valid-expect-in-promise): adjust conditions to dedent code
* fix(valid-expect-in-promise): allow variables assigned awaited promises
* feat(valid-expect-in-promise): track promise vars across reassignments
* feat(valid-expect-in-promise): support blocks and multi-variable assigns
* feat(valid-expect-in-promise): support re-assignment promise chaining
* refactor(valid-expect-in-promise): remove unneeded condition
* refactor(valid-expect-in-promise): inline reporting function
We only call it in one place, and so it lets us also remove some minor
types that can be otherwise inferred
* fix(valid-expect-in-promise): rewrite rule message to be clearer
* fix(valid-expect-in-promise): rewrite rule description to be clearer
* fix(valid-expect-in-promise): ignore unreachable code after return
* fix(valid-expect-in-promise): support `Promise.all`
* fix(valid-expect-in-promise): support `resolve` & `reject` methods
* refactor(valid-expect-in-promise): remove unneeded optional chain
* refactor(valid-expect-in-promise): adjust conditions slightly
* chore(valid-expect-in-promise): add a bunch of comments
* feat(valid-expect-in-promise): support `Promise.allSettled`
* docs(valid-expect-in-promise): add more examples and reword1 parent a4f66f6 commit 7a49c58
File tree
4 files changed
+1335
-179
lines changed- docs/rules
- src/rules
- __tests__
4 files changed
+1335
-179
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
9 | | - | |
| 7 | + | |
| 8 | + | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 10 | + | |
14 | 11 | | |
15 | 12 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
21 | 39 | | |
22 | 40 | | |
23 | 41 | | |
24 | 42 | | |
25 | 43 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
29 | 47 | | |
30 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
31 | 72 | | |
0 commit comments