Skip Menu |

This queue is for tickets about the JavaScript-Beautifier CPAN distribution.

Report information
The Basics
Id: 129976
Status: new
Priority: 0/
Queue: JavaScript-Beautifier

People
Owner: Nobody in particular
Requestors: x.guimard [...] free.fr
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.25
Fixed in: (no value)



Subject: "=>" operator replaced by "= >" thus creating syntax errors
Hello, This simple code becomes unusable when parsed by JavaScript::Beautifier: # SOURCE (test.js) fetch('https://example.com/').then(resp = >resp.blob()).then(blob = >{ alert('your file has downloaded!'); }). catch(() => alert('oh no!')); # RESULT $ js_beautify - <test.js fetch('https://example.com/').then(resp = >resp.blob()).then(blob = >{ alert('your file has downloaded!'); }). catch(() = >alert('oh no!'));
Le Mer 03 Jui 2019 12:25:52, GUIMARD a écrit : Show quoted text
> Hello, > > This simple code becomes unusable when parsed by JavaScript::Beautifier: > > # SOURCE (test.js) > fetch('https://example.com/').then(resp = >resp.blob()).then(blob = >{ > alert('your file has downloaded!'); > }). > catch(() => alert('oh no!')); > > # RESULT > $ js_beautify - <test.js > fetch('https://example.com/').then(resp = >resp.blob()).then(blob = >{ > alert('your file has downloaded!'); > }). > catch(() = >alert('oh no!'));
Quick and dirty fix attached
Subject: javascript-beautifier.diff
diff --git a/lib/JavaScript/Beautifier.pm b/lib/JavaScript/Beautifier.pm index 06d5981..66ecf5e 100644 --- a/lib/JavaScript/Beautifier.pm +++ b/lib/JavaScript/Beautifier.pm @@ -18,7 +18,7 @@ my @whitespace = split('', "\n\r\t "); my @wordchar = split('', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'); my @digits = split('', '0123456789'); # <!-- is a special case (ok, it's a minor hack actually) -my @punct = split(' ', '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::'); +my @punct = split(' ', '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= => >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::'); # words which should always start on new line. my @line_starter = split(',', 'continue,try,throw,return,var,if,switch,case,default,for,while,break,function');