How to use the @babel/traverse.default.visitors function in @babel/traverse

To help you get started, we’ve selected a few @babel/traverse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coderaiser / putout / packages / engine-runner / lib / merge-visitors.js View on Github external
'use strict';

const traverse = require('@babel/traverse').default;

const {merge} = traverse.visitors;

const {generate} = require('@putout/engine-parser');
const runFix = require('./run-fix');
const {getPosition} = require('./get-position');

const shouldSkip = (a) => !a.parent;

module.exports = (pluginsToMerge, {fix, shebang, template}) => {
    const mergeItems = [];
    const pushed = {};
    
    for (const {rule, plugin, msg, options} of pluginsToMerge) {
        const {push, pull} = getStore(plugin, {
            fix,
            rule,
            shebang,
github coderaiser / putout / packages / engine-runner / lib / super-find.js View on Github external
'use strict';

const babelTraverse = require('@babel/traverse').default;
const {types} = require('@babel/types');

const {generate} = require('@putout/engine-parser');
const {merge} = babelTraverse.visitors;

module.exports = function superFind({rule, find, ast, options, template}) {
    const pushItems = [];
    const push = (a) => {
        pushItems.push(a);
    };
    
    const returnItems = find(ast, {
        traverse: traverse({rule, options, template}),
        generate,
        types,
        push,
        options,
    });
    
    return [

@babel/traverse

The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes

MIT
Latest version published 20 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages