Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

bool-param-default should ignore params beginning with underscore #818

Open
slubowsky opened this issue Jan 21, 2019 · 1 comment
Open

Comments

@slubowsky
Copy link

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.

@vilchik-elena
Copy link
Contributor

vilchik-elena commented Feb 1, 2019

@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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants