-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: generator
Description
Issue originally made by Jan Potoms (jan)
Bug information
- Babel version: 6.5.0
- Node version: 5.6.0
- npm version: 3.6.0
Input code
var babylon = require('babylon');
var generate = require('babel-generator')['default'];
function check (code, options) {
var ast = babylon.parse(code, options);
console.log(generate(ast, options, code).code);
}
check('"foo"; "bar"; \'baz\'', {});
// output : "foo";"bar";'baz';
// expected: "foo";"bar";"baz";
check("'foo'; 'bar'; \"baz\"", {});
// output : 'foo';'bar';"baz";
// expected: 'foo';'bar';'baz';
check('"foo"; "bar"; \'baz\'', { quotes: 'single' });
// output : "foo";"bar";'baz';
// expected: 'foo';'bar';'baz';
check("'foo'; 'bar'; \"baz\"", { quotes: 'double' });
// output : 'foo';'bar';"baz";
// expected: "foo";"bar";"baz";Description
according to documentation, you can provide a quotes option to the generate method in babel-generate. if not specified, it should autodetect based on the tokens in ast.
first of all, currently it doesn't detect based on the tokens in ast but on the code parameter in the generate function. This means this parameter can't be left empty.
second (and the actual issue), the detection doesn't work, quotes are preserved from input to output. the generate method doesn't apply the detected preference and neither when explicitly specified in the options.
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: generator