You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As reported in #176 (Originally posted by @chrimaeon in #176 (comment)), the fix for running the compose rules with the ktlint-intellij-plugin only partially works. Given code sample below:
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@Composable
fun Post() {
Text("foo")
}
does not show violation below which is shown by Ktlint CLI"
Post.kt:11:5: This @Composable function emits content but doesn't have a modifier parameter.
See https://mrmans0n.github.io/compose-rules/rules/#when-should-i-expose-modifier-parameters for more information. (compose:modifier-missing-check)
Summary error count (descending) by rule:
compose:modifier-missing-check: 1
Process finished with exit code 1
with ktlint-compose 0.3.9 and intellij-ktlint-plugin 0.20.0
After investigation in ktlint and ktlint-intellij-plugin, I have found the cause of the problem. Like in #176 the cause is the embedded kotlin compiler which conflicts with packages provided by Intellij IDEA itself. In the ktlint-intellij-plugin those problems are resolved with relocating packages.
I have tried to relocate the packages in ktlint to prevent that third party supplier of rules are not affected by this but it didn't work out as expected. For now, I see no other solution than that each third party supplier of rules applies relocation of packages similar as is done in ktlint-intellij-plugin. For compose rules that would mean that configuration below has to be added to build file of ktlint-rules:
shadowJar {
// Relocate packages that may conflict with ktlint-intellij-plugin. The rule set won't work when relocations below
// are not kept in sync with https://github.com/nbadal/ktlint-intellij-plugin/blob/main/lib/build.gradle.kts
relocate("org.jetbrains.concurrency", "shadow.org.jetbrains.concurrency")
relocate("org.jetbrains.kotlin.psi.KtPsiFactory", "shadow.org.jetbrains.kotlin.psi.KtPsiFactory")
relocate("org.jetbrains.kotlin.psi.psiUtil", "shadow.org.jetbrains.kotlin.psi.psiUtil")
relocate("org.jetbrains.org", "shadow.org.jetbrains.org")
}
On my local machine, I have build the compose rules for ktlint with changes above. Both ktlint CLI and ktlint-intelli-plugin now report the violation as requested by OP.
The text was updated successfully, but these errors were encountered:
As reported in #176 (Originally posted by @chrimaeon in #176 (comment)), the fix for running the compose rules with the
ktlint-intellij-plugin
only partially works. Given code sample below:does not show violation below which is shown by Ktlint CLI"
with ktlint-compose 0.3.9 and intellij-ktlint-plugin 0.20.0
After investigation in
ktlint
andktlint-intellij-plugin
, I have found the cause of the problem. Like in #176 the cause is the embedded kotlin compiler which conflicts with packages provided by Intellij IDEA itself. In thektlint-intellij-plugin
those problems are resolved with relocating packages.I have tried to relocate the packages in
ktlint
to prevent that third party supplier of rules are not affected by this but it didn't work out as expected. For now, I see no other solution than that each third party supplier of rules applies relocation of packages similar as is done inktlint-intellij-plugin
. For compose rules that would mean that configuration below has to be added to build file ofktlint-rules
:On my local machine, I have build the compose rules for ktlint with changes above. Both
ktlint CLI
andktlint-intelli-plugin
now report the violation as requested by OP.The text was updated successfully, but these errors were encountered: