Bug: [return-await] "in-try-catch" not respected with explicit resource management #7889
Open
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.2.2&fileType=.tsx&code=IYZwngdgxgBAZgV2gFwJYHsI1JKAxCACgEoYBvAKBmwHdhVkYIBTGmABQCd0BbVEZgB4AbulQATAHyFCnZiHQAbYc1IBeSTAHIAKqh7N0CZLPlKVAGhgBGAAy3ixANxUYUTAsXMAdIvQBzQgByHGgCGHFMZiDnVzlkBE4sIIUDZAALVAh-IJcAXwoKUNhEFAwseMSIAEE6BhJyVwQQLP8YAH0YNUbqagBtAGUwHgAjJW9xfgAHdAEAXQAuGAaNHt7qdwhPHz9AoMmQGYEYl3WC6gK45gSk2npGYoISfMLgOsZKpNr758LmAA8ZpxGGQYHkXEA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6aRfWaJ2gQwDufSvnRRE0aAHtokcGAC%2BIBUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
I expect that the line
return await asyncFn();
does not trigger a linting error, since theusing
statement is effectively atry/catch/finally
around the scope of the function.Actual Result
return await asyncFn();
triggers a linting error for an unnecessaryawait
, and it gets autofixed toreturn asyncFn();
. This makes it so that the disposers run before the returned promise settles, when previously they would run after the returned promise settles.Additional Info
Demonstrates difference in behavior after running
eslint --fix
: https://stackblitz.com/edit/node-fsxhhx?file=src%2Fwith-await.tsThe text was updated successfully, but these errors were encountered: