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: April 18, 2024, 2: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



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



Users browsing this thread: 1 Guest(s)