slackhq / compose-lints

Lint checks to aid with a healthy adoption of Compose
https://slackhq.github.io/compose-lints
Apache License 2.0
388 stars 22 forks source link

Don't expect Modifier parameters on Preview functions #377

Closed ZacSweers closed 6 days ago

yukilabo commented 2 months ago

In our project, we are experiencing the following problem. Does this Issue point out something similar?

// These are annotated with @Preview.
@DeviceWidthPreviews
@ThemePreviews
annotation class ComponentPreviews

// "TestPreview"  is a preview function, but Lint says "There is no modifier".
@ComponentPreviews
@Composable
private fun TestPreview() {
    Text(text = "Hello, World!")
}

I think this is because isPreview only checks if the function's annotation has @Preview attached to it.