Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/fengzilong/babel-is
- Owner: fengzilong
- License: mit
- Created: 2021-06-04T13:15:43.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-06-05T07:34:23.000Z (over 3 years ago)
- Last Synced: 2024-12-24T19:40:03.235Z (11 days ago)
- Topics: ast, babel, match, plugin, test, verify
- Language: JavaScript
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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