-
Notifications
You must be signed in to change notification settings - Fork 506
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
standard:function-naming on composables #2259
Comments
I found this ticket #2139 But find this not acceptable. A lot of projects use compose somewhere in their code base. I do not think that it makes sense to enable it by default in the current state. |
The wording Android Kotlin style guide says following about naming of Composable functions:
So in one way, you're correct to say that according to kotlin style guide it is allowed to start function names with a capital given that other conditions are also met. But this does not apply, when not using composeables. So it becomes arguable whether the My advice would be to disable this specific rule in your |
Compose is available beyond Android (https://github.com/JetBrains/compose-multiplatform) so limiting it to the |
Ktlint will not be tailored for specific libraries like Compose. Although I dislike adding all kinds of configuration options (bikeshedding principle), it could be considered to add In the FAQ of ktlint it should then be documented how Compose projects should configure ktlint by setting |
…tated_with` When using Compose, set property `ktlint_function_naming_ignore_when_annotated_with=Composable` to suppress the `function-naming` rule for functions annotated with `@Composable`. A dedicated ktlint ruleset like [Compose Rules](https://mrmans0n.github.io/compose-rules/ktlint/) can be used for checking naming conventions for such Composable functions. Closes #2259
I have added When using Compose, set property |
Add `.editorconfig` property `ktlint_function_naming_ignore_when_annotated_with` When using Compose, set property `ktlint_function_naming_ignore_when_annotated_with=Composable` to suppress the `function-naming` rule for functions annotated with `@Composable`. A dedicated ktlint ruleset like [Compose Rules](https://mrmans0n.github.io/compose-rules/ktlint/) can be used for checking naming conventions for such Composable functions. Closes #2259
Nice! Thanks for the implementation 👌🎉 For many, compose isn't just "a library", but the standard to build UI elements on Kotlin. |
Thanks, this'll go a long way for the ecosystem! |
@paul-dingemans I'm not sure if my comment will be visible to you but in the changes I've seen you referenced 1.0.1 which is a dead link right now. Did you intend to release 1.0.1 alongside this change? |
Yes, link is still dead as the release has not been built. Please see snapshot docs https://pinterest.github.io/ktlint/dev-snapshot/rules/standard/#function-naming until it is released. See https://pinterest.github.io/ktlint/dev-snapshot/install/snapshot-build/ if you want to use the snapshot build till then. |
Yep I noticed my mistake. I'll try the snapshot. |
@paul-dingemans any timeline when do you intend to release 1.0.1 with this change ? we are facing this issue when using megalinter |
It is a bit hard to say at this moment. I intended to release on Oct 1st but did not have enoug time for it. And last couple of days, some new (regression) problems were reported which I want to include as well. You should not expect a release in next two weeks. |
Release is on its way... |
Ktlint 1.0.0 warns that composable functions should be named lower case.
Composable functions should be named CamelCase and not lowerCase.
Steps to reproduce
Composey.kt
The text was updated successfully, but these errors were encountered: