escodegen
escodegen copied to clipboard
Bug? options semicolons: false not behaving as expected
Hello, escodegen adds semicolons everywhere when I generate code from esprima AST. I dont use semi colons and I don't want this. Setting option semicolons to false does not help. Is this a bug? If not, how do I prevent this from happening?
The code:
/* test.js */
const file = there => String(require('fs').readFileSync(there))
const esprima = require('esprima')
const escodegen = require('escodegen')
let program = file('test.js') /* open itself (this snippet) */
let ast = esprima.parse(program) /* parse it using esprima */
/* generate code from AST, options from: https://github.com/estools/escodegen/wiki/API */
let code = escodegen.generate(ast, {
format: {
semicolons: false
}
})
console.log(code)
The output below has semicolons added, except the last line. If this is not a bug then how do I disable this behaviour?
const file = there => String(require('fs').readFileSync(there));
const esprima = require('esprima');
const escodegen = require('escodegen');
let program = file('test.js');
let ast = esprima.parse(program);
let code = escodegen.generate(ast, { format: { semicolons: false } });
console.log(code)
Same here, really annoying, have to run eslint --fix
every time after escodegen.generate
Any update on this?
Currently having this same issue. According to the documentation, it seems it only covers turning off the semicolons for block statements, so I don't think it's a bug.
Could their be an addition to turn off semicolons completely?