This is a MegaLinter plugin for linting YAML frontmatter found in Markdown files.
MegaLinter by OxSecurity is a linter tool that supports various programming languages and file formats. This repository contains a MegaLinter plugin for linting YAML frontmatter found in Markdown files. yamllint by adrienverge is used to perform the actual linting while GNU sed is used to extract the frontmatter from the Markdown files. This plugin is designed to be used with MegaLinter and is not intended to be used as a standalone tool.
To use this plugin, you need to have MegaLinter installed. Please refer to the MegaLinter documentation for installation instructions.
To use this plugin, add the following to your MegaLinter configuration:
PLUGINS:
- "https://raw.githubusercontent.com/wesley-dean/mega-linter-plugin-fmlint/refs/heads/main/mega-linter-plugin-fmlint/fmlint.megalinter-descriptor.yml
Tip
Simply adding the plugin to the PLUGINS
section will cause MegaLiner to read
the descriptor and make it available for use. However, depending on your
MegaLinter configuration, you may need to enable the linter in the
ENABLE_LINTERS
section as well. For example:
ENABLE_LINTERS:
- "MARKDOWN_FMLINT""
The plugin uses yamllint
to lint the frontmatter of Markdown files. By
default, this plugin will lint all Markdown files in the repository. That's
probably not the desired behavior as it'll attempt to lint Markdown files that
don't have any frontmatter at which point yamllint
will throw an error saying
that there's no ---
found. To prevent this, limit the files to only those
that actually are expected to include frontmatter. This can be done by setting
MARKDOWN_FMLINT_FILTER_REGEX_*
options in the .mega-linter.yml
file. For
example, if you only want to lint Markdown files the pages
and posts
directories, you can add the following to your .mega-linter.yml
file:
MARKDOWN_FMLINT_FILTER_REGEX_INCLUDE: "(pages\|posts)/.*\\.md"
To configure yamllint
(the tool that performs the actual linting), you may
create a .fmlint.yml
file in the root of your repository. For more
information on configuring, refer to the
yamllint documentation
Note
Because yamllint
is doing the linting, the configuration file must be a
valid configuration for yamllint
. By default, the plugin will look for a
file named .fmlint.yml
in the root of your repository. It will not look for
a file named .yamllint.yml
or any other name. If you want to use a
different name, you can specify the name of the file in the
FMLINT_CONFIG_FILE
option. This is because one is likely to have a
different configuration for yamllint
than for fmlint
. If you want to
use the same configuration for both, you can simply create a symlink to the
file in the root of your repository.