obsidian-linter icon indicating copy to clipboard operation
obsidian-linter copied to clipboard

FR: enable rules via frontmatter

Open Mikle-Bond opened this issue 1 year ago • 2 comments

Is Your Feature Request Related to a Problem? Please Describe.

There's an option to disable rules per-file, as described in the official docs. I'd like to see a symmetrical option to forcibly enable rules per-file.

For example. I have been creating a bunch of daily notes from a template. This template happens to add an identical first H1 heading: "Log". So, the yaml-title-alias rule would add this to every daily note. With "lint on focus change" option this does a frustrating thing, when a meaningless alias appears after viewing any old note.

My options are: either disable "lint on focus change" or disable yaml-title-alias rule. Or go through all the notes and fix H1 headings to carry at least some meaning.

Describe the Solution You'd Like

I'd like some rules, like yaml-title-alias or move-tags-to-yaml be applied only to the notes that are ready for this. In my case, that means I would add them to the templates that will generate (or require me to type in) a meaningful H1 header/filename.

---
enabled rules:
  - yaml-title-alias
disabled rules:
  - header-increment
  - move-footnotes-to-the-bottom
---

# Log {{date:dddd, 1YYYY MMMM Do}}

# Links

# Extracted

Describe Alternatives You've Considered

As I said, disabling some functionality, and going though entire vault fixing/verifying almost all of my notes. A reliable but not an easy approach.

Additional Context

Implementing this shouldn't be hard, as most of the code needed already exists for "disabled rules" feature. Exceptions: the all probably shouldn't be an option for "enabled rules", as it may break a lot of thins. It shouldn't override "Folders to ignore" too.

So, the suggested logic is:

  • if note is in ignored folder - skip note;
  • if note has rule disabled - skip rule;
  • if note has rule enabled - apply rule;
  • if note doesn't mention the rule - look at what's configured in settings.

Mikle-Bond avatar Aug 17 '23 12:08 Mikle-Bond