Skip to content

Instantly share code, notes, and snippets.

@perjansson
Last active December 1, 2017 08:41
Show Gist options
  • Save perjansson/bca2ccdb968c48530466a2d949512c79 to your computer and use it in GitHub Desktop.
Save perjansson/bca2ccdb968c48530466a2d949512c79 to your computer and use it in GitHub Desktop.
const transformer = (file, api) => {
const j = api.jscodeshift;
const root = j(file.source);
const multiLineArrays = path => {
const { loc } = path.node;
return loc.start.line < loc.end.line;
}
return root
.find(j.ArrayExpression)
.filter(multiLineArrays)
.forEach(path => path.node.original = null)
.toSource({ trailingComma: 1, wrapColumn: 1});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment