Skip to content

regexyl/eslint-parser-mdast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
      }
    }
  }
}

About

An ESLint custom parser for generating markdown ASTs (using mdast).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published