Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 reword
- Loading branch information