framework-parsers
Create and maintain framework parser and spec packages for markuplint.
Architecture
The parser hierarchy, extension points, and design rationale are documented in the Parser class JSDoc in packages/@markuplint/parser-utils/src/parser.ts. Read it before extending. For concrete patterns, read an existing sibling package (template engine: ejs-parser; full framework: astro-parser; spec: react-spec) — new packages follow the sibling's structure.
Package types and naming
@markuplint/<lang>-parser— parser package. Two kinds:- Template engine parsers extend
HtmlParserand configure onlyignoreTags. - Full framework parsers extend
Parserand implementtokenize(),nodeize(),visitAttr(),detectElementType(), delegating tokenization to the framework's own parser library.
- Template engine parsers extend
@markuplint/<lang>-spec— spec package exporting anExtendedSpecobject (global attributes + per-element overrides).
Rules (constraints — violations break the build or runtime contracts)
- Template parsers must only configure
ignoreTags— never overridetokenize()ornodeize(). - Full parsers must delegate tokenization to an external parser library — never implement framework parsing from scratch.
- Spec packages must only export an
ExtendedSpecobject — no parsing logic. - Use
potentialNamefor attribute mapping — it tells markuplint which standard HTML attribute a framework attribute corresponds to. - Test with
nodeListToDebugMaps— the standard assertion pattern across all parsers. - Full framework parsers must ship a
component-scannersubpath export ("./component-scanner"inpackage.jsonexports) —@markuplint/pretendersdynamically imports it at runtime for auto scan. Without it, the framework's components are not detected. - Never import from
@markuplint/pretendersinside component-scanner — define local types structurally compatible with itsComponentScannerinterface. Importing pretenders creates a circular dependency in the lerna build graph.