compose-rules icon indicating copy to clipboard operation
compose-rules copied to clipboard

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

Open YingChen0605 opened this issue 1 year ago • 3 comments

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

YingChen0605 avatar Aug 05 '24 19:08 YingChen0605

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

kenyee avatar Aug 05 '24 19:08 kenyee

@kenyee Thank you for getting back so quickly and informing about the migration! 👍 Assuming 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?

YingChen0605 avatar Aug 05 '24 22:08 YingChen0605

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

kenyee avatar Aug 05 '24 23:08 kenyee