eslint-parser-mdast
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

eslint-parser-mdast

Version License: MIT

An ESLint custom parser for generating markdown abstract syntax trees (in this case - mdast). Uses mdast-util-from-markdown under 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

  1. Install package as a dev dependency:
yarn add -D eslint-parser-mdast
  1. Include parser in your .eslintrc config:
// .eslintrc
module.exports = {
  overrides: {
    '*.md': {
      parser: 'eslint-parser-mdast',
    },
  },
}
  1. Retrieve mdast in your custom ESLint plugin rule:
// src > rules > myCustomRule.js
module.exports = {
  meta: { ... },
  create: function(context) {
    return {
      Program(node) {
        // retrieve `mdast` with `node.markdown` here
      }
    }
  }
}

Package Sidebar

Install

npm i eslint-parser-mdast

Weekly Downloads

3

Version

0.0.1

License

MIT

Unpacked Size

5.07 kB

Total Files

5

Last publish

Collaborators

  • stunnedlemur