Replies: 1 comment 1 reply
-
This is because Ktlint disallows the use of PascalCase for constants by default. https://pinterest.github.io/ktlint/1.0.0/rules/standard/#property-naming We can discuss which style we should use in the project, and add customized rules to allow it. However, we should stick with the default rule for now since ktlint is our current code formatter. |
Beta Was this translation helpful? Give feedback.
-
PR #1094 (merged) has left me a bit confused.
In non-Compose code, changing the naming of constants to
CAPITALS_AND_UNDERSCORES
seems reasonable to follow the official Kotlin style guide, although two distinct styles for constant naming coexist within a single codebase.However, in the Compose code, the official Style guidelines for Jetpack Compose APIs supersedes this and clearly states that the constants in the Compose framework MUST use
PascalCase
. In addition, it indicates Compose libraries SHOULD follow this, and apps MAY do so. Thus, I assumed that the NiA app also followed the PascalCase style, in accordance with this MAY rule, until I saw the above-mentioned PR.For example, in this change, the property
const val DisabledChipContainerAlpha: Float
is a constant. Thus, imho, usingPascalCase
for the property name is not a violation of the above style guidelines, and changing it toDISABLED_CHIP_CONTAINER_ALPHA
might lead to confusion for readers. One might wonder whyNiaIconButtonDefaults.CONSTANT_PROPERTY
followsCAPITALS_AND_UNDERSCORES
, whileButtonDefaults.ConstantProperty
in Compose usesPascalCase
, and confusing "Which one should I follow?"Why should we fix the style?
Beta Was this translation helpful? Give feedback.
All reactions