For testing purposes, I sometimes add || true
to make a boolean expression true
of && false
to make it false
.
Is there an ESLint or Typescript ESLint rule to report these hacks and make sure they don't get committed or at least not built/deployed?
Building on an answer to this question, I came up with this config using ESLint no-restricted-syntax rule:
{
'no-restricted-syntax': [
'error',
{
selector: 'LogicalExpression[operator="||"][right.value=true]',
message: '|| true is only for testing',
},
{
selector: 'LogicalExpression[operator="&&"][right.value=false]',
message: '&& false is only for testing',
},
]
}