-
-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find unsed methods of objects #274
Comments
Knip supports namespaced/star imports and class members, so some of the semantics are probably similar. Returned values (e.g. objects) created by exported functions is something Knip currently does not analyze. Not sure whether this could be implemented reliably. How to decide whether to include such a function? Things combined, this feature might have noticeable to significant effects to performance. So yeah, opt-in as you suggest would probably make sense. Feel free to dive into this and open a pull request, though (or anyone else). This feature request is currently not high on my priority list, but willing to assist with/look into a PR. |
Maybe we could simple check every function or method that end up to be exported somehow. Or if it is too hard to distinguish between exported and non-exported functions we could simply do it fall all function definitions. Although non-exported unused functions are already flagged by typescript itself and a bunch of ESLint rules. But non of those tools help to detect unused functions that are exported. |
I'm going to close this issue. If anyone wants to pick it up, feel free to reach out and we can look into it. |
I would like to see a possibility to track and find unused methods on exported objects, or objects created by exported functions.
Use Case:
Most of the time I wrap modules with side-effects in a factory function in order to do dependency-injection, e.g.
Let’s say
secondMethod
is never used within my project, I want it to be flagged.I know that this cannot be achieved in all circumstances, for example when the project is a library and those methods might by consumed by the consumers. But for app projects this is not an issue and such dead code be detected reliably. Therefore I think this feature should be disabled by default and needs to be opt-in.
The text was updated successfully, but these errors were encountered: