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
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');