grunt-markdownlint
raw JSON → 3.1.6 verified Fri May 01 auth: no javascript
Grunt plugin for markdownlint, a rule-based Markdown linter. Version 3.1.6 wraps markdownlint 0.26+. Integrates linting into Grunt build pipelines, supporting config files (JSON) or inline rules. Alternatives: direct markdownlint CLI or other Grunt linters. Active maintenance, monthly releases.
Common errors
error Warning: Task "markdownlint" not found. ↓
cause grunt.loadNpmTasks('grunt-markdownlint') not called or plugin not installed.
fix
Run
npm install --save-dev grunt-markdownlint and add grunt.loadNpmTasks('grunt-markdownlint') to Gruntfile. error Fatal error: Cannot find module 'markdownlint' ↓
cause markdownlint is a peer dependency not installed automatically.
fix
Run
npm install --save-dev markdownlint. Warnings
breaking Minimum Node.js version required: v13+ (since v3.0.0). Older versions cause runtime errors. ↓
fix Upgrade Node.js to v13 or later.
gotcha Config file must be parsed with grunt.file.readJSON, not a string path. ↓
fix Use grunt.file.readJSON('path/to/config.json').
deprecated The 'rules' property in options is deprecated; use 'config' instead. ↓
fix Replace 'rules' with 'config' in task options.
gotcha Glob patterns in src must not include directories without markdown files; task succeeds silently if no files matched. ↓
fix Verify glob patterns with grunt.file.expand.
Install
npm install grunt-markdownlint yarn add grunt-markdownlint pnpm add grunt-markdownlint Imports
- grunt wrong
require('grunt-markdownlint')(grunt);correctgrunt.loadNpmTasks('grunt-markdownlint'); grunt.initConfig({ markdownlint: { ... } }); - config wrong
options: { rules: { ... } }correctoptions: { config: { 'default': true, 'line-length': false } } - configFile wrong
options: { configFile: 'path/to/config.json' }correctoptions: { config: grunt.file.readJSON('path/to/config.json') }
Quickstart
// Gruntfile.js
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-markdownlint');
grunt.initConfig({
markdownlint: {
all: {
options: {
config: {
'default': true,
'line-length': false,
'no-inline-html': false
}
},
src: ['README.md', '**/*.md', '!node_modules']
}
}
});
grunt.registerTask('lint', ['markdownlint']);
};