slackhq / compose-lints

Lint checks to aid with a healthy adoption of Compose
https://slackhq.github.io/compose-lints
Apache License 2.0
392 stars 23 forks source link

Sample/documentation to use the lint rules for compose mpp projects #60

Open sureshg opened 1 year ago

sureshg commented 1 year ago

As per the current documentation, compose-lint should work for non-android projects by adding the following dependency and android lint plugin.

Just add the dependency to the lintChecks configuration. Note for non-android projects, you must apply the com.android.lint Gradle plugin to use this.

dependencies {
  lintChecks("com.slack.lint.compose:compose-lint-checks:<version>")
}

But it's not working as expected for a compose mpp project as it can't find the main sourceset. So it would be great if you can provide some samples/documentation on how to configure this lint rules for compose mpp projects.

ZacSweers commented 1 year ago

PRs welcome, I've never tried to apply it in a multiplatform project so I don't know off-hand. non-android really kinda means just jvm projects in this context, I'm not sure lint supports multiplatform.

ZacSweers commented 1 year ago

Redwood may have some solutions

so the setup for multiplatform, js, jvm, and android kotlin plugins are all here: https://github.com/cashapp/redwood/blob/65be6c3ceec60d8b44eb304af8e93584ce3641fb/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodLintPlugin.kt.

the task is in there as well, although it just forks a JVM to run the CLI which depends on lint. The lint setup within the CLI is here: https://github.com/cashapp/redwood/blob/65be6c3ceec60d8b44eb304af8e93584ce3641fb/redwood-cli/src/main/kotlin/app/cash/redwood/cli/LintCommand.kt