Closed mxalbert1996 closed 2 months ago
Ktlint is following the recommendations of Android Kotlin Style Guide when using code_style android_studio
.
Based on Baseline style guidelines of Jetpack Compose you should use default kotlin coding style (code_style = intellij_idea
). But this results in same violation.
The exception for Singletons, constants, sealed class and enum class values defined in Jetpack Compose can best be dealt with by disabling this rule in the .editorconfig
. Defining a separate code style for Jetpack Compose is not something that I consider at this moment.
Based on Baseline style guidelines of Jetpack Compose you should use default kotlin coding style (code_style = intellij_idea). But this results in same violation.
Right. I tried in IntelliJ IDEA and it's not reported as well, so this as a conflict between ktlint and IntelliJ IDEA.
What is worse is that suppressing the rule using @Suppress("ConstPropertyName")
results in a warning ("Redundant suppression") in the IDE.
I guess disabling the rule is the only way.
Defining a separate code style for Jetpack Compose is not something that I consider at this moment.
Understandable. Disabling the rule is what I'm doing now, but that also disables the linting of other non-constant properties. It would be great if the naming rule for constants can be separated so that I can disable that rule only.
Opened #2637.
Expected Behavior
A top-level constant with a name in PascalCase (e.g.
private const val SomeConstant = 100
) shouldn't be reported as a violation.I'm using
android_studio
style and latest stable version of Android Studio (2023.2.1 Patch 2) doesn't report this.PascalCase is the style recommended by API Guidelines for Jetpack Compose.
By the way, the recommendation also applies to properties of
object
s, so it would be great to fix that as well, but that case is also reported by AS, though.Observed Behavior
The following violation is reported:
Property name should use the screaming snake case notation when the value can not be changed
.Steps to Reproduce
Simply
private const val SomeConstant = 100
.Your Environment
.editorconfig
settings