-
Notifications
You must be signed in to change notification settings - Fork 150
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
Provide info about annotated functions #42
Comments
splitting ngAnnotate into 2 separate modules might help to do the job. The first would be responsible for finding functions that should get annotated (including the ones annotated via explicit annotations which will be great!). The second would do the processing. After the first part of the task is done a list of functions to be annotated (perhaps as parts of the AST) to do the unused injection checking. This way it'll be easy to build ESlint rule for performing such checking. |
Maybe "easy" is too much said since ESLint currently doesn't accept custom AST as input but always parses with its own Esprima copy but maybe it'll gain such possibility in the nearby future. |
Haha, maybe not easy, but once you have the scanner and the output in place, I could see an |
It would be possible for ng-annotate to turn
into
for all declaration forms it understands, given some switch. Then a tool such as eslint or defs can do whatever it wants with it. FWIW, I'd also recommend exploring more generic (not coupled to Angular) approaches to linting unused function parameters. Have you considered a naming convention where any unused parameter (say in an event-handler) starts with an |
This is a loose idea but I often add a service to dependencies of another one and then remove its uses but forget to remove the injection. Now, linters often have an option to report unused parameters of functions not only at the end of them, e.g. see:
http://eslint.org/docs/rules/no-unused-vars.html
with
{"args": "all"}
but then I'd have lots of false positives since in case of event handlers, replace functions on strings etc. we're sometimes interested in a second parameter but the first still has to be there.Since ng-annotate already figures out which functions need to be annotated, I wonder if it was possible to pass this info along in some ways so that it'd be possible to check for unused injections in outside projects.
Or maybe ng-annotate could do this checking on its own? It rarely makes sense to inject components that aren't used in the code after all...
The text was updated successfully, but these errors were encountered: