jsx-use-translation-function overlooks ternary expressions
karol-majewski opened this issue · comments
Karol Majewski commented
Hello and thank you for your work. I believe the jsx-use-translation-function
rule should look into what an expression evaluates to, not only for string literals alone.
Linted code
<div>{true ? 'Told ya' : 'Not really'}</div>
Expected result
String literals are disallowed as JSX. Use a translation function (jsx-use-translation-function)
Actual result
No error.
Configuration
{
"extends": [
"tslint-react"
],
"rules": {
"jsx-use-translation-function": true
}
}
tslint
:5.9.1
tslint-react
:3.5.1
Adi Dahiya commented
Static code analysis tools like TSLint avoid evaluating code for good reason: it is expensive and error-prone. I think this is out of scope.