4.8 KiB
Troubleshooting Guide
Common issues and solutions for markdownlint-cli2 and the code-quality plugin.
Hook Not Running
Symptoms: Markdown files created but not linted
Causes:
- markdownlint-cli2 not installed → Install with npm
- Hook disabled in settings → Check
.claude/settings.jsonor.claude/hooks.json - File extension not .md or .markdown → Rename file or update hook configuration
- Hook script not executable → Check file permissions
- Wrong working directory → Hook runs from project root
Solution:
# Install markdownlint-cli2 (using local/project npm)
npm install --save-dev markdownlint-cli2
# Or install globally (alternative)
npm install -g markdownlint-cli2
# Test manually
markdownlint-cli2 --fix yourfile.md
# Check hook configuration
cat .claude/hooks.json
Unfixable Issues
Symptoms: Hook reports issues that remain after fixing
Causes:
- Rule requires manual judgment (e.g., heading hierarchy, heading content)
- Content violates multiple conflicting rules
- Structural issues (missing language, wrong heading level)
- Semantic issues (duplicate headings, improper nesting)
Solution: Run /mr-sparkle:lint-md to see detailed error messages, then fix manually
Common unfixable issues:
- Heading hierarchy violations (must restructure manually)
- Multiple H1 headings (decide which to demote)
- Missing code block language (must choose appropriate language)
- Duplicate heading content (reword one of them)
Configuration Not Applied
Symptoms: Custom rules not taking effect
Causes:
- Configuration file in wrong location (see file precedence below)
- Invalid JSON syntax (use a JSON validator)
- Wrong filename or precedence issue
- Parent directory config overriding your settings
- Cached configuration (stale)
- Using markdownlint file instead of markdownlint-cli2 file
Solution:
# Validate JSON syntax
npx jsonlint .markdownlint-cli2.jsonc
# Check which config file is being used
markdownlint-cli2 --help # Shows search order
# Test with explicit config
markdownlint-cli2 --config .markdownlint-cli2.jsonc "**/*.md"
# Debug config loading
markdownlint-cli2 yourfile.md 2>&1 | grep -i config
File precedence reminder:
.markdownlint-cli2.jsonc(highest priority, recommended).markdownlint-cli2.yaml.markdownlint.jsonc.markdownlint.json
For complete configuration details, fetch the official documentation: https://github.com/DavidAnson/markdownlint-cli2
Linting Errors on Valid Markdown
Symptoms: Markdownlint reports errors on markdown that renders correctly
Cause: Markdown renderers are permissive; linters enforce stricter standards
Solution: This is expected behavior - linting enforces best practices even if renderers are forgiving
Example:
#No space after hash - renders fine but fails MD018
Better to follow the standard for consistency.
Performance Issues
Symptoms: Linting is slow on large repositories
Solutions:
- Add appropriate ignore patterns to
.markdownlint-cli2.jsonc - Use
.gitignoreintegration (already enabled in our config) - Lint specific directories instead of entire tree
- Exclude large generated files
{
"ignores": [
"node_modules/**",
"dist/**",
"build/**",
"**/*.min.md",
"vendor/**"
]
}
Command Not Found
Symptoms: markdownlint-cli2: command not found
Causes:
- Not installed globally
- npm global bin directory not in PATH
- Installed locally instead of globally
Solution:
# Install globally
npm install -g markdownlint-cli2
# Or use npx (no installation needed)
npx markdownlint-cli2 "**/*.md"
# Or install locally and use npm scripts
npm install --save-dev markdownlint-cli2
# Then add to package.json scripts
False Positives
Symptoms: Linter flags correct markdown as errors
Solution: If a rule doesn't fit your workflow, disable it in config:
{
"config": {
"MD013": false // Disable specific rule
}
}
Or disable inline for specific cases:
<!-- markdownlint-disable MD013 -->
This very long line won't be flagged
<!-- markdownlint-enable MD013 -->
Hook Returns Non-Zero Exit
Symptoms: Hook fails and blocks Claude operations
Cause: Unfixable linting errors return exit code 1 (by design, non-blocking)
Expected behavior: The hook should report errors but NOT block the operation
If blocking occurs: Check hook configuration - should use exit 1 (report) not exit 2 (block)
Getting Help
- Check
pitfalls-reference.mdfor common mistakes - Check
rules-reference.mdfor rule details - Run
/mr-sparkle:lint-mdfor detailed error messages - Visit https://github.com/DavidAnson/markdownlint-cli2/issues
- Check markdownlint rules: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md