Does anyone know if it's possibly to write a lint ...
# android
c
Does anyone know if it's possibly to write a lint check that just warns if there's a specific import being used?
b
Absolutely
On our team we do this -- and add quick fixes to change the import to a desired one (if it applies to your use case)
c
Nice! I've only written
ResourceXmlDetector
so I'm trying to figure out what to extend for a java/kotlin file.
b
SourceCodeScanner IIRC
And Detector as well
c
Hm. Doesn't seem to be autofilling. I will try to look up more docs and come back if I can't happen to figure it out. Thank you @Brandon Trautmann
👍 1
@Brandon Trautmann you sure it's not just
Detector(), UastScanner
as in
class SampleCodeDetector : Detector(), UastScanner {
https://github.com/googlesamples/android-custom-lint-rules/blob/master/android-studio-4/checks/src/main/java/com/example/lint/checks/SampleCodeDetector.kt
Found a better repo with more lint checks. I think I got it. Thank you https://github.com/tikurahul/lint-experiments/tree/master/lint/src/main/java/com/rahulrav
l
There are a couple of examples of custom lint checks and their unit tests which you may find useful https://github.com/jshvarts/CustomLintRule
👍 1