JulianCataldo / remark-lint-frontmatter-schema

Validate your Markdown frontmatter data against a JSON schema — remark-lint rule plugin
ISC License
54 stars 6 forks source link

Require that frontmatter exists #28

Open smartcontracts opened 11 months ago

smartcontracts commented 11 months ago

Hi, I'm using remark-lint-frontmatter-schema to validate the frontmatter for some markdown files. However, it seems that this plugin doesn't warn you when a file is missing frontmatter entirely, which means required fields don't get enforced at all. I believe it's reasonable behavior for an error to be thrown if the frontmatter schema requires a field to exist but the frontmatter isn't present (since the field therefore must not exist). I think a relatively easy way to solve this would be to feed empty frontmatter into validation if the frontmatter doesn't exist.

Would be ideal to get this fixed, even if this behavior is behind a flag or something to avoid breaking existing projects. Thank you!

JulianCataldo commented 11 months ago

Mhhh, interesting indeed. I will look into this. Thanks for your feedback!

JulianCataldo commented 1 month ago

Just to say I had a chance to take a stab at it, but it was quite a bit more work than estimated. I keep this open as a reminder, thx