Closed alexjlockwood closed 1 month ago
Yep, it also rings a bell -- but can't find where they mention it 😅
Anyway, I had it in the back on my mind for a while so I just went and added the rule.
Can anyone provide a source or logical justification for this rule? Imposing it because it "rings a bell" doesn't feel significant enough for inclusion.
The docs say "It a common mistake to use the past tense in some of these events..." without saying why it's a mistake to do this, or linking to a relevant argument; which is not conducive to eager adoption.
It's mainly an opinionated style / consistency choice, like most of other the *Naming rules already present. I am all in in this one in particular, stemming from multiple discussions at work in the past two years about the naming of lambdas.
I agree that the language in the docs can be improved (as it's not really a mistake, just a style recommendation), I'll update that when I have a minute.
And as always, If you don't want a particular rule to run in your codebase you can always disable it in your linter of choice 😄
Thanks @mrmans0n. I don't disagree with the rule and I'm sure there's good reasons, but there would be value in exposing the justification for other's benefit when you have chance to update the docs to make it feel less arbitrary 👍.
In composable functions, lambda callbacks shouldn't be named in the past tense. For example:
onClicked
should beonClick
onCheckedChanged
should beonCheckedChanged
This doesn't seem to be mentioned in Google's official style guide, but I know it's a pattern they practice just based on what I see in their source code... and I remember reading it somewhere in the documentation that it's something they encourage but I can't seem to find it 😓