Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fengzilong/babel-is

verify an AST path with css-selector-like syntax in your babel plugin
https://github.com/fengzilong/babel-is

ast babel match plugin test verify

Last synced: 5 days ago
JSON representation

verify an AST path with css-selector-like syntax in your babel plugin

Awesome Lists containing this project

README

        

# babel-is

### Installation

For npm users

```bash
npm i babel-is
```

For yarn users

```bash
yarn add babel-is
```

### Usage

In your babel plugin

```js
const is = require( 'babel-is' )

module.exports = function () {
return {
visitor: {
// matches all `let` variable declarations in `foo` function
VariableDeclaration( path ) {
const selector = `FunctionDeclaration[id.name=foo] [kind=let]`

if ( is( path, selector ) ) {
// add your logic
// ...
}
}
}
}
}
```

### License

MIT