remark-lint rule to warn when the markers of ordered lists violate a given style
npx @tessl/cli install tessl/npm-remark-lint-ordered-list-marker-style@3.1.0remark-lint rule to warn when the markers of ordered lists violate a given style. This package helps maintain consistency in Markdown documents by ensuring ordered lists use either dots (.) or parentheses ()) consistently throughout the document.
npm install remark-lint-ordered-list-marker-styleimport remarkLintOrderedListMarkerStyle from 'remark-lint-ordered-list-marker-style';Note: This package is ESM only and does not support CommonJS. Use dynamic imports in CommonJS environments:
// Not supported - package is ESM only
// const remarkLintOrderedListMarkerStyle = require('remark-lint-ordered-list-marker-style');
// Use dynamic import instead:
const remarkLintOrderedListMarkerStyle = (await import('remark-lint-ordered-list-marker-style')).default;import {remark} from 'remark';
import remarkLint from 'remark-lint';
import remarkLintOrderedListMarkerStyle from 'remark-lint-ordered-list-marker-style';
const processor = remark()
.use(remarkLint)
.use(remarkLintOrderedListMarkerStyle); // Uses 'consistent' by default
const result = await processor.process(`1. First item
2) Second item (inconsistent - will warn)`);
console.error(String(result));Validates that ordered list markers are consistent throughout a Markdown document.
/**
* remark-lint rule plugin for ordered list marker consistency
* This is the default export - a unified plugin created with lintRule()
*/
declare const remarkLintOrderedListMarkerStyle: Plugin;
/**
* Plugin type that accepts standard unified lint rule configuration
* Supports: false (disable), true/'on' (enable), [severity, options], or direct options
*/
type Plugin = import('unified').Plugin<
| []
| [false]
| [true | 'on' | 'warn' | 'error' | 0 | 1 | 2]
| [boolean | 'on' | 'off' | 'warn' | 'error' | 0 | 1 | 2, Options?]
| [Options]
, Root>;
type Options = 'consistent' | Marker;
type Marker = '.' | ')';Configuration Options:
'consistent' (default): Detects the first ordered list marker style used in the document and enforces consistency with that style throughout'.': Enforces dot markers only (e.g., 1., 2., 3.)')': Enforces parenthesis markers only (e.g., 1), 2), 3))Usage Examples:
// Default behavior - consistent style detection
.use(remarkLintOrderedListMarkerStyle)
.use(remarkLintOrderedListMarkerStyle, 'consistent')
// Enforce dots only
.use(remarkLintOrderedListMarkerStyle, '.')
// Enforce parentheses only
.use(remarkLintOrderedListMarkerStyle, ')')
// Standard unified plugin configuration
.use(remarkLintOrderedListMarkerStyle, false) // Disable rule
.use(remarkLintOrderedListMarkerStyle, true) // Enable with default options
.use(remarkLintOrderedListMarkerStyle, [1, '.']) // Severity 1 (warn) with dots
.use(remarkLintOrderedListMarkerStyle, [2, ')']) // Severity 2 (error) with parens
.use(remarkLintOrderedListMarkerStyle, ['error', 'consistent']) // Error severityError Messages:
When inconsistencies are found, the rule reports:
"Marker style should be \.`"` - When dots are expected but parentheses found"Marker style should be \)`"` - When parentheses are expected but dots found"Incorrect ordered list item marker style \<invalid>`: use either `'.'` or `')'`"` - When invalid option provided/**
* MDast Root node type (from @types/mdast)
*/
type Root = import('mdast').Root;
/**
* Valid ordered list marker characters
*/
type Marker = '.' | ')';
/**
* Configuration options for the rule
*/
type Options = 'consistent' | Marker;
/**
* Unified plugin type supporting standard lint rule configuration
* Based on unified-lint-rule conventions
*/
type Plugin = import('unified').Plugin<
| []
| [false]
| [true | 'on' | 'warn' | 'error' | 0 | 1 | 2]
| [boolean | 'on' | 'off' | 'warn' | 'error' | 0 | 1 | 2, Options?]
| [Options]
, Root>;
/**
* Rule metadata interface (from unified-lint-rule)
*/
interface RuleMeta {
origin: string;
url?: string | null;
}
/**
* VFile interface for error reporting
*/
type VFile = import('vfile').VFile;This package integrates seamlessly with the unified ecosystem:
unified() processing pipelineremark-lint as the base linting frameworkPackage.json configuration:
{
"remarkConfig": {
"plugins": [
"remark-lint",
["remark-lint-ordered-list-marker-style", "."]
]
}
}CLI usage:
remark --use remark-lint --use remark-lint-ordered-list-marker-style example.mdThis rule is included in several remark-lint presets:
remark-preset-lint-consistent: Uses 'consistent' settingremark-preset-lint-markdown-style-guide: Uses '.' settingremark-preset-lint-recommended: Uses '.' settingThe rule handles various edge cases:
Example error output:
3:1-3:8: Marker style should be `.`This indicates line 3, column 1 through column 8 has a marker inconsistency.
The rule is built using unified-lint-rule and operates on the MDast (Markdown Abstract Syntax Tree):
unist-util-visit to traverse all list nodes in the syntax treenode.ordered === trueKey implementation details from the source:
unist-util-generated to skip programmatically generated nodes[x], [ ]) before marker extraction using regexunist-util-position for accurate error location reportingremark-lint:ordered-list-marker-stylehttps://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-ordered-list-marker-style#readmeThese details are automatically added to error messages by the unified-lint-rule framework.
Core dependencies required for functionality:
@types/mdast: TypeScript definitions for Markdown ASTunified: Core unified processor frameworkunified-lint-rule: Helper for creating lint rulesunist-util-generated: Utility to check if AST nodes are generatedunist-util-position: Utility for AST node position informationunist-util-visit: Utility for traversing AST trees