Skip to content

Instantly share code, notes, and snippets.

@tgroshon
Last active December 7, 2020 17:35
Show Gist options
  • Save tgroshon/d1b8016a617f33313504a218603c6892 to your computer and use it in GitHub Desktop.
Save tgroshon/d1b8016a617f33313504a218603c6892 to your computer and use it in GitHub Desktop.

Formatting: Prettier vs. Standard

A formatting comparison.

How will the two tools format the following input code:

export const f = function(a) { if (a === 0) { return []; } return [1,2,3,4,a].map(int => int * 2); }

Standard via standard --fix:

export const f = function (a) { if (a === 0) { return [] } return [1, 2, 3, 4, a].map(int => int * 2) }

Prettier via prettier:

export const f = function (a) {
  if (a === 0) {
    return [];
  }
  return [1, 2, 3, 4, a].map((int) => int * 2);
};

Try Yourself

https://github.com/tgroshon/prettier-vs-standard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment