restrict-template-expressions
Added in v0.1.4Configuration
rslint.config.ts
Rule Details
Enforce template literal expressions to be of string type. When a value is interpolated into a template literal (${expr}), it is implicitly converted to a string, which produces results such as "[object Object]" for plain objects. This rule restricts which types may be interpolated.
By default, primitives that stringify predictably are permitted (number, bigint, boolean, null, undefined, any, RegExp), along with Error, URL, and URLSearchParams and their subclasses.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
To require every interpolated value to be a string, empty the allow list and turn each allow* option off: