-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): [await-thenable] report unnecessary `await using…
…` statements (#10209) * [await-thenable] report unnecessary await using statements * continue, not return * await using without init * disable lint error * exempt code ticks from upper-case heading test Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com> --------- Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
- Loading branch information
1 parent
22f7f25
commit 5b2ebcd
Showing
8 changed files
with
375 additions
and
45 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
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
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
import type { TSESLint } from '@typescript-eslint/utils'; | ||
|
||
export function getFixOrSuggest<MessageId extends string>({ | ||
fixOrSuggest, | ||
suggestion, | ||
useFix, | ||
}: { | ||
fixOrSuggest: 'fix' | 'none' | 'suggest'; | ||
suggestion: TSESLint.SuggestionReportDescriptor<MessageId>; | ||
useFix: boolean; | ||
}): | ||
| { fix: TSESLint.ReportFixFunction } | ||
| { suggest: TSESLint.SuggestionReportDescriptor<MessageId>[] } { | ||
return useFix ? { fix: suggestion.fix } : { suggest: [suggestion] }; | ||
| { suggest: TSESLint.SuggestionReportDescriptor<MessageId>[] } | ||
| undefined { | ||
switch (fixOrSuggest) { | ||
case 'fix': | ||
return { fix: suggestion.fix }; | ||
case 'none': | ||
return undefined; | ||
case 'suggest': | ||
return { suggest: [suggestion] }; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
packages/eslint-plugin/tests/docs-eslint-output-snapshots/await-thenable.shot
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.