:wave: Is it conceivable to use KSP to generate l...
# ksp
r
👋 Is it conceivable to use KSP to generate lint rules ? I would like to create an annotation like
@Replacing("androidx.compose.material3")
to enforce design system use in Compose. I don't see how to do it in pure Lint rule
e
ksp is not a natural fit because you want to generate code for a different module (lint rules) than the annotated sources
you could potentially do something where you generate resources with ksp and copy them to your lint rules (possibly even automatically with gradle)
👍 2
w
Maybe you can use something like Classgraph to dynamically scan the package with composables and find all the annotated methods as part of the lint check? That'd come with some runtime overhead though
d
Kinda similar to the first comment, but would using KSP to generate the XML config for consumption by lint work? https://googlesamples.github.io/android-custom-lint-rules/api-guide.html#options There is an example of this in slack-lints where there is a generic rule that get supplied with data at build time via option: https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/inclusive/InclusiveNamingChecker.kt#L60
👀 1
r
Ok thanks for the guidance 👍