With the help of RefTrace it should be possible to replace some of the awkward regex linting logic into clearer code and also catch more edge-cases.
Would be nice if we could start with some linting tests and see how it feels like.
Possible good starting points: