twitter / compose-rules

Static checks to aid with a healthy adoption of Compose
https://twitter.github.io/compose-rules
Other
1.37k stars 93 forks source link

Allow reporting PreviewPublic for @Preview Composables without any param #95

Closed G00fY2 closed 2 years ago

G00fY2 commented 2 years ago

Currently the PreviewPublic rule only reports Composable functions that are annotated with @Preview and have preview params. In our codebase we always wrap the actual Composables into separate Preview Composables (e.g. to set a specific theme). Therefore Composables annotated with@Preview are solely used as previews and should never be used in actual UI. Currently this rule won't report these functions.

Would be nice to allow configuring this rule, so that also Composable functions annotated with @Preview and without any params are reported.

mrmans0n commented 2 years ago

I am adding in #102 a previewPublicOnlyIfParams param, so if you set that to false, you'll get this behavior you asked. When that's merged and 0.0.20 is published, you'll be able to use it 😄

G00fY2 commented 2 years ago

Thank you very much. Was thinking about contributing a PR by myself. Great that you already went for this feature request.