Skip to content

nuxt-content/mdclint

Repository files navigation

MDC Lint

npm version npm downloads License

Lint Markdown and MDC files with markdownlint. MDC Lint ships a CLI and an ESLint flat-config plugin tuned for Nuxt Content style Markdown.

  • CLI with glob support and --fix
  • ESLint plugin with recommended rules for Markdown/MDC
  • Presets: mdc (default) with custom MDC rules, or markdown for plain Markdown
  • Respects existing .markdownlint.* config files and supplies sane defaults

Installation

# with npm
npm install -D mdclint

# with pnpm
pnpm add -D mdclint

CLI

Lint files directly from the terminal:

npx mdclint "content/**/*.md"

Options:

  • --preset [mdc|markdown] (default: mdc) — use MDC-specific rules or standard Markdown rules only.
  • --fix — apply autofixable markdownlint suggestions in-place.

The CLI:

  • Accepts files or glob patterns and expands directories automatically.
  • Loads the first .markdownlint.* config it finds in the project root; if none exists, it uses a default config that disables some noisy markdownlint rules (e.g. MD041, table line length) and enables MDC-specific rules (MDC007, MDC018, MDC022, MDC023, MDC031, MDC032, MDC034, MDC058).

Examples:

# Lint all docs using the MDC preset
npx mdclint docs/**/*.md

# Lint plain Markdown and apply fixes
npx mdclint README.md --preset markdown --fix

ESLint Plugin (flat config)

Use MDC Lint as part of your flat ESLint config:

// eslint.config.mjs
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
import { mdcLint } from 'mdclint'

export default createConfigForNuxt({})
  .append(await mdcLint({
    files: ['content/**/*.md'],      // defaults to ['**/*.md']
    preset: 'mdc',                   // or 'markdown'
    config: { MD013: { line_length: 100 } } // optional markdownlint overrides
  }))

What the plugin provides:

  • Recommended rules under the mdclint/* namespace (all enabled as error by default).
  • A parser stub compatible with Markdown files.
  • Support for .markdownlint.* configs; pass config to override rules inline, or preset: 'markdown' to disable MDC-specific rules.

Configuration

  • MDC Lint will load the first .markdownlint.* file in your project root (.yaml, .yml, .json, .js, .cjs, etc.).
  • Built-in defaults loosen some markdownlint rules for content sites (e.g. allow missing top-level header, ignore table line length) and add MDC-specific checks. Override any rule in your config or via the plugin’s config option.
  • Use preset: 'markdown' (CLI flag or plugin option) to lint plain Markdown without MDC custom rules.

Development

pnpm install        # install dependencies
pnpm lint           # run ESLint
pnpm prepack        # build the package

Related Projects

MDC Lint is built on top of markdownlint and inspired by:

License

MIT License