Closed JakeWharton closed 10 months ago
I forgot ktlint doesn't have the classpath so it can't do type resolution. I guess the only option is either disabling the rule or whether an option is provided to name the "Modifier"-like type.
Yea, probably adding a configurable modifier config for these rules would be nice to have. So far, we only look at the type name, and if it's called Modifier or GlanceModifier, it's covered. But it would be nice to have the flexibility.
As per the disabling the rule for cases like Redwood, or any where Compose UI is not a thing: You should be able to disable any of these rules altogether.
From what you mention you are using ktlint, so you can disable them via the .editorconfig
file: https://pinterest.github.io/ktlint/1.0.1/faq/#how-do-i-enable-or-disable-a-rule
From memory I think it was something like:
ktlint_compose_modifier-missing-check = disabled
There are other modifier-related rules that you might want to disable as well in those cases. In the config it'd be ktlint_compose_
plus:
I added these rules to Mosaic mostly for the function naming rule, but I'm getting errors about missing
Modifier
parameters. Now, Mosaic does have aModifier
type now, but that wasn't always the case. And it certainly isn't the case that other Compose-based projects will have such a type. In Redwood we are actively planning on eliminating ourModifier
type because the semantics are not the same as in Compose UI. Once that happens our node-emitting functions will never be able to comply with this rule.The presence of a
Modifier
type is certainly common across multiple node types, but it's not fundamentally intrinsic to Compose. What should the behavior of this rule be in the larger non-Compose UI, Compose-based ecosystem?Maybe it could hardcode a list of well-known
Modifier
types (Compose UI + Glance) which are detected on the classpath to enable the rule. And then perhaps a configuration option could be exposed for cases like Mosaic where we can specify the fully-qualified type name of ourModifier
. Plus, in the future case of Redwood, this would allow our non-"Modifier"-namedModifier
-like type to participate in this rule's validation.