How to use escodegen-wallaby - 10 common examples

To help you get started, we’ve selected a few escodegen-wallaby 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 drd / jsxlate / plugin.js View on Github external
function validateJSXElement(element, context) {
    if (isElementMarker(element)) {
        // TODO: unified error handling showing source of exception
        // and context, including line/character positions.
        throw new Error("Found a nested element marker in " + escodegen.generate(context.root));
    }
    if (isTag(element) && hasUnsafeAttributes(element)) {
        assertI18nId(element);
    } else if (isComponent(element)) {
        let name = elementName(element);
        let count = context.componentsWithoutIds[name];
        if (count === undefined) {
            context.componentsWithoutIds[name] = 0;
        }
        context.componentsWithoutIds[name]++;
    }

    validateChildren(element.children, context);
}
github drd / jsxlate / plugin.js View on Github external
function isExtractableAttribute(element, attribute) {
    let value = attributeValue(attribute);
    let attributeIsWhitelisted = isWhitelistedAttribute(element, attribute);
    if (attributeIsWhitelisted && !value) {
        console.warn("Ignoring non-literal extractable attribute:", escodegen.generate(attribute));
    }
    return value && attributeIsWhitelisted;
}
github drd / jsxlate / jsxlate.js View on Github external
function generate(ast) {
    return escodegen.generate(ast.toJS()).trim();
}
github VulcanJS / vulcanjs-cli / dist / generator-vulcanjs / lib / ast.js View on Github external
var generateCode = function generateCode(ast) {
  var astWithComments = escodegen.attachComments(ast, ast.comments, ast.tokens);
  return escodegen.generate(astWithComments, {
    comment: true,
    format: { index: { style: '  ' } }
  });
};
github drd / jsxlate / lib / jsxlate.js View on Github external
function generate(ast) {
    return escodegen.generate(ast.toJS()).trim();
}
github javascript-obfuscator / javascript-obfuscator / src / JavaScriptObfuscatorInternal.ts View on Github external
private generateCode (sourceCode: string, astTree: ESTree.Program): IGeneratorOutput {
        const escodegenParams: escodegen.GenerateOptions = {
            ...JavaScriptObfuscatorInternal.escodegenParams
        };

        if (this.options.sourceMap) {
            escodegenParams.sourceMap = 'sourceMap';
            escodegenParams.sourceContent = sourceCode;
        }

        if (this.options.mangle) {
            astTree = esmangle.mangle(astTree);
        }

        const generatorOutput: IGeneratorOutput = escodegen.generate(astTree, {
            ...escodegenParams,
            format: {
                compact: this.options.compact
            }
        });

        generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : '';

        return generatorOutput;
    }
github hex13 / lupa / old / plugins / ES6ModuleInfo.js View on Github external
.map(function (method) {
                        return {
                            name: method.key.name,
                            body: escodegen.generate(method.value.body)
                        };
                    });
            }
github VulcanJS / vulcanjs-cli / src / generator-vulcanjs / lib / ast.js View on Github external
const generateCode = (ast) => {
  const astWithComments = escodegen.attachComments(
    ast,
    ast.comments,
    ast.tokens
  );
  return escodegen.generate(
    astWithComments,
    {
      comment: true,
      format: { index: { style: '  ' } },
    }
  );
};
github javascript-obfuscator / javascript-obfuscator / src / JavaScriptObfuscator.ts View on Github external
private generateCode (sourceCode: string, astTree: ESTree.Program): IGeneratorOutput {
        const escodegenParams: escodegen.GenerateOptions = {
            ...JavaScriptObfuscator.escodegenParams
        };

        if (this.options.sourceMap) {
            escodegenParams.sourceMap = this.options.inputFileName || 'sourceMap';
            escodegenParams.sourceContent = sourceCode;
        }

        const generatorOutput: IGeneratorOutput = escodegen.generate(astTree, {
            ...escodegenParams,
            format: {
                compact: this.options.compact
            }
        });

        generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : '';

        return generatorOutput;
    }
github SBoudrias / AST-query / lib / tree.js View on Github external
function Tree(source, escodegenOptions, acornOptions) {
  this.acornOptionDefaults = _.extend({}, acornOptionDefaults, acornOptions);
  this.comments = [];
  this.tokens = [];
  this.acornOptionDefaults.onComment = this.comments;
  this.acornOptionDefaults.onToken = this.tokens;
  this.tree = acorn.parse(source.toString(), this.acornOptionDefaults);
  this.tree = escodegen.attachComments(this.tree, this.comments, this.tokens);
  this.body = new Body(this.tree.body, this.acornOptionDefaults);
  this.escodegenOptions = _.extend({}, escodegenOptionDefaults, escodegenOptions);
}

escodegen-wallaby

ECMAScript code generator with JSX support

BSD-2-Clause
Latest version published 3 months ago

Package Health Score

71 / 100
Full package analysis

Similar packages