Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: December 4, 2026, 5:32 am

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reformatting tools for JavaScript
#1
Reformatting tools for JavaScript
So, what do you guys think, what is the best reformatting tool for JavaScript? The two ones I have experience with is clang-format and Prettier.
I think clang-format produces significantly more legible code. I formatted this web-page using Prettier, and this NodeJS script with clang-format.
Here is an example of how the code produced by clang-format is more legible than the code produced by Prettier.
Clang-format:
Code:
var mnemonike = [  "mov",    "fxch",    "fabs",   "fild",  "f2xm1", "fprem", "fld1",  "fscale", "fldl2e",  "fyl2x",  "fldpi", "fstp",  "fld",   "fpatan",  "fsqrt",  "fsincos", "fcos",   "fsin",  "fdivp", "fmulp", "fsubp",  "faddp",  "finit",   "fcomip", "jne",   "jmp",   "fldz",  "jna",  "jnb",    "fistp",   "and",    "or",    "xor",   "jz",    "cmp" ]; var registri = [ "eax", "st0", "st1" ];
Prettier:

Code:
     var mnemonike = [        "mov",        "fxch",        "fabs",        "fild",        "f2xm1",        "fprem",        "fld1",        "fscale",        "fldl2e",        "fyl2x",        "fldpi",        "fstp",        "fld",        "fpatan",        "fsqrt",        "fsincos",        "fcos",        "fsin",        "fdivp",        "fmulp",        "fsubp",        "faddp",        "finit",        "fcomip",        "jne",        "jmp",        "fldz",        "jna",        "jnb",        "fistp",        "and",        "or",        "xor",        "jz",        "cmp"      ];      var registri = ["eax", "st0", "st1"];
The advantage of Prettier over clang-format is that clang-format won't help you format your HTML or CSS.
Reply



Messages In This Thread
Reformatting tools for JavaScript - by FlatAssembler - June 14, 2020 at 10:13 am

Possibly Related Threads…
Thread Author Replies Views Last Post
  A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript FlatAssembler 81 34177 December 19, 2023 at 4:46 pm
Last Post: BrianSoddingBoru4
  PicoBlaze Simulator in JavaScript FlatAssembler 80 41945 June 23, 2023 at 5:20 pm
Last Post: awty
  Nothing annoys me quite like linux and using OSS tools KevinM1 12 4532 January 24, 2015 at 12:59 am
Last Post: KevinM1
  Analysis of a Facebook social engineering/Javascript "hack" Autumnlicious 4 4727 March 2, 2011 at 9:29 am
Last Post: fr0d0



Users browsing this thread: 1 Guest(s)