Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/injms/remark-frontmatter-linter
A Remark plugin that lints the frontmatter in a markdown file.
https://github.com/injms/remark-frontmatter-linter
Last synced: 19 days ago
JSON representation
A Remark plugin that lints the frontmatter in a markdown file.
- Host: GitHub
- URL: https://github.com/injms/remark-frontmatter-linter
- Owner: injms
- License: other
- Created: 2023-06-14T22:04:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-03T15:36:21.000Z (about 1 month ago)
- Last Synced: 2024-10-07T23:20:12.520Z (about 1 month ago)
- Language: TypeScript
- Size: 1.72 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: license.md
- Code of conduct: code_of_conduct.md
Awesome Lists containing this project
README
# Remark Frontmatter linter
Uses [eslint-plugin-yml] to lint YAML frontmatter in a Markdown file.
Requirements:
* [remark-lint]
* [remark-frontmatter]## ๐๏ธ Installation
Install this package - `@injms/remark-frontmatter-linter` - and its dependencies - `remark-lint` and `remark-frontmatter` - with npm:
```bash
npm install remark-lint remark-frontmatter @injms/remark-frontmatter-linter
```## โจ๏ธ Set up for [`remark-cli`][remark-cli]
Add the plugin in the list of plugins, [where ever that is being set][example-config-files], remembering to add it **after** the `remark-lint` and `remark-frontmatter` plugins.
```javascript
// .remarkrc.mjs
export default {
"plugins": [
"remark-lint",
"remark-frontmatter",
"remark-frontmatter-linter",
],
}
```## โ๏ธ Configuration
By default the rules are the [standard YML set of rules][standard-yml-rules] (`plugin:yml/standard`) but with indentation changed to be 2 spaces.
To change this, both the `extends` and `rules` properties can be set in the Remark config file, for example:
```javascript
// .remarkrc.mjs
export default {
"plugins": [
"remark-lint",
"remark-frontmatter",
[
"remark-frontmatter-linter",
{
extends: [
'yml:prettier',
],
rules: {
'yml/indent': ['error', 4],
'yml/plain-scalar': 'off',
}
}
],
],
}
```See the [`eslint-plugin-yml` configuration docs][eslint-plugin-yml-config-docs] for a list of available configs and rules.
Setting anything in `extends` will _overwrite_ the default use of `yml:standard`.
Setting anything in `rules` will _add_ to the rules - so unless `yml/indent` is set then the default of 2 spaces will be used.
## ๐งช Tests
```shell
npm run test
```This plugin uses the [AVA test runner][ava].
[eslint-plugin-yml]: https://github.com/ota-meshi/eslint-plugin-yml
[remark-lint]: https://github.com/remarkjs/remark-lint
[remark-frontmatter]: https://github.com/remarkjs/remark-frontmatter
[remark-cli]: https://github.com/remarkjs/remark/tree/main/packages/remark-cli
[standard-yml-rules]: https://ota-meshi.github.io/eslint-plugin-yml/rules/
[example-config-files]: https://github.com/remarkjs/remark/tree/618a9ad1d44aa106bd2a8c61ebf8589cfe97fa16/packages/remark-cli#example-config-files-json-yaml-js
[ava]: https://github.com/avajs/ava
[eslint-plugin-yml-config-docs]: https://ota-meshi.github.io/eslint-plugin-yml/user-guide/#usage