Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as acornBase from 'acorn'
import inject from 'acorn-jsx/inject'
import estraverse from '../../../lib/estraverse'
import escodegen from 'escodegen'
let acorn = inject(acornBase)
let parser = {
estraverse,
parse(text) {
return acorn.parse(text, {
plugins: {
jsx: true
},
ecmaVersion: 6,
sourceType: 'module',
locations: true
});
},
print(ast) {
// TODO not working, escodegen can't generate JSX tags
return escodegen.generate(ast);
export * from "./src/index";
import "./plugins/flow";
import inject from "acorn-jsx/inject";
import * as acorn from "./src/index";
inject(acorn);
import recast from 'recast';
import inject from 'acorn-jsx/inject'
import * as acornBase from 'acorn'
import estraverse from '../../../lib/estraverse'
let acorn = inject(acornBase)
let parser = {
estraverse,
parse(text) {
let result = recast.parse(text, {
parser: acorn
});
if (result) {
return result.program;
}
return result;
},
print(ast) {
return recast.print(ast).code;
}
}
load() {
return Promise.resolve({
loose: parse_dammit,
parse: jsxInject(acorn).parse,
});
},
};
import recast from 'recast';
import * as acornBase from 'acorn'
import inject from 'acorn-jsx/inject'
import jsxKeys from 'estraverse-fb/keys';
import estraverseOrig from '../../../lib/estraverse'
let acorn = inject(acornBase)
let acornParser = {
parse(text, options) {
let baseOptions = {
plugins: {
jsx: true
}
};
let mergedOptions = Object.assign({}, options, baseOptions);
return acorn.parse(text, mergedOptions);
}
}
let parser = {
estraverse: {
...estraverseOrig,
load() {
return Promise.resolve({
loose: parse_dammit,
parse: jsxInject(acorn).parse,
});
},
};
load() {
return Promise.resolve({
loose: parse_dammit,
parse: jsxInject(acorn).parse,
});
},
};