mrmans0n / compose-rules

Lint rules for ktlint/detekt aimed to contribute to a healthier usage of Compose. Actively maintained and evolved fork of the Twitter Compose rules.
https://mrmans0n.github.io/compose-rules
Other
543 stars 20 forks source link

[Idea] add ComposePreviewNaming #229

Open egorikftp opened 4 months ago

egorikftp commented 4 months ago

The idea is to align naming of preview composable functions in unified format. we already have PreviewAnnotationNaming and PreviewPublic.

Propose: name: ComposePreviewNaming logic: composable preview function should require Preview postfix

Didn't find any official docs, but Google follow this name convention: https://developer.android.com/develop/ui/compose/tooling/previews

valid code

@Preview
@Composable
private fun SectionCounterPreview() {
    // code
}

invalid

@Preview
@Composable
private fun SectionCounter() {
    // code
}
@Preview
@Composable
private fun PreviewSectionCounter() {
    // code
}