babel-plugin-transform-safely
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -135,3 +135,8 @@ module.exports = function ({ types: t }) { | ||
path.traverse(safelyVisitors) | ||
path.replaceWith(node.arguments[0]) | ||
if (path.parent.type === 'ArrowFunctionExpression' && path.parent.body && path.parent.body.body && path.parent.body.body[1] && path.parent.body.body[1].argument === node) { | ||
// the node can be moved in an arrow function | ||
path.parent.body.body[1].argument = node.arguments[0] | ||
} else { | ||
path.replaceWith(node.arguments[0]) | ||
} | ||
} | ||
@@ -138,0 +143,0 @@ } |
@@ -27,3 +27,3 @@ { | ||
"scripts": {}, | ||
"version": "0.1.0" | ||
"version": "0.1.1" | ||
} |
@@ -45,3 +45,3 @@ # babel-plugin-transform-safely | ||
And of course you can combine any permutation of the above: | ||
And of course you can combine any permutation of the above (with any other valid expression or operator): | ||
``` | ||
@@ -48,0 +48,0 @@ safely(empty.b.c = object[a]() || object[b](something.c.d)) |
@@ -32,6 +32,11 @@ var obj = {foo: 'bar'} | ||
safely(empty.b = obj.foo.bar(func.c)) | ||
}, | ||
arrow: function() { | ||
return { | ||
get: (row) => safely(row.SelectedOutcome.FieldType) | ||
} | ||
} | ||
} | ||
var test | ||
for (let testName in tests) { | ||
for (var testName in tests) { | ||
var result = require("babel-core").transform('test=' + tests[testName].toString(), { | ||
@@ -38,0 +43,0 @@ plugins: ["transform-safely"] |
9420
181