{"id":26215,"library":"remark-lint-frontmatter-schema","title":"remark-lint-frontmatter-schema","description":"Validate Markdown frontmatter YAML against an associated JSON schema using remark-lint. Current version: 3.15.4 (released Oct 2023). Released regularly with bug fixes. Key differentiators: supports JSON Schema draft-07, both in-file $schema and global pattern associations, auto-fixes, integration with VS Code and ESLint MDX, and CLI reporting. Uses ajv for validation.","status":"active","version":"3.15.4","language":"javascript","source_language":"en","source_url":"https://github.com/JulianCataldo/remark-lint-frontmatter-schema","tags":["javascript","lint","yaml","remark","validation","linting","json-schema","linter","unified","typescript"],"install":[{"cmd":"npm install remark-lint-frontmatter-schema","lang":"bash","label":"npm"},{"cmd":"yarn add remark-lint-frontmatter-schema","lang":"bash","label":"yarn"},{"cmd":"pnpm add remark-lint-frontmatter-schema","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for remark-lint plugin integration","package":"unified","optional":false},{"reason":"Required for lint rule base","package":"remark-lint","optional":false},{"reason":"Used for JSON Schema validation","package":"ajv","optional":false},{"reason":"Used to parse frontmatter YAML","package":"yaml","optional":false}],"imports":[{"note":"Default export is a function that returns a remark plugin. CommonJS require is also supported.","wrong":"const { remarkLintFrontmatterSchema } = require('remark-lint-frontmatter-schema')","symbol":"remarkLintFrontmatterSchema","correct":"import remarkLintFrontmatterSchema from 'remark-lint-frontmatter-schema'"},{"note":"In CJS, default export is accessed directly via require, not destructured.","wrong":"const { default: plugin } = require('remark-lint-frontmatter-schema')","symbol":"default","correct":"const plugin = require('remark-lint-frontmatter-schema')"},{"note":"This is a default export, not named export. Named import will result in undefined.","wrong":"import { remarkLintFrontmatterSchema } from 'remark-lint-frontmatter-schema'","symbol":"remarkLintFrontmatterSchema","correct":"import remarkLintFrontmatterSchema from 'remark-lint-frontmatter-schema'"}],"quickstart":{"code":"import { readSync } from 'fs';\nimport { remark } from 'remark';\nimport remarkLint from 'remark-lint';\nimport remarkLintFrontmatterSchema from 'remark-lint-frontmatter-schema';\n\nconst processor = remark()\n  .use(remarkLint)\n  .use(remarkLintFrontmatterSchema, {\n    schemas: [\n      {\n        pattern: '*.md',\n        schema: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            date: { type: 'string', format: 'date' }\n          },\n          required: ['title', 'date']\n        }\n      }\n    ]\n  });\n\nconst result = processor.processSync(\n  '---\\ntitle: Hello\\ndate: 2023-01-01\\n---\\n# Content'\n);\n\nconsole.log(result.messages);\n// [] (no errors)\n\nconst result2 = processor.processSync(\n  '---\\ntitle: 123\\ndate: not-a-date\\n---\\n# Content'\n);\n\nconsole.log(result2.messages);\n// [ { message: 'title: must be string', ... } ]","lang":"typescript","description":"Set up a remark processor with remark-lint and remark-lint-frontmatter-schema, validate frontmatter against a JSON schema, and see lint messages."},"warnings":[{"fix":"Validate your schema against JSON Schema meta-schema before use.","message":"Schema must be a valid JSON Schema (draft-07) object. Invalid schemas will fail silently or throw obscure errors.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Update configuration to new format: { schemas: [{ pattern: '*.md', schema: {...} }] }","message":"From v3.0.0, the plugin changed from a custom configuration format to using a `schemas` array with `pattern` and `schema` objects. Old `schemaPath` option removed.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use `schemas` array with inline schema or `$ref` to external file.","message":"The `schemaPath` option was deprecated in v3.0.0 and removed in v3.14.0.","severity":"deprecated","affected_versions":">=3.14.0"},{"fix":"Use relative paths (e.g., `$schema: ./schema.json`) or a URL. For local schemas, ensure the file resolves relative to the working directory.","message":"In-file `$schema` key in frontmatter is only supported if the schema URL is an HTTP(S) URL or a relative file path. Absolute file paths are not supported.","severity":"gotcha","affected_versions":">=3.13.0"},{"fix":"Ensure that only one YAML frontmatter block exists, or the first one is the intended frontmatter.","message":"The plugin only validates the first YAML block in the Markdown file even if multiple YAML blocks exist. It treats the first YAML as frontmatter.","severity":"gotcha","affected_versions":">=3.15.3"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install remark-lint-frontmatter-schema` and ensure import path is correct.","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'remark-lint-frontmatter-schema'"},{"fix":"Use default import: `import plugin from 'remark-lint-frontmatter-schema'`","cause":"Importing the module incorrectly (e.g., named import instead of default).","error":"TypeError: plugin is not a function"},{"fix":"Add the missing required fields to the frontmatter YAML.","cause":"Frontmatter missing required fields as per schema.","error":"ValidationError: data must have required property 'title'"},{"fix":"Check the `schemas` array configuration and ensure the pattern matches the file being processed.","cause":"Glob pattern in configuration doesn't match any defined schema.","error":"Error: No schema defined for pattern '*.md'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}