twitter / compose-rules

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

Create a custom modifier using a composable modifier factory is now recommended, however it is still failing "Avoid Modifier extension factory functions" #130

Open YingChen0605 opened 1 month ago

YingChen0605 commented 1 month ago

Describe the bug

https://twitter.github.io/compose-rules/rules/#avoid-modifier-extension-factory-functions is no longer true now. Refer to the official documentation:

Note: In previous versions of Compose, we recommended against this approach and suggested using composed {} instead via a lint rule. Now that composed {} is not recommended, the lint rule has been removed.

To Reproduce Steps to reproduce the behavior: Adding a new Composable:

@Composable
private fun Modifier.modify(viewModel: xxViewModel) =  this then Modifier.viewable(onView = viewModel.onView)
        .margin(margin = viewModel.margin)

Expected behavior It should not be flagged as a violation.

Screenshots

Screenshot 2024-08-05 at 12 21 31 PM

Environment com.twitter.compose.rules.detekt of 0.0.26

kenyee commented 1 month ago

These have migrated to: https://github.com/mrmans0n/compose-rules https://slackhq.github.io/compose-lints/

YingChen0605 commented 1 month ago

@kenyee Thank you for getting back so quickly and informing about the migration! 👍 Assuming https://github.com/twitter/[compose-rules](https://github.com/twitter/compose-rules) is now deprecated. Would you suggest choosing between https://github.com/mrmans0n/compose-rules(ktlint and detekt) and https://slackhq.github.io/compose-lints/(lint) for use? Do their rules overlap to some extent?

kenyee commented 1 month ago

use the one that fits your usage best. Slack's is done using Android lint. The original was ktlint+detekt.