Skip to content
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

no-unused-variable from tslint is not sufficient to angular 2 project #86

Closed
netstart opened this issue Sep 14, 2016 · 8 comments
Closed
Assignees

Comments

@netstart
Copy link

netstart commented Sep 14, 2016

no-unused-variable from tslint is not sufficient to angular 2 project. We need verify teamplate html

"no-unused-variable": true,

Look researched variable for exemple.
If use this variable only in tamplate we receive a Message:
Failed to lint: login/modulos/components/areabox/area-box-list.component.ts [38, 20]: Unused property: 'researched'.

image

@mgechev
Copy link
Owner

mgechev commented Sep 14, 2016

It makes sense to create a rule ng-no-unused-variable. With what we have in the templates branch I think we're not far from one.

@mgechev mgechev added this to the Beta 1 milestone Sep 18, 2016
@mgechev mgechev self-assigned this Sep 18, 2016
@mgechev
Copy link
Owner

mgechev commented Sep 21, 2016

@netstart I was thinking that might be a good idea to keep this rule for the next version when we support external templates. Currently it will be only misleading for the users if we mark a variable as unused.

@mgechev mgechev modified the milestones: Beta 2 - Dark Realm, Beta 1 - Nepeta Sep 21, 2016
@mgechev mgechev added the P2 label Sep 21, 2016
@mgechev mgechev modified the milestones: Beta 2 - Trichocolea mollissima, Beta 1 - Dark Realm Oct 2, 2016
@mgechev mgechev modified the milestones: Beta 2 - Trichocolea mollissima, Beta 1 - Dark Realm Oct 9, 2016
@dzonatan
Copy link

Before implementing it take a look at angular/angular#11422 about accessing private properties when using AoT.

Also some key notes from http://stackoverflow.com/a/39000046/2320455:

With ngc and static template compilation, you'll get errors if you try accessing private members of the component from template.

In Dart the template can't reference private variables of the component class, because Dart in contrast to TypeScript effectively prevents access of private members from outside.

I'd think about creating the converse rule: to verify that all properties usages in template are with public access.

@mgechev
Copy link
Owner

mgechev commented Oct 17, 2016

Thanks for the comment! We have such rule already.

@michaeljota
Copy link

The no-unused-vars rule will be deprecated in tslint 4. See #1481.

@mgechev
Copy link
Owner

mgechev commented Nov 23, 2016

This is even greater motivation to include such rule in codelyzer. Now we support external templates so we can make it happen. I'm afraid that the release will become too big so I'd suggest to move this feature as part of the next one.

@mgechev mgechev modified the milestones: Beta 3 - Turing switch, Beta 2 - Trichocolea mollissima Nov 23, 2016
@mgechev mgechev modified the milestones: 2.0.0-Beta 5 Flightside, 2.0.0-Beta 4 KV35 Dec 21, 2016
@michaeljota
Copy link

Still, the no-unused-vars will rise only for private members, and as @dzonatan said, all template binded properties should be public. (There is a rule for that already)

@mgechev mgechev removed this from the 2.0.0-Beta 5 Flightside milestone Feb 19, 2017
@mgechev mgechev closed this as completed Feb 19, 2017
@RobertPaulson90
Copy link

RobertPaulson90 commented Apr 30, 2017

Any suggestions to get VS Code to work with Angular component fields showing up as unused like WebStorm can? https://stackoverflow.com/questions/43700420/angular2-with-vs-code-intellisense

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

No branches or pull requests

5 participants