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

contextual-decorator: fails for some cases #776

Closed
rafaelss95 opened this issue Feb 24, 2019 · 5 comments · Fixed by #798
Closed

contextual-decorator: fails for some cases #776

rafaelss95 opened this issue Feb 24, 2019 · 5 comments · Fixed by #798
Assignees
Labels

Comments

@rafaelss95
Copy link
Collaborator

rafaelss95 commented Feb 24, 2019

Case 1: (It doesn't report failures for pipes) Fixed in #754.

@Pipe({
  name: 'app-test'
})
export class TestPipe {
  @Input() someVar: string; // should report a failure, currently it does not.
}

Case 2: (it doesn't report failures if ViewChild decorator is applied to a setter accessor)

@Injectable({ // doesn't work for @Pipe also
  providedIn: 'root'
})
export class TestService {
  @ViewChild(Pane)  // should report a failure, currently it does not.
  set pane(v: Pane) {
    console.log('v', v);
  }
}

Also, the @Attribute decorator is not handled at the moment. Is it intentional? @mgechev @wKoza

@rafaelss95 rafaelss95 added the bug label Feb 24, 2019
@rafaelss95 rafaelss95 changed the title decorator-not-allowed: fails for some cases contextual-decorator: fails for some cases Feb 24, 2019
@wKoza
Copy link
Collaborator

wKoza commented Feb 25, 2019

@Attribute can only be used in a constructor. It's maybe the reason (which it's not a valid reason ;) ).
But, if we handle @Attribute, what about @Host, @Self, ... ?

So, I don't think it's intentional.

@wKoza
Copy link
Collaborator

wKoza commented Feb 26, 2019

@rafaelss95 , I've just seen that @Attribute is a bad practice here

@rafaelss95
Copy link
Collaborator Author

@rafaelss95 , I've just seen that @Attribute is a bad practice here

@wKoza Yep, it's supposed to be, however the rules are independent, right?

@wKoza
Copy link
Collaborator

wKoza commented Feb 28, 2019

I think we should still keep some consistency but I don't have the whole history of this rule.

@superdyzio
Copy link

superdyzio commented Apr 29, 2019

Today I noticed weird behavior for @Pipe and @Injectable.
Example:

@Pipe({
  name: 'tableRow',
})
export class TableRowPipe implements PipeTransform {
    @Input() x; // not an error
}

and

@Pipe()
export class TableRowPipe implements PipeTransform {
    @Input() x; // error
}

Similar behavior for @Injectable() and @Injectable({...}). Codelyzer 5.0.1 and tslint 5.16.0.

EDIT: I just checked pull request mentioned above 😃

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