0.0.1 • Published 4 years ago
eslint-parser-mdast v0.0.1
eslint-parser-mdast
An ESLint custom parser for generating markdown abstract syntax trees (in this case - mdast). Uses
mdast-util-from-markdownunder the hood.
Unlike a usual custom parser which parses JS files, this receives input from markdown (.md) files.
This means that the Program node returned as part of the JS abstract syntax tree (AST) contains mostly dummy values, except for its property markdown which returns Root.
Usage
- Install package as a dev dependency:
yarn add -D eslint-parser-mdast- Include parser in your
.eslintrcconfig:
// .eslintrc
module.exports = {
overrides: {
'*.md': {
parser: 'eslint-parser-mdast',
},
},
}- Retrieve
mdastin your custom ESLint plugin rule:
// src > rules > myCustomRule.js
module.exports = {
meta: { ... },
create: function(context) {
return {
Program(node) {
// retrieve `mdast` with `node.markdown` here
}
}
}
}0.0.1
4 years ago