mrmans0n / compose-rules

Lint rules for ktlint/detekt aimed to contribute to a healthier usage of Compose. Actively maintained and evolved fork of the Twitter Compose rules.
https://mrmans0n.github.io/compose-rules
Other
525 stars 19 forks source link

Unable to suppress a rule with spotless #249

Closed NikhilMunna closed 2 months ago

NikhilMunna commented 2 months ago

i've added https://mrmans0n.github.io/compose-rules/rules/#hoist-all-the-things custom ruleset to ktlint spotless

but i'm unable to suppress a rule for a function

I tried adding @Suppress("ktlint:compose:vm-forwarding-check") above the function but it doesn't work

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':spotlessKotlin'. Error on line: 127, column: 17 rule: compose:vm-forwarding-check Forwarding a ViewModel/Presenter through multiple https://github.com/composable functions should be avoided. Consider using state hoisting.

See https://mrmans0n.github.io/compose-rules/rules/#hoist-all-the-things for more information.

Try: Run with --info or --debug option to get more log output.

mrmans0n commented 2 months ago

This is managed by ktlint, these rules don't control their own suppressions at all, it's the job of the linter itself to do so.

NikhilMunna commented 2 months ago

can you help me with a sample of how to suppress if you have any?

mrmans0n commented 2 months ago

The suppression annotation you wrote there seems to be correct according to ktlint's latest documentation, but somehow your spotless / ktlint setup is not picking it up. Just make sure that the ktlint version being brought by spotless is one that supports that style of suppressions, and double check your gradle configuration - those are the only things that come to mind, sorry.