Document rationale for allowNumber: false in restrict-template-expressions #9311
Closed
2 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
documentation
Documentation ("docs") that needs adding/updating
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
Before You File a Proposal Please Confirm You Have Done The Following...
Description
The strict-type-checked configuration sets
allowNumber: false
for the restrict-template-expressions rule. This prohibits code like the following:There is nothing wrong with this code. The official MDN docs on template literals contain code just like it. The typescript-eslint docs for this rule offer no rationale of why interpolating numbers into a string in this way is problematic.
Impacted Configurations
Additional Info
I'm totally bought into all the other options that
strict
enables for restrict-template-expressions (allowAny
,allowArray
,allowBoolean
,allowNullish
,allowNever
). These seem potentially problematic since they could result in your inadvertently showing debug code to users. ButallowNumber
? I'm having trouble seeing any rationale for banning that.My proposal would be to either change the default setting or add a clear explanation of why interpolating numbers into strings is dangerous.
Possibly related:
The text was updated successfully, but these errors were encountered: