Skip to content

Instantly share code, notes, and snippets.

@DavidMellul
Last active May 30, 2018 21:50
Show Gist options
  • Save DavidMellul/2dfc1760e9b09e284f50d9a003196c00 to your computer and use it in GitHub Desktop.
Save DavidMellul/2dfc1760e9b09e284f50d9a003196c00 to your computer and use it in GitHub Desktop.
// We will implement a Prettier option :
// Remove parenthesis on ES6 functions using only a single parameter
// (arg) => { } becomes arg => { }
const es6Function = '(arg) => { }';
const regex = /\((.+)\)/;
const cleanedSingleParameter = es6Function.replace(regex,'$1');
console.log(cleanedSingleParameter);
// Prints : arg => { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment