Skip to content

Instantly share code, notes, and snippets.

Pablo Navarro pnavarrc

Block or report user

Report or block pnavarrc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View writing-a-babel-plugin-09.js
const createMergeExpression = (a, b) =>
t.objectExpression([
t.spreadElement(a),
t.spreadElement(b)
]);
View writing-a-babel-plugin-08.js
{
type: "ObjectExpression",
properties: [
{
type: "SpreadProperty",
argument: {
type: "Identifier",
name: "a"
}
},
View writing-a-babel-plugin-07.js
const isUselessRamdaMerge = node =>
t.isCallExpression(node) &&
isRamdaMerge(node.callee) &&
node.arguments.length === 2;
View writing-a-babel-plugion-06.js
const isRamdaMerge = node =>
t.isMemberExpression(node) &&
t.isIdentifier(node.object, { name: "R" }) &&
t.isIdentifier(node.property, { name: "merge" });
View writing-a-babel-plugin-05.js
{
type: "CallExpression",
callee: {
type: "MemberExpression",
object: {
type: "Identifier",
name: "R"
},
property: {
type: "Identifier",
View writing-a-babel-plugin-04.js
export default plugin(babel) {
return {
name: "plugin-name",
ArrowFunctionExpression(path) {
const { node } = path;
// transform the node here
}
}
}
View writing-a-babel-plugin-03.js
// Out
{
type: "FunctionExpression",
params: [
{
type: "Identifier",
name: "n"
}
],
body: {
View writing-a-babel-plugin-02.js
{
type: "VariableDeclaration",
declarators: [
{
type: "VariableDeclarator",
id: {
type: "Identifier",
name: "square"
},
init: {
@pnavarrc
pnavarrc / writing-a-babel-plugin-01.js
Last active Jul 11, 2019
writing-a-babel-plugin-1
View writing-a-babel-plugin-01.js
// In
[1, 2, 3].map(n => n * n);
// Out
[1, 2, 3].map(function(n) { return n * n; });
View writing-a-babel-plugin-02.js
{
type: "VariableDeclaration",
declarators: [
{
type: "VariableDeclarator",
id: {
type: "Identifier",
name: "square"
},
init: {
You can’t perform that action at this time.