Skip to content

Instantly share code, notes, and snippets.

@tgroshon
Last active December 7, 2020 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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