tpmjs/packages/tools/official/markdown-lint-basic/README.md
Ajax Davis 5d2096fb5d feat: add 100+ official TPMJS tools
Implements a comprehensive suite of AI SDK v6 tools across multiple categories:

- Research (5): page-brief, compare-pages, source-credibility, claim-checklist, timeline-from-text
- Web (10): fetch-text, links-catalog, extract-meta, extract-json-ld, redirect-trace, sitemap-read, rss-read, table-extract, robots-policy, url-normalize
- Data (15): csv-parse, csv-stringify, json-repair, json-schema-validate, yaml-parse, yaml-stringify, text-chunk, normalize-whitespace, dedupe-by-key, pivot, rows-filter, rows-sort, rows-group-aggregate, rows-join, schema-infer
- Doc (12): toc-generate, glossary-build, faq-from-text, executive-brief, decision-record-adr, prd-outline, acceptance-criteria, style-rewrite
- Eng (12): diff-text-unified, env-var-docs-generate, dependency-audit-lite, conventional-commit-suggest, markdown-lint-basic, test-case-generate, stacktrace-parse, release-notes, changelog-entry, release-checklist
- Security (7): redact-secrets, secret-scan-text, url-risk-heuristic, csp-compose, hardening-checklist-web, access-control-matrix, data-classification-heuristic
- Stats (9): effect-size-suite, bootstrap-ci, permutation-test, multiple-testing-adjust, linear-regression-ols, logistic-regression, time-series-decompose-lite, anomaly-detect-mad
- Ops (7): slo-draft, runbook-draft, postmortem-draft, postmortem-action-extractor, error-log-triage, coverage-tracker, monitoring-gap-analysis
- Agent (15): prompt-to-workflow-skeleton, workflow-validate-io, workflow-explain, workflow-cost-estimate, tool-call-accuracy-score, eval-fixture-build, guardrail-policy-draft, workflow-auto-repair, tool-selection-plan, novelty-score-workflow, workflow-variant-generate, config-normalize, recipe-*
- Utility (8): base64-encode, base64-decode, hash-text, regex-extract, template-render, date-parse, json-path-query, url-parse
- HTML (3): html-sanitize, html-to-markdown, markdown-to-html

All tools follow AI SDK v6 pattern with tool() and jsonSchema<T>().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 22:55:56 +10:00

3.9 KiB

@tpmjs/tools-markdown-lint-basic

Basic markdown linting to check for common issues.

Features

  • Checks for trailing whitespace
  • Detects multiple consecutive blank lines
  • Validates heading hierarchy (no skipping levels)
  • Ensures blank lines around headings
  • Checks for consistent list marker style
  • Detects hard tabs (recommends spaces)
  • Validates code block language specification
  • Checks link formatting (no bare URLs, no empty links)

Installation

npm install @tpmjs/tools-markdown-lint-basic

Usage

import { markdownLintBasicTool } from '@tpmjs/tools-markdown-lint-basic';

const result = await markdownLintBasicTool.execute({
  markdown: `
# Title
## Section 1
#### Subsection (skips h3)

Some text with trailing spaces

Bare URL: https://example.com
`,
});

console.log(result.passed); // false (has errors)
console.log(result.summary);
// {
//   errors: 1,
//   warnings: 2,
//   totalLines: 8,
//   rulesChecked: ['no-trailing-spaces', 'no-multiple-blanks', ...]
// }

console.log(result.issues);
// [
//   {
//     rule: 'heading-increment',
//     severity: 'error',
//     line: 4,
//     message: 'Heading level 4 skips level 3',
//     context: '#### Subsection (skips h3)'
//   },
//   ...
// ]

API

markdownLintBasicTool.execute(input)

Input

  • markdown (string, required): The markdown content to lint

Output

Returns a LintResult object:

interface LintResult {
  issues: LintIssue[];
  passed: boolean;           // true if no errors (warnings are OK)
  summary: {
    errors: number;
    warnings: number;
    totalLines: number;
    rulesChecked: string[];
  };
}

interface LintIssue {
  rule: string;              // Rule identifier
  severity: 'error' | 'warning';
  line: number;              // Line number where issue occurs
  column?: number;           // Optional column number
  message: string;           // Human-readable message
  context?: string;          // Code snippet showing the issue
}

Rules

Errors (must fix)

  • heading-increment: Headings must not skip levels (e.g., h1 → h3)
  • no-hard-tabs: Hard tabs are not allowed (use spaces)
  • no-empty-links: Link text cannot be empty

Warnings (should fix)

  • no-trailing-spaces: Lines should not have trailing whitespace
  • no-multiple-blanks: No more than 2 consecutive blank lines
  • blanks-around-headings: Headings should have blank lines before/after
  • list-marker-style: Use consistent list markers (-, *, or +)
  • fenced-code-language: Code blocks should specify a language
  • no-bare-urls: URLs should be formatted as markdown links

Examples

Check for Errors Only

const result = await markdownLintBasicTool.execute({ markdown });

if (!result.passed) {
  const errors = result.issues.filter(i => i.severity === 'error');
  console.error(`Found ${errors.length} errors:`);
  for (const error of errors) {
    console.error(`Line ${error.line}: ${error.message}`);
  }
}

Format Issue Report

const result = await markdownLintBasicTool.execute({ markdown });

for (const issue of result.issues) {
  const icon = issue.severity === 'error' ? '❌' : '⚠️';
  console.log(`${icon} Line ${issue.line}: ${issue.message}`);
  if (issue.context) {
    console.log(`   ${issue.context}`);
  }
}

Group by Rule

const result = await markdownLintBasicTool.execute({ markdown });

const byRule = new Map<string, LintIssue[]>();
for (const issue of result.issues) {
  if (!byRule.has(issue.rule)) {
    byRule.set(issue.rule, []);
  }
  byRule.get(issue.rule)!.push(issue);
}

for (const [rule, issues] of byRule) {
  console.log(`${rule}: ${issues.length} issues`);
}

Use Cases

  • Pre-commit hooks for documentation
  • CI/CD markdown validation
  • Documentation quality checks
  • Style guide enforcement
  • Automated code review

License

MIT