Linting Org-roam files

So I’ve been working on bringing some linting into org-roam, and I think it’s now in a state where things can be tested. The PR is here: The linter currently helps you detect broken links, and auto-fix them.

To run it, simply run M-x org-roam-doctor. It’s a bit slow, because it works through all Org-roam files. C-u M-x org-roam-doctor runs the linter only on the current file. I have a couple of questions for anyone who’s testing it out:

  1. What do you think of the flow, and what could be improved?
  2. What other lints would you like to see?
1 Like

What if I am deleting a file and want that deletion to remove all org-links? Wouldn’t this proposed workflow cause a problem here? Sometimes To link, or not to link is subtle – you think a concept in a new domain might be work keeping around, but as notes progress you realize the concept is ubiquitous/fundamental and not worth keeping around.

If I understand you properly, you’re saying that you’d want the possibility to convert a link to a plain-word? For example, you’d want to delete in your org-roam-directory, and you’d want every link that points to to be change from [[][Foo] to just Foo?

If so, we could add an action for the linter that would ask you, when an invalid link is found, to either relocate it, or to only keep the label.

If you meant that you’d like to delete the links entirely, label included, then it’d break the sentences in which that link appeared.

We actually already have the action for just unlinking and keeping the label, as part of one of the auto-fixes.

Leo Vivier via Org-roam writes:

1 Like

Hah, that’s what I get for not checking the new commits on your PR. :clown_face:

It was the very first action added (; anyway, I don’t think this is the linter’s job, we should probably do something on a delete-file-advice now that we have the capability of easily finding links that will be broken on delete (this didn’t exist when Org-roam used hash-maps)

Oof, and here I was thinking that I had a handle on the code-base. So much for that!

And yeah, aye for a hook to before-save-hook.