From 5659ad9863f7ce47962668a473fd29c79d9c710e Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 27 Apr 2023 14:43:47 +0530 Subject: feat(build): add Slack's Compose Lints --- app/lint-baseline.xml | 11 +++++++++++ .../src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt | 8 ++++++++ .../main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt | 2 +- .../src/main/kotlin/app/passwordstore/gradle/LintConfig.kt | 6 +++++- gradle/libs.versions.toml | 1 + 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index e0ce6073..d599da9d 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -128,6 +128,17 @@ column="4"/> + + + + ()?.run { lint.configureLint(project) } project.extensions.findByType()?.run { lint.configureLint(project) } + val catalog = project.extensions.getByType() + val libs = catalog.named("libs") + project.dependencies.addProvider( + "lintChecks", + libs.findLibrary("thirdparty-compose-lints").get() + ) } } diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt index 253c7aed..c5cf84a0 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt @@ -23,6 +23,6 @@ class KotlinJVMLibrary : Plugin { apply(LintPlugin::class) apply(KotlinCommonPlugin::class) } - project.extensions.configure { configureLint(project) } + project.extensions.configure { configureLint(project, isJVM = true) } } } diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt index 41bb781f..de63c580 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt @@ -4,7 +4,7 @@ import com.android.build.api.dsl.Lint import org.gradle.api.Project object LintConfig { - fun Lint.configureLint(project: Project) { + fun Lint.configureLint(project: Project, isJVM: Boolean = false) { quiet = project.providers.environmentVariable("CI").isPresent abortOnError = true checkReleaseBuilds = true @@ -28,6 +28,10 @@ object LintConfig { disable += "TypographyQuotes" // False-positives abound due to use of ViewBinding disable += "UnusedIds" + if (!isJVM) { + enable += "ComposeM2Api" + error += "ComposeM2Api" + } baseline = project.file("lint-baseline.xml") } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 238133f3..a4c8e428 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -79,6 +79,7 @@ testing-turbine = "app.cash.turbine:turbine:0.12.3" thirdparty-bouncycastle-bcpkix = { module = "org.bouncycastle:bcpkix-jdk15to18", version.ref = "bouncycastle" } thirdparty-bouncycastle-bcprov = { module = "org.bouncycastle:bcprov-jdk15to18", version.ref = "bouncycastle" } thirdparty-commons_codec = "commons-codec:commons-codec:1.14" +thirdparty-compose-lints = "com.slack.lint.compose:compose-lint-checks:1.2.0" thirdparty-eddsa = "net.i2p.crypto:eddsa:0.3.0" thirdparty-fastscroll = "me.zhanghai.android.fastscroll:library:1.2.0" thirdparty-flowbinding-android = { module = "io.github.reactivecircus.flowbinding:flowbinding-android", version.ref = "flowbinding" } -- cgit v1.2.3