diktat
diktat copied to clipboard
New rule to check if @Preview (Jetpack Compose) functions end with 'Preview' suffix and are also private
This is a common issue with Jetpack Compose and would be really convenient. Actually, this should be a resposnibility for android lint I guess but maybe you see potential here.
Description: In Jetpack Compose it is common to give your @Preview functions a 'Preview' suffix for example
@Preview
@Composable
private fun BannerPreview() {}
It's not so common to make them private but it should be. I had a discussion on slack, check https://kotlinlang.slack.com/archives/CJLTWPH7S/p1652276247920509
Sooner or later this will be adopted by android. If you think this is a good idea for 2 new rules, I'm glad to see it in a future version :)
Good rules for the future. Will be added after 1.2.0
It will be really useful to have a rule to check if Preview functions are called in the non preview functions.
https://github.com/saveourtool/diktat/discussions/1725