SonarTS
SonarTS copied to clipboard
bool-param-default should ignore params beginning with underscore
I want to request a feature.
Typescript noUnusedParameters option ignores params beginning with underscore (understand that some people dislike this, but this is how it is). For such params that are being ignored it would seem preferable to use the optional parameter syntax over providing an unused default value. A default value makes it LESS clear that the parameter is actually not used.
@slubowsky thanks for the feedback. Sounds reasonable!
function foo(p1: number, _p2?: boolean) { // '_p2' should not be reported as it unused
return p1 * 2;
}
When implementing the fix we should consider 2 options:
- relying on parameter name (starts with
_
) -> suggested by @slubowsky - relying on symbol table (parameter is not used), not sure if it's better or worse
RSPEC -> https://jira.sonarsource.com/browse/RSPEC-4798