Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lint-md/ast-plugin
The simplest abstract syntax tree walker, similar with @Babel plugin.
https://github.com/lint-md/ast-plugin
ast babel babel-plugin plugin
Last synced: about 2 months ago
JSON representation
The simplest abstract syntax tree walker, similar with @Babel plugin.
- Host: GitHub
- URL: https://github.com/lint-md/ast-plugin
- Owner: lint-md
- Created: 2020-01-19T01:58:28.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-23T13:35:00.000Z (almost 4 years ago)
- Last Synced: 2024-11-09T07:46:24.256Z (about 2 months ago)
- Topics: ast, babel, babel-plugin, plugin
- Language: TypeScript
- Homepage: https://github.com/lint-md/ast-plugin
- Size: 11.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @lint-md/ast-plugin
> The simplest abstract syntax tree walker.
[![Build Status](https://github.com/lint-md/ast-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/lint-md/ast-plugin/actions/workflows/build.yml)
## Install
> npm i --save ast-plugin
## Usage
- Traverse Ast plugins
```js
import { Ast, Plugin } from 'ast-plugin';new Ast(ast).traverse([
new TestPlugin(cfg),
// ...
]);
```- Write an ast plugin
```js
import { Ast, Plugin } from 'ast-plugin';class TestPlugin extends Plugin {
pre = () => {
};visitor = () => {
return {
// process node with type = 'text'
text: ast => {
console.log(ast.node);
ast.segment();
},
};
};post = () => {
};
}
```## Used by
- [lint-md](https://github.com/lint-md/lint-md) Cli tool to lint your markdown file for Chinese.
## License
MIT@[hustcc](https://github.com/hustcc).