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-output-on-prefix incorrectly throws error if output property name starts with "one" #480

Closed
compeek opened this issue Jan 5, 2018 · 8 comments

Comments

@compeek
Copy link

@compeek compeek commented Jan 5, 2018

I enabled the new no-output-on-prefix rule and started getting an error for an output property named oneTimeScheduleDetailItemChange. It seems the rule is only looking at the first two letters. It should really check the first three and see if the first two are "on" and the third is a capital letter.

I'm using codelyzer 4.0.2 with Angular 5.1.3.

@compeek compeek changed the title no-output-on-prefix incorrectly throws error if property starts with "one" no-output-on-prefix incorrectly throws error if output property name starts with "one" Jan 5, 2018
@compeek compeek changed the title no-output-on-prefix incorrectly throws error if output property name starts with "one" no-output-on-prefix incorrectly throws error if output property name starts with "one" Jan 5, 2018
@mgechev
Copy link
Owner

@mgechev mgechev commented Jan 5, 2018

Good catch. Will add a fix in the next release.

@tatsujb
Copy link

@tatsujb tatsujb commented Aug 16, 2018

I'm currently getting this but with "on"

@lazarljubenovic
Copy link
Contributor

@lazarljubenovic lazarljubenovic commented Aug 16, 2018

@tatsujb I'm not sure I understand you correctly but if you're getting an error with an output named something like "onClick", then that's the point of the rule: it should be just "click".

@tatsujb
Copy link

@tatsujb tatsujb commented Aug 16, 2018

ok that's dumb. why can't it be "on" when that would allow you to match Angular's naming convention?

like the function I'm trying to hit is the original one, the one you call "click", no prefix. so I can't call the emitter "click" again, vars and functions may only be declared once in JS.

so naturally "onClick" springs up to your mind as the natural name which would allow your own function to follow many if not all of Angular's functions' naming convention.

@lazarljubenovic
Copy link
Contributor

@lazarljubenovic lazarljubenovic commented Aug 16, 2018

It doesn't: https://angular.io/guide/styleguide#dont-prefix-output-properties

Do name events without the prefix on.

@lazarljubenovic
Copy link
Contributor

@lazarljubenovic lazarljubenovic commented Aug 16, 2018

If you want to use the on prefix for some reason, simply turn off this lint rule. This one is specifically for forbidding the on prefix, as the name implies: no output "on" prefix.

@tatsujb
Copy link

@tatsujb tatsujb commented Aug 16, 2018

Oh. my bad. so they bridge the "name-gap" html-side :
<toh-hero (savedTheDay)="onSavedTheDay($event)"></toh-hero>

yeah that makes more sense, sorry.

@George35mk
Copy link

@George35mk George35mk commented Oct 13, 2018

I get the same warning like you, an easy way to fix this is to not use camelCase try to use something like this.

you can set a rule of course http://codelyzer.com/rules/no-output-on-prefix/

or

onReset  <--  warning
onreset  <--  ok

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

Successfully merging a pull request may close this issue.

None yet
5 participants