feat(eslint-plugin): [restrict-template-expressions] add option allow any
#1762
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1660.
Sometimes it can be useful to allow the
any
type in template expressions. Although a typescript-eslint user will usually prefer the stronger checking, there are times when the weaker checking is useful if the author is confident the value will stringise sanely, for example in codebases with significant legacy, or where there is a lot of handling of untyped values, or in scenarios such as thecatch
case outlined in #1660.This PR provides an option not to warn if an
any
value is dumped in a template expression. The option is off by default because, as mentioned in the issue, the goal of the rule is "to make sure you're not doing something that might dump garbage into your template strings," and nothing is more able to dump garbage thanany
...!