Core plugin setup and configuration management with pre-built configurations for common use cases including recommended rules and processor setup.
The main plugin export containing all plugin functionality and metadata.
/**
* Main ESLint plugin object for @eslint/markdown
*/
interface Plugin {
meta: {
name: "@eslint/markdown";
version: "7.2.0";
};
processors: {
markdown: Processor;
};
languages: {
commonmark: MarkdownLanguage;
gfm: MarkdownLanguage;
};
rules: { [ruleName: string]: Rule };
configs: {
recommended: Config[];
processor: Config[];
"recommended-legacy": LegacyConfig;
};
}Usage Example:
import markdown from "@eslint/markdown";
// Access plugin metadata
console.log(markdown.meta.name); // "@eslint/markdown"
console.log(markdown.meta.version); // "7.2.0"
// Use in ESLint configuration
export default [
{
plugins: { markdown },
// ... other config
}
];Pre-configured setup that enables Markdown linting with recommended rules using CommonMark format.
/**
* Recommended configuration for Markdown linting
* Enables CommonMark language and recommended rules
*/
interface RecommendedConfig {
name: "markdown/recommended";
files: ["**/*.md"];
language: "markdown/commonmark";
plugins: { markdown: Plugin };
rules: RecommendedRules;
}
const recommended: RecommendedConfig[];Usage Example:
import markdown from "@eslint/markdown";
export default [
markdown.configs.recommended,
// your other configs here
];Configuration that enables code block extraction and linting from Markdown files.
/**
* Processor configuration for code block extraction
* Enables the markdown processor for .md files and configures code block linting
*/
interface ProcessorConfig extends Array<{
name: string;
files?: string[];
processor?: string;
plugins?: { markdown: Plugin };
languageOptions?: {
parserOptions: {
ecmaFeatures: {
impliedStrict: boolean;
};
};
};
rules?: RulesConfig;
}> {}
const processor: ProcessorConfig;Usage Example:
import markdown from "@eslint/markdown";
export default [
...markdown.configs.processor,
// your other configs here
];Legacy ESLint configuration format for older ESLint versions (deprecated).
/**
* Legacy configuration format (deprecated)
* Use flat config formats instead
*/
interface LegacyConfig {
plugins: ["markdown"];
overrides: Array<{
files: string[];
processor?: string;
parserOptions?: {
ecmaFeatures: {
impliedStrict: boolean;
};
};
rules?: RulesConfig;
}>;
}
const "recommended-legacy": LegacyConfig;Note: This configuration format is deprecated. Use the flat config formats (recommended or processor) instead.
Manual configuration for advanced use cases with full control over settings.
Usage Examples:
// Basic custom configuration
import markdown from "@eslint/markdown";
export default [
{
files: ["**/*.md"],
plugins: { markdown },
language: "markdown/commonmark",
rules: {
"markdown/no-html": "error",
"markdown/require-alt-text": "error"
}
}
];// Advanced configuration with GitHub Flavored Markdown and frontmatter
import markdown from "@eslint/markdown";
export default [
{
files: ["**/*.md"],
plugins: { markdown },
language: "markdown/gfm",
languageOptions: {
frontmatter: "yaml"
},
rules: {
"markdown/no-html": "off",
"markdown/table-column-count": "error",
"markdown/no-duplicate-headings": "warn"
}
}
];// Mixed configuration with both Markdown linting and code block processing
import markdown from "@eslint/markdown";
export default [
// Enable Markdown linting
{
files: ["**/*.md"],
plugins: { markdown },
language: "markdown/gfm",
rules: {
"markdown/no-html": "error"
}
},
// Enable code block processing
{
files: ["**/*.md"],
processor: "markdown/markdown"
},
// Configure JavaScript code blocks
{
files: ["**/*.md/*.js"],
rules: {
"no-console": "off",
"no-undef": "off"
}
}
];// Advanced configuration with per-directory customization
import markdown from "@eslint/markdown";
export default [
// Base configuration for all Markdown files
{
files: ["**/*.md"],
plugins: { markdown },
language: "markdown/commonmark",
rules: {
"markdown/heading-increment": "error",
"markdown/no-empty-links": "error",
"markdown/require-alt-text": "error"
}
},
// Documentation files can use HTML
{
files: ["docs/**/*.md"],
language: "markdown/gfm",
languageOptions: {
frontmatter: "yaml"
},
rules: {
"markdown/no-html": ["error", {
allowed: ["br", "kbd", "details", "summary"],
allowedIgnoreCase: true
}],
"markdown/table-column-count": "error"
}
},
// Blog posts have different requirements
{
files: ["blog/**/*.md"],
language: "markdown/gfm",
languageOptions: {
frontmatter: "yaml"
},
rules: {
"markdown/no-html": "off",
"markdown/no-duplicate-headings": "error"
}
},
// Code block processing for all markdown files
{
files: ["**/*.md"],
processor: "markdown/markdown"
},
// TypeScript code blocks in documentation
{
files: ["docs/**/*.md/*.ts", "docs/**/*.md/*.tsx"],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"no-undef": "off"
}
},
// Example code blocks can have more relaxed rules
{
files: ["examples/**/*.md/*.js"],
rules: {
"no-console": "off",
"no-undef": "off",
"no-unused-vars": "off"
}
}
];interface Config {
name?: string;
files?: string[];
language?: string;
languageOptions?: MarkdownLanguageOptions;
plugins?: { [pluginName: string]: Plugin };
processor?: string;
rules?: RulesConfig;
}
interface RulesConfig {
[ruleName: string]: "off" | "warn" | "error" | [string, ...any[]];
}
interface RecommendedRules {
"markdown/fenced-code-language": "error";
"markdown/heading-increment": "error";
"markdown/no-duplicate-definitions": "error";
"markdown/no-empty-definitions": "error";
"markdown/no-empty-images": "error";
"markdown/no-empty-links": "error";
"markdown/no-invalid-label-refs": "error";
"markdown/no-missing-atx-heading-space": "error";
"markdown/no-missing-label-refs": "error";
"markdown/no-missing-link-fragments": "error";
"markdown/no-multiple-h1": "error";
"markdown/no-reversed-media-syntax": "error";
"markdown/no-space-in-emphasis": "error";
"markdown/no-unused-definitions": "error";
"markdown/require-alt-text": "error";
"markdown/table-column-count": "error";
}