Writing custom Babel and ESLint plugins

Kent C. Dodds

Utah

1 wife, 3.5 kids

PayPal, Inc.

@kentcdodds

Please Stand...

... if you're physically able

What this talk is

  • Basic introduction to the concept of ASTs
  • (sorta) Practical demo of how to use ASTs with Babel and ESLint
  • Something to get you totally psyched about using ASTs

What this talk is not

  • A deep dive into parsing, tokenizing, and lexing
  • Everything you need to know to be productive with ASTs

Let's
Get
STARTED!

Why

Should I care?

ESNext

ESNow

ESLint

eslint-plugin-import

Codemods

better than find/replace

no matter how good your regex skills are...

What

Is an AST?

Code for humans

const uniqueRandomArray = require('unique-random-array')

const transformersNames = require('./transformers-names.json')
const getRandomItem = uniqueRandomArray(transformersNames)

module.exports = {
  all: transformersNames,
  random: random,
}

function random(number) {
  if (number === undefined) {
    return getRandomItem()
  } else {
    const randomItems = []
    for (let i = 0; i < number; i++) {
      randomItems.push(getRandomItem())
    }
    return randomItems
  }
}

Code for computers

{
  "type": "File",
  "start": 0,
  "end": 482,
  "loc": {
    "start": {
      "line": 1,
      "column": 0
    },
    "end": {
      "line": 22,
      "column": 0
    }
  },
  "program": {
    "type": "Program",
    "start": 0,
    "end": 482,
    "loc": {
      "start": {
        "line": 1,
        "column": 0
      },
      "end": {
        "line": 22,
        "column": 0
      }
    },
    "sourceType": "module",
    "body": [
      {
        "type": "VariableDeclaration",
        "start": 0,
        "end": 56,
        "loc": {
          "start": {
            "line": 1,
            "column": 0
          },
          "end": {
            "line": 1,
            "column": 56
          }
        },
        "declarations": [
          {
            "type": "VariableDeclarator",
            "start": 6,
            "end": 56,
            "loc": {
              "start": {
                "line": 1,
                "column": 6
              },
              "end": {
                "line": 1,
                "column": 56
              }
            },
            "id": {
              "type": "Identifier",
              "start": 6,
              "end": 23,
              "loc": {
                "start": {
                  "line": 1,
                  "column": 6
                },
                "end": {
                  "line": 1,
                  "column": 23
                }
              },
              "name": "uniqueRandomArray"
            },
            "init": {
              "type": "CallExpression",
              "start": 26,
              "end": 56,
              "loc": {
                "start": {
                  "line": 1,
                  "column": 26
                },
                "end": {
                  "line": 1,
                  "column": 56
                }
              },
              "callee": {
                "type": "Identifier",
                "start": 26,
                "end": 33,
                "loc": {
                  "start": {
                    "line": 1,
                    "column": 26
                  },
                  "end": {
                    "line": 1,
                    "column": 33
                  }
                },
                "name": "require"
              },
              "arguments": [
                {
                  "type": "StringLiteral",
                  "start": 34,
                  "end": 55,
                  "loc": {
                    "start": {
                      "line": 1,
                      "column": 34
                    },
                    "end": {
                      "line": 1,
                      "column": 55
                    }
                  },
                  "extra": {
                    "rawValue": "unique-random-array",
                    "raw": "'unique-random-array'"
                  },
                  "value": "unique-random-array"
                }
              ]
            }
          }
        ],
        "kind": "const"
      },
      {
        "type": "VariableDeclaration",
        "start": 58,
        "end": 120,
        "loc": {
          "start": {
            "line": 3,
            "column": 0
          },
          "end": {
            "line": 3,
            "column": 62
          }
        },
        "declarations": [
          {
            "type": "VariableDeclarator",
            "start": 64,
            "end": 120,
            "loc": {
              "start": {
                "line": 3,
                "column": 6
              },
              "end": {
                "line": 3,
                "column": 62
              }
            },
            "id": {
              "type": "Identifier",
              "start": 64,
              "end": 81,
              "loc": {
                "start": {
                  "line": 3,
                  "column": 6
                },
                "end": {
                  "line": 3,
                  "column": 23
                }
              },
              "name": "transformersNames"
            },
            "init": {
              "type": "CallExpression",
              "start": 84,
              "end": 120,
              "loc": {
                "start": {
                  "line": 3,
                  "column": 26
                },
                "end": {
                  "line": 3,
                  "column": 62
                }
              },
              "callee": {
                "type": "Identifier",
                "start": 84,
                "end": 91,
                "loc": {
                  "start": {
                    "line": 3,
                    "column": 26
                  },
                  "end": {
                    "line": 3,
                    "column": 33
                  }
                },
                "name": "require"
              },
              "arguments": [
                {
                  "type": "StringLiteral",
                  "start": 92,
                  "end": 119,
                  "loc": {
                    "start": {
                      "line": 3,
                      "column": 34
                    },
                    "end": {
                      "line": 3,
                      "column": 61
                    }
                  },
                  "extra": {
                    "rawValue": "./transformers-names.json",
                    "raw": "'./transformers-names.json'"
                  },
                  "value": "./transformers-names.json"
                }
              ]
            }
          }
        ],
        "kind": "const"
      },
      {
        "type": "VariableDeclaration",
        "start": 121,
        "end": 179,
        "loc": {
          "start": {
            "line": 4,
            "column": 0
          },
          "end": {
            "line": 4,
            "column": 58
          }
        },
        "declarations": [
          {
            "type": "VariableDeclarator",
            "start": 127,
            "end": 179,
            "loc": {
              "start": {
                "line": 4,
                "column": 6
              },
              "end": {
                "line": 4,
                "column": 58
              }
            },
            "id": {
              "type": "Identifier",
              "start": 127,
              "end": 140,
              "loc": {
                "start": {
                  "line": 4,
                  "column": 6
                },
                "end": {
                  "line": 4,
                  "column": 19
                }
              },
              "name": "getRandomItem"
            },
            "init": {
              "type": "CallExpression",
              "start": 143,
              "end": 179,
              "loc": {
                "start": {
                  "line": 4,
                  "column": 22
                },
                "end": {
                  "line": 4,
                  "column": 58
                }
              },
              "callee": {
                "type": "Identifier",
                "start": 143,
                "end": 160,
                "loc": {
                  "start": {
                    "line": 4,
                    "column": 22
                  },
                  "end": {
                    "line": 4,
                    "column": 39
                  }
                },
                "name": "uniqueRandomArray"
              },
              "arguments": [
                {
                  "type": "Identifier",
                  "start": 161,
                  "end": 178,
                  "loc": {
                    "start": {
                      "line": 4,
                      "column": 40
                    },
                    "end": {
                      "line": 4,
                      "column": 57
                    }
                  },
                  "name": "transformersNames"
                }
              ]
            }
          }
        ],
        "kind": "const"
      },
      {
        "type": "ExpressionStatement",
        "start": 181,
        "end": 245,
        "loc": {
          "start": {
            "line": 6,
            "column": 0
          },
          "end": {
            "line": 9,
            "column": 1
          }
        },
        "expression": {
          "type": "AssignmentExpression",
          "start": 181,
          "end": 245,
          "loc": {
            "start": {
              "line": 6,
              "column": 0
            },
            "end": {
              "line": 9,
              "column": 1
            }
          },
          "operator": "=",
          "left": {
            "type": "MemberExpression",
            "start": 181,
            "end": 195,
            "loc": {
              "start": {
                "line": 6,
                "column": 0
              },
              "end": {
                "line": 6,
                "column": 14
              }
            },
            "object": {
              "type": "Identifier",
              "start": 181,
              "end": 187,
              "loc": {
                "start": {
                  "line": 6,
                  "column": 0
                },
                "end": {
                  "line": 6,
                  "column": 6
                }
              },
              "name": "module"
            },
            "property": {
              "type": "Identifier",
              "start": 188,
              "end": 195,
              "loc": {
                "start": {
                  "line": 6,
                  "column": 7
                },
                "end": {
                  "line": 6,
                  "column": 14
                }
              },
              "name": "exports"
            },
            "computed": false
          },
          "right": {
            "type": "ObjectExpression",
            "start": 198,
            "end": 245,
            "loc": {
              "start": {
                "line": 6,
                "column": 17
              },
              "end": {
                "line": 9,
                "column": 1
              }
            },
            "properties": [
              {
                "type": "ObjectProperty",
                "start": 202,
                "end": 224,
                "loc": {
                  "start": {
                    "line": 7,
                    "column": 2
                  },
                  "end": {
                    "line": 7,
                    "column": 24
                  }
                },
                "method": false,
                "shorthand": false,
                "computed": false,
                "key": {
                  "type": "Identifier",
                  "start": 202,
                  "end": 205,
                  "loc": {
                    "start": {
                      "line": 7,
                      "column": 2
                    },
                    "end": {
                      "line": 7,
                      "column": 5
                    }
                  },
                  "name": "all"
                },
                "value": {
                  "type": "Identifier",
                  "start": 207,
                  "end": 224,
                  "loc": {
                    "start": {
                      "line": 7,
                      "column": 7
                    },
                    "end": {
                      "line": 7,
                      "column": 24
                    }
                  },
                  "name": "transformersNames"
                }
              },
              {
                "type": "ObjectProperty",
                "start": 228,
                "end": 242,
                "loc": {
                  "start": {
                    "line": 8,
                    "column": 2
                  },
                  "end": {
                    "line": 8,
                    "column": 16
                  }
                },
                "method": false,
                "shorthand": false,
                "computed": false,
                "key": {
                  "type": "Identifier",
                  "start": 228,
                  "end": 234,
                  "loc": {
                    "start": {
                      "line": 8,
                      "column": 2
                    },
                    "end": {
                      "line": 8,
                      "column": 8
                    }
                  },
                  "name": "random"
                },
                "value": {
                  "type": "Identifier",
                  "start": 236,
                  "end": 242,
                  "loc": {
                    "start": {
                      "line": 8,
                      "column": 10
                    },
                    "end": {
                      "line": 8,
                      "column": 16
                    }
                  },
                  "name": "random"
                }
              }
            ]
          }
        }
      },
      {
        "type": "FunctionDeclaration",
        "start": 247,
        "end": 481,
        "loc": {
          "start": {
            "line": 11,
            "column": 0
          },
          "end": {
            "line": 21,
            "column": 1
          }
        },
        "id": {
          "type": "Identifier",
          "start": 256,
          "end": 262,
          "loc": {
            "start": {
              "line": 11,
              "column": 9
            },
            "end": {
              "line": 11,
              "column": 15
            }
          },
          "name": "random"
        },
        "generator": false,
        "expression": false,
        "async": false,
        "params": [
          {
            "type": "Identifier",
            "start": 263,
            "end": 269,
            "loc": {
              "start": {
                "line": 11,
                "column": 16
              },
              "end": {
                "line": 11,
                "column": 22
              }
            },
            "name": "number"
          }
        ],
        "body": {
          "type": "BlockStatement",
          "start": 271,
          "end": 481,
          "loc": {
            "start": {
              "line": 11,
              "column": 24
            },
            "end": {
              "line": 21,
              "column": 1
            }
          },
          "body": [
            {
              "type": "IfStatement",
              "start": 275,
              "end": 479,
              "loc": {
                "start": {
                  "line": 12,
                  "column": 2
                },
                "end": {
                  "line": 20,
                  "column": 3
                }
              },
              "test": {
                "type": "BinaryExpression",
                "start": 279,
                "end": 299,
                "loc": {
                  "start": {
                    "line": 12,
                    "column": 6
                  },
                  "end": {
                    "line": 12,
                    "column": 26
                  }
                },
                "left": {
                  "type": "Identifier",
                  "start": 279,
                  "end": 285,
                  "loc": {
                    "start": {
                      "line": 12,
                      "column": 6
                    },
                    "end": {
                      "line": 12,
                      "column": 12
                    }
                  },
                  "name": "number"
                },
                "operator": "===",
                "right": {
                  "type": "Identifier",
                  "start": 290,
                  "end": 299,
                  "loc": {
                    "start": {
                      "line": 12,
                      "column": 17
                    },
                    "end": {
                      "line": 12,
                      "column": 26
                    }
                  },
                  "name": "undefined"
                }
              },
              "consequent": {
                "type": "BlockStatement",
                "start": 301,
                "end": 333,
                "loc": {
                  "start": {
                    "line": 12,
                    "column": 28
                  },
                  "end": {
                    "line": 14,
                    "column": 3
                  }
                },
                "body": [
                  {
                    "type": "ReturnStatement",
                    "start": 307,
                    "end": 329,
                    "loc": {
                      "start": {
                        "line": 13,
                        "column": 4
                      },
                      "end": {
                        "line": 13,
                        "column": 26
                      }
                    },
                    "argument": {
                      "type": "CallExpression",
                      "start": 314,
                      "end": 329,
                      "loc": {
                        "start": {
                          "line": 13,
                          "column": 11
                        },
                        "end": {
                          "line": 13,
                          "column": 26
                        }
                      },
                      "callee": {
                        "type": "Identifier",
                        "start": 314,
                        "end": 327,
                        "loc": {
                          "start": {
                            "line": 13,
                            "column": 11
                          },
                          "end": {
                            "line": 13,
                            "column": 24
                          }
                        },
                        "name": "getRandomItem"
                      },
                      "arguments": []
                    }
                  }
                ],
                "directives": []
              },
              "alternate": {
                "type": "BlockStatement",
                "start": 339,
                "end": 479,
                "loc": {
                  "start": {
                    "line": 14,
                    "column": 9
                  },
                  "end": {
                    "line": 20,
                    "column": 3
                  }
                },
                "body": [
                  {
                    "type": "VariableDeclaration",
                    "start": 345,
                    "end": 367,
                    "loc": {
                      "start": {
                        "line": 15,
                        "column": 4
                      },
                      "end": {
                        "line": 15,
                        "column": 26
                      }
                    },
                    "declarations": [
                      {
                        "type": "VariableDeclarator",
                        "start": 351,
                        "end": 367,
                        "loc": {
                          "start": {
                            "line": 15,
                            "column": 10
                          },
                          "end": {
                            "line": 15,
                            "column": 26
                          }
                        },
                        "id": {
                          "type": "Identifier",
                          "start": 351,
                          "end": 362,
                          "loc": {
                            "start": {
                              "line": 15,
                              "column": 10
                            },
                            "end": {
                              "line": 15,
                              "column": 21
                            }
                          },
                          "name": "randomItems"
                        },
                        "init": {
                          "type": "ArrayExpression",
                          "start": 365,
                          "end": 367,
                          "loc": {
                            "start": {
                              "line": 15,
                              "column": 24
                            },
                            "end": {
                              "line": 15,
                              "column": 26
                            }
                          },
                          "elements": []
                        }
                      }
                    ],
                    "kind": "const"
                  },
                  {
                    "type": "ForStatement",
                    "start": 372,
                    "end": 452,
                    "loc": {
                      "start": {
                        "line": 16,
                        "column": 4
                      },
                      "end": {
                        "line": 18,
                        "column": 5
                      }
                    },
                    "init": {
                      "type": "VariableDeclaration",
                      "start": 377,
                      "end": 386,
                      "loc": {
                        "start": {
                          "line": 16,
                          "column": 9
                        },
                        "end": {
                          "line": 16,
                          "column": 18
                        }
                      },
                      "declarations": [
                        {
                          "type": "VariableDeclarator",
                          "start": 381,
                          "end": 386,
                          "loc": {
                            "start": {
                              "line": 16,
                              "column": 13
                            },
                            "end": {
                              "line": 16,
                              "column": 18
                            }
                          },
                          "id": {
                            "type": "Identifier",
                            "start": 381,
                            "end": 382,
                            "loc": {
                              "start": {
                                "line": 16,
                                "column": 13
                              },
                              "end": {
                                "line": 16,
                                "column": 14
                              }
                            },
                            "name": "i"
                          },
                          "init": {
                            "type": "NumericLiteral",
                            "start": 385,
                            "end": 386,
                            "loc": {
                              "start": {
                                "line": 16,
                                "column": 17
                              },
                              "end": {
                                "line": 16,
                                "column": 18
                              }
                            },
                            "extra": {
                              "rawValue": 0,
                              "raw": "0"
                            },
                            "value": 0
                          }
                        }
                      ],
                      "kind": "let"
                    },
                    "test": {
                      "type": "BinaryExpression",
                      "start": 388,
                      "end": 398,
                      "loc": {
                        "start": {
                          "line": 16,
                          "column": 20
                        },
                        "end": {
                          "line": 16,
                          "column": 30
                        }
                      },
                      "left": {
                        "type": "Identifier",
                        "start": 388,
                        "end": 389,
                        "loc": {
                          "start": {
                            "line": 16,
                            "column": 20
                          },
                          "end": {
                            "line": 16,
                            "column": 21
                          }
                        },
                        "name": "i"
                      },
                      "operator": "<",
                      "right": {
                        "type": "Identifier",
                        "start": 392,
                        "end": 398,
                        "loc": {
                          "start": {
                            "line": 16,
                            "column": 24
                          },
                          "end": {
                            "line": 16,
                            "column": 30
                          }
                        },
                        "name": "number"
                      }
                    },
                    "update": {
                      "type": "UpdateExpression",
                      "start": 400,
                      "end": 403,
                      "loc": {
                        "start": {
                          "line": 16,
                          "column": 32
                        },
                        "end": {
                          "line": 16,
                          "column": 35
                        }
                      },
                      "operator": "++",
                      "prefix": false,
                      "argument": {
                        "type": "Identifier",
                        "start": 400,
                        "end": 401,
                        "loc": {
                          "start": {
                            "line": 16,
                            "column": 32
                          },
                          "end": {
                            "line": 16,
                            "column": 33
                          }
                        },
                        "name": "i"
                      }
                    },
                    "body": {
                      "type": "BlockStatement",
                      "start": 405,
                      "end": 452,
                      "loc": {
                        "start": {
                          "line": 16,
                          "column": 37
                        },
                        "end": {
                          "line": 18,
                          "column": 5
                        }
                      },
                      "body": [
                        {
                          "type": "ExpressionStatement",
                          "start": 413,
                          "end": 446,
                          "loc": {
                            "start": {
                              "line": 17,
                              "column": 6
                            },
                            "end": {
                              "line": 17,
                              "column": 39
                            }
                          },
                          "expression": {
                            "type": "CallExpression",
                            "start": 413,
                            "end": 446,
                            "loc": {
                              "start": {
                                "line": 17,
                                "column": 6
                              },
                              "end": {
                                "line": 17,
                                "column": 39
                              }
                            },
                            "callee": {
                              "type": "MemberExpression",
                              "start": 413,
                              "end": 429,
                              "loc": {
                                "start": {
                                  "line": 17,
                                  "column": 6
                                },
                                "end": {
                                  "line": 17,
                                  "column": 22
                                }
                              },
                              "object": {
                                "type": "Identifier",
                                "start": 413,
                                "end": 424,
                                "loc": {
                                  "start": {
                                    "line": 17,
                                    "column": 6
                                  },
                                  "end": {
                                    "line": 17,
                                    "column": 17
                                  }
                                },
                                "name": "randomItems"
                              },
                              "property": {
                                "type": "Identifier",
                                "start": 425,
                                "end": 429,
                                "loc": {
                                  "start": {
                                    "line": 17,
                                    "column": 18
                                  },
                                  "end": {
                                    "line": 17,
                                    "column": 22
                                  }
                                },
                                "name": "push"
                              },
                              "computed": false
                            },
                            "arguments": [
                              {
                                "type": "CallExpression",
                                "start": 430,
                                "end": 445,
                                "loc": {
                                  "start": {
                                    "line": 17,
                                    "column": 23
                                  },
                                  "end": {
                                    "line": 17,
                                    "column": 38
                                  }
                                },
                                "callee": {
                                  "type": "Identifier",
                                  "start": 430,
                                  "end": 443,
                                  "loc": {
                                    "start": {
                                      "line": 17,
                                      "column": 23
                                    },
                                    "end": {
                                      "line": 17,
                                      "column": 36
                                    }
                                  },
                                  "name": "getRandomItem"
                                },
                                "arguments": []
                              }
                            ]
                          }
                        }
                      ],
                      "directives": []
                    }
                  },
                  {
                    "type": "ReturnStatement",
                    "start": 457,
                    "end": 475,
                    "loc": {
                      "start": {
                        "line": 19,
                        "column": 4
                      },
                      "end": {
                        "line": 19,
                        "column": 22
                      }
                    },
                    "argument": {
                      "type": "Identifier",
                      "start": 464,
                      "end": 475,
                      "loc": {
                        "start": {
                          "line": 19,
                          "column": 11
                        },
                        "end": {
                          "line": 19,
                          "column": 22
                        }
                      },
                      "name": "randomItems"
                    }
                  }
                ],
                "directives": []
              }
            }
          ],
          "directives": []
        }
      }
    ],
    "directives": []
  },
  "comments": [],
  "tokens": [
    {
      "type": {
        "label": "const",
        "keyword": "const",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "const",
      "start": 0,
      "end": 5,
      "loc": {
        "start": {
          "line": 1,
          "column": 0
        },
        "end": {
          "line": 1,
          "column": 5
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "uniqueRandomArray",
      "start": 6,
      "end": 23,
      "loc": {
        "start": {
          "line": 1,
          "column": 6
        },
        "end": {
          "line": 1,
          "column": 23
        }
      }
    },
    {
      "type": {
        "label": "=",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": true,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "=",
      "start": 24,
      "end": 25,
      "loc": {
        "start": {
          "line": 1,
          "column": 24
        },
        "end": {
          "line": 1,
          "column": 25
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "require",
      "start": 26,
      "end": 33,
      "loc": {
        "start": {
          "line": 1,
          "column": 26
        },
        "end": {
          "line": 1,
          "column": 33
        }
      }
    },
    {
      "type": {
        "label": "(",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 33,
      "end": 34,
      "loc": {
        "start": {
          "line": 1,
          "column": 33
        },
        "end": {
          "line": 1,
          "column": 34
        }
      }
    },
    {
      "type": {
        "label": "string",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "unique-random-array",
      "start": 34,
      "end": 55,
      "loc": {
        "start": {
          "line": 1,
          "column": 34
        },
        "end": {
          "line": 1,
          "column": 55
        }
      }
    },
    {
      "type": {
        "label": ")",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 55,
      "end": 56,
      "loc": {
        "start": {
          "line": 1,
          "column": 55
        },
        "end": {
          "line": 1,
          "column": 56
        }
      }
    },
    {
      "type": {
        "label": "const",
        "keyword": "const",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "const",
      "start": 58,
      "end": 63,
      "loc": {
        "start": {
          "line": 3,
          "column": 0
        },
        "end": {
          "line": 3,
          "column": 5
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "transformersNames",
      "start": 64,
      "end": 81,
      "loc": {
        "start": {
          "line": 3,
          "column": 6
        },
        "end": {
          "line": 3,
          "column": 23
        }
      }
    },
    {
      "type": {
        "label": "=",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": true,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "=",
      "start": 82,
      "end": 83,
      "loc": {
        "start": {
          "line": 3,
          "column": 24
        },
        "end": {
          "line": 3,
          "column": 25
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "require",
      "start": 84,
      "end": 91,
      "loc": {
        "start": {
          "line": 3,
          "column": 26
        },
        "end": {
          "line": 3,
          "column": 33
        }
      }
    },
    {
      "type": {
        "label": "(",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 91,
      "end": 92,
      "loc": {
        "start": {
          "line": 3,
          "column": 33
        },
        "end": {
          "line": 3,
          "column": 34
        }
      }
    },
    {
      "type": {
        "label": "string",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "./transformers-names.json",
      "start": 92,
      "end": 119,
      "loc": {
        "start": {
          "line": 3,
          "column": 34
        },
        "end": {
          "line": 3,
          "column": 61
        }
      }
    },
    {
      "type": {
        "label": ")",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 119,
      "end": 120,
      "loc": {
        "start": {
          "line": 3,
          "column": 61
        },
        "end": {
          "line": 3,
          "column": 62
        }
      }
    },
    {
      "type": {
        "label": "const",
        "keyword": "const",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "const",
      "start": 121,
      "end": 126,
      "loc": {
        "start": {
          "line": 4,
          "column": 0
        },
        "end": {
          "line": 4,
          "column": 5
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "getRandomItem",
      "start": 127,
      "end": 140,
      "loc": {
        "start": {
          "line": 4,
          "column": 6
        },
        "end": {
          "line": 4,
          "column": 19
        }
      }
    },
    {
      "type": {
        "label": "=",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": true,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "=",
      "start": 141,
      "end": 142,
      "loc": {
        "start": {
          "line": 4,
          "column": 20
        },
        "end": {
          "line": 4,
          "column": 21
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "uniqueRandomArray",
      "start": 143,
      "end": 160,
      "loc": {
        "start": {
          "line": 4,
          "column": 22
        },
        "end": {
          "line": 4,
          "column": 39
        }
      }
    },
    {
      "type": {
        "label": "(",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 160,
      "end": 161,
      "loc": {
        "start": {
          "line": 4,
          "column": 39
        },
        "end": {
          "line": 4,
          "column": 40
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "transformersNames",
      "start": 161,
      "end": 178,
      "loc": {
        "start": {
          "line": 4,
          "column": 40
        },
        "end": {
          "line": 4,
          "column": 57
        }
      }
    },
    {
      "type": {
        "label": ")",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 178,
      "end": 179,
      "loc": {
        "start": {
          "line": 4,
          "column": 57
        },
        "end": {
          "line": 4,
          "column": 58
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "module",
      "start": 181,
      "end": 187,
      "loc": {
        "start": {
          "line": 6,
          "column": 0
        },
        "end": {
          "line": 6,
          "column": 6
        }
      }
    },
    {
      "type": {
        "label": ".",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 187,
      "end": 188,
      "loc": {
        "start": {
          "line": 6,
          "column": 6
        },
        "end": {
          "line": 6,
          "column": 7
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "exports",
      "start": 188,
      "end": 195,
      "loc": {
        "start": {
          "line": 6,
          "column": 7
        },
        "end": {
          "line": 6,
          "column": 14
        }
      }
    },
    {
      "type": {
        "label": "=",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": true,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "=",
      "start": 196,
      "end": 197,
      "loc": {
        "start": {
          "line": 6,
          "column": 15
        },
        "end": {
          "line": 6,
          "column": 16
        }
      }
    },
    {
      "type": {
        "label": "{",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 198,
      "end": 199,
      "loc": {
        "start": {
          "line": 6,
          "column": 17
        },
        "end": {
          "line": 6,
          "column": 18
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "all",
      "start": 202,
      "end": 205,
      "loc": {
        "start": {
          "line": 7,
          "column": 2
        },
        "end": {
          "line": 7,
          "column": 5
        }
      }
    },
    {
      "type": {
        "label": ":",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 205,
      "end": 206,
      "loc": {
        "start": {
          "line": 7,
          "column": 5
        },
        "end": {
          "line": 7,
          "column": 6
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "transformersNames",
      "start": 207,
      "end": 224,
      "loc": {
        "start": {
          "line": 7,
          "column": 7
        },
        "end": {
          "line": 7,
          "column": 24
        }
      }
    },
    {
      "type": {
        "label": ",",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 224,
      "end": 225,
      "loc": {
        "start": {
          "line": 7,
          "column": 24
        },
        "end": {
          "line": 7,
          "column": 25
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "random",
      "start": 228,
      "end": 234,
      "loc": {
        "start": {
          "line": 8,
          "column": 2
        },
        "end": {
          "line": 8,
          "column": 8
        }
      }
    },
    {
      "type": {
        "label": ":",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 234,
      "end": 235,
      "loc": {
        "start": {
          "line": 8,
          "column": 8
        },
        "end": {
          "line": 8,
          "column": 9
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "random",
      "start": 236,
      "end": 242,
      "loc": {
        "start": {
          "line": 8,
          "column": 10
        },
        "end": {
          "line": 8,
          "column": 16
        }
      }
    },
    {
      "type": {
        "label": ",",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 242,
      "end": 243,
      "loc": {
        "start": {
          "line": 8,
          "column": 16
        },
        "end": {
          "line": 8,
          "column": 17
        }
      }
    },
    {
      "type": {
        "label": "}",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 244,
      "end": 245,
      "loc": {
        "start": {
          "line": 9,
          "column": 0
        },
        "end": {
          "line": 9,
          "column": 1
        }
      }
    },
    {
      "type": {
        "label": "function",
        "keyword": "function",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "function",
      "start": 247,
      "end": 255,
      "loc": {
        "start": {
          "line": 11,
          "column": 0
        },
        "end": {
          "line": 11,
          "column": 8
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "random",
      "start": 256,
      "end": 262,
      "loc": {
        "start": {
          "line": 11,
          "column": 9
        },
        "end": {
          "line": 11,
          "column": 15
        }
      }
    },
    {
      "type": {
        "label": "(",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 262,
      "end": 263,
      "loc": {
        "start": {
          "line": 11,
          "column": 15
        },
        "end": {
          "line": 11,
          "column": 16
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "number",
      "start": 263,
      "end": 269,
      "loc": {
        "start": {
          "line": 11,
          "column": 16
        },
        "end": {
          "line": 11,
          "column": 22
        }
      }
    },
    {
      "type": {
        "label": ")",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 269,
      "end": 270,
      "loc": {
        "start": {
          "line": 11,
          "column": 22
        },
        "end": {
          "line": 11,
          "column": 23
        }
      }
    },
    {
      "type": {
        "label": "{",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 271,
      "end": 272,
      "loc": {
        "start": {
          "line": 11,
          "column": 24
        },
        "end": {
          "line": 11,
          "column": 25
        }
      }
    },
    {
      "type": {
        "label": "if",
        "keyword": "if",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "if",
      "start": 275,
      "end": 277,
      "loc": {
        "start": {
          "line": 12,
          "column": 2
        },
        "end": {
          "line": 12,
          "column": 4
        }
      }
    },
    {
      "type": {
        "label": "(",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 278,
      "end": 279,
      "loc": {
        "start": {
          "line": 12,
          "column": 5
        },
        "end": {
          "line": 12,
          "column": 6
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "number",
      "start": 279,
      "end": 285,
      "loc": {
        "start": {
          "line": 12,
          "column": 6
        },
        "end": {
          "line": 12,
          "column": 12
        }
      }
    },
    {
      "type": {
        "label": "==/!=",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": 6,
        "updateContext": null
      },
      "value": "===",
      "start": 286,
      "end": 289,
      "loc": {
        "start": {
          "line": 12,
          "column": 13
        },
        "end": {
          "line": 12,
          "column": 16
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "undefined",
      "start": 290,
      "end": 299,
      "loc": {
        "start": {
          "line": 12,
          "column": 17
        },
        "end": {
          "line": 12,
          "column": 26
        }
      }
    },
    {
      "type": {
        "label": ")",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 299,
      "end": 300,
      "loc": {
        "start": {
          "line": 12,
          "column": 26
        },
        "end": {
          "line": 12,
          "column": 27
        }
      }
    },
    {
      "type": {
        "label": "{",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 301,
      "end": 302,
      "loc": {
        "start": {
          "line": 12,
          "column": 28
        },
        "end": {
          "line": 12,
          "column": 29
        }
      }
    },
    {
      "type": {
        "label": "return",
        "keyword": "return",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "return",
      "start": 307,
      "end": 313,
      "loc": {
        "start": {
          "line": 13,
          "column": 4
        },
        "end": {
          "line": 13,
          "column": 10
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "getRandomItem",
      "start": 314,
      "end": 327,
      "loc": {
        "start": {
          "line": 13,
          "column": 11
        },
        "end": {
          "line": 13,
          "column": 24
        }
      }
    },
    {
      "type": {
        "label": "(",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 327,
      "end": 328,
      "loc": {
        "start": {
          "line": 13,
          "column": 24
        },
        "end": {
          "line": 13,
          "column": 25
        }
      }
    },
    {
      "type": {
        "label": ")",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 328,
      "end": 329,
      "loc": {
        "start": {
          "line": 13,
          "column": 25
        },
        "end": {
          "line": 13,
          "column": 26
        }
      }
    },
    {
      "type": {
        "label": "}",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 332,
      "end": 333,
      "loc": {
        "start": {
          "line": 14,
          "column": 2
        },
        "end": {
          "line": 14,
          "column": 3
        }
      }
    },
    {
      "type": {
        "label": "else",
        "keyword": "else",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "else",
      "start": 334,
      "end": 338,
      "loc": {
        "start": {
          "line": 14,
          "column": 4
        },
        "end": {
          "line": 14,
          "column": 8
        }
      }
    },
    {
      "type": {
        "label": "{",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 339,
      "end": 340,
      "loc": {
        "start": {
          "line": 14,
          "column": 9
        },
        "end": {
          "line": 14,
          "column": 10
        }
      }
    },
    {
      "type": {
        "label": "const",
        "keyword": "const",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "const",
      "start": 345,
      "end": 350,
      "loc": {
        "start": {
          "line": 15,
          "column": 4
        },
        "end": {
          "line": 15,
          "column": 9
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "randomItems",
      "start": 351,
      "end": 362,
      "loc": {
        "start": {
          "line": 15,
          "column": 10
        },
        "end": {
          "line": 15,
          "column": 21
        }
      }
    },
    {
      "type": {
        "label": "=",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": true,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "=",
      "start": 363,
      "end": 364,
      "loc": {
        "start": {
          "line": 15,
          "column": 22
        },
        "end": {
          "line": 15,
          "column": 23
        }
      }
    },
    {
      "type": {
        "label": "[",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 365,
      "end": 366,
      "loc": {
        "start": {
          "line": 15,
          "column": 24
        },
        "end": {
          "line": 15,
          "column": 25
        }
      }
    },
    {
      "type": {
        "label": "]",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 366,
      "end": 367,
      "loc": {
        "start": {
          "line": 15,
          "column": 25
        },
        "end": {
          "line": 15,
          "column": 26
        }
      }
    },
    {
      "type": {
        "label": "for",
        "keyword": "for",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": true,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "for",
      "start": 372,
      "end": 375,
      "loc": {
        "start": {
          "line": 16,
          "column": 4
        },
        "end": {
          "line": 16,
          "column": 7
        }
      }
    },
    {
      "type": {
        "label": "(",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 376,
      "end": 377,
      "loc": {
        "start": {
          "line": 16,
          "column": 8
        },
        "end": {
          "line": 16,
          "column": 9
        }
      }
    },
    {
      "type": {
        "label": "let",
        "keyword": "let",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "let",
      "start": 377,
      "end": 380,
      "loc": {
        "start": {
          "line": 16,
          "column": 9
        },
        "end": {
          "line": 16,
          "column": 12
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "i",
      "start": 381,
      "end": 382,
      "loc": {
        "start": {
          "line": 16,
          "column": 13
        },
        "end": {
          "line": 16,
          "column": 14
        }
      }
    },
    {
      "type": {
        "label": "=",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": true,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "=",
      "start": 383,
      "end": 384,
      "loc": {
        "start": {
          "line": 16,
          "column": 15
        },
        "end": {
          "line": 16,
          "column": 16
        }
      }
    },
    {
      "type": {
        "label": "num",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": 0,
      "start": 385,
      "end": 386,
      "loc": {
        "start": {
          "line": 16,
          "column": 17
        },
        "end": {
          "line": 16,
          "column": 18
        }
      }
    },
    {
      "type": {
        "label": ";",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 386,
      "end": 387,
      "loc": {
        "start": {
          "line": 16,
          "column": 18
        },
        "end": {
          "line": 16,
          "column": 19
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "i",
      "start": 388,
      "end": 389,
      "loc": {
        "start": {
          "line": 16,
          "column": 20
        },
        "end": {
          "line": 16,
          "column": 21
        }
      }
    },
    {
      "type": {
        "label": "</>",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": 7,
        "updateContext": null
      },
      "value": "<",
      "start": 390,
      "end": 391,
      "loc": {
        "start": {
          "line": 16,
          "column": 22
        },
        "end": {
          "line": 16,
          "column": 23
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "number",
      "start": 392,
      "end": 398,
      "loc": {
        "start": {
          "line": 16,
          "column": 24
        },
        "end": {
          "line": 16,
          "column": 30
        }
      }
    },
    {
      "type": {
        "label": ";",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 398,
      "end": 399,
      "loc": {
        "start": {
          "line": 16,
          "column": 30
        },
        "end": {
          "line": 16,
          "column": 31
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "i",
      "start": 400,
      "end": 401,
      "loc": {
        "start": {
          "line": 16,
          "column": 32
        },
        "end": {
          "line": 16,
          "column": 33
        }
      }
    },
    {
      "type": {
        "label": "++/--",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": true,
        "postfix": true,
        "binop": null
      },
      "value": "++",
      "start": 401,
      "end": 403,
      "loc": {
        "start": {
          "line": 16,
          "column": 33
        },
        "end": {
          "line": 16,
          "column": 35
        }
      }
    },
    {
      "type": {
        "label": ")",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 403,
      "end": 404,
      "loc": {
        "start": {
          "line": 16,
          "column": 35
        },
        "end": {
          "line": 16,
          "column": 36
        }
      }
    },
    {
      "type": {
        "label": "{",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 405,
      "end": 406,
      "loc": {
        "start": {
          "line": 16,
          "column": 37
        },
        "end": {
          "line": 16,
          "column": 38
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "randomItems",
      "start": 413,
      "end": 424,
      "loc": {
        "start": {
          "line": 17,
          "column": 6
        },
        "end": {
          "line": 17,
          "column": 17
        }
      }
    },
    {
      "type": {
        "label": ".",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 424,
      "end": 425,
      "loc": {
        "start": {
          "line": 17,
          "column": 17
        },
        "end": {
          "line": 17,
          "column": 18
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "push",
      "start": 425,
      "end": 429,
      "loc": {
        "start": {
          "line": 17,
          "column": 18
        },
        "end": {
          "line": 17,
          "column": 22
        }
      }
    },
    {
      "type": {
        "label": "(",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 429,
      "end": 430,
      "loc": {
        "start": {
          "line": 17,
          "column": 22
        },
        "end": {
          "line": 17,
          "column": 23
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "getRandomItem",
      "start": 430,
      "end": 443,
      "loc": {
        "start": {
          "line": 17,
          "column": 23
        },
        "end": {
          "line": 17,
          "column": 36
        }
      }
    },
    {
      "type": {
        "label": "(",
        "beforeExpr": true,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 443,
      "end": 444,
      "loc": {
        "start": {
          "line": 17,
          "column": 36
        },
        "end": {
          "line": 17,
          "column": 37
        }
      }
    },
    {
      "type": {
        "label": ")",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 444,
      "end": 445,
      "loc": {
        "start": {
          "line": 17,
          "column": 37
        },
        "end": {
          "line": 17,
          "column": 38
        }
      }
    },
    {
      "type": {
        "label": ")",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 445,
      "end": 446,
      "loc": {
        "start": {
          "line": 17,
          "column": 38
        },
        "end": {
          "line": 17,
          "column": 39
        }
      }
    },
    {
      "type": {
        "label": "}",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 451,
      "end": 452,
      "loc": {
        "start": {
          "line": 18,
          "column": 4
        },
        "end": {
          "line": 18,
          "column": 5
        }
      }
    },
    {
      "type": {
        "label": "return",
        "keyword": "return",
        "beforeExpr": true,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "value": "return",
      "start": 457,
      "end": 463,
      "loc": {
        "start": {
          "line": 19,
          "column": 4
        },
        "end": {
          "line": 19,
          "column": 10
        }
      }
    },
    {
      "type": {
        "label": "name",
        "beforeExpr": false,
        "startsExpr": true,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "value": "randomItems",
      "start": 464,
      "end": 475,
      "loc": {
        "start": {
          "line": 19,
          "column": 11
        },
        "end": {
          "line": 19,
          "column": 22
        }
      }
    },
    {
      "type": {
        "label": "}",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 478,
      "end": 479,
      "loc": {
        "start": {
          "line": 20,
          "column": 2
        },
        "end": {
          "line": 20,
          "column": 3
        }
      }
    },
    {
      "type": {
        "label": "}",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null
      },
      "start": 480,
      "end": 481,
      "loc": {
        "start": {
          "line": 21,
          "column": 0
        },
        "end": {
          "line": 21,
          "column": 1
        }
      }
    },
    {
      "type": {
        "label": "eof",
        "beforeExpr": false,
        "startsExpr": false,
        "rightAssociative": false,
        "isLoop": false,
        "isAssign": false,
        "prefix": false,
        "postfix": false,
        "binop": null,
        "updateContext": null
      },
      "start": 482,
      "end": 482,
      "loc": {
        "start": {
          "line": 22,
          "column": 0
        },
        "end": {
          "line": 22,
          "column": 0
        }
      }
    }
  ]
}

Code for computers

For humans...

Exploring ASTs

For humans, for computers, for humans

How

Do I use them?

Let's try it out!

  1. ESLint Plugin: setup / complete
  2. Babel Plugin: setup / complete
  3. Codemod: setup / complete

Resources

Thank you!

Writing custom Babel and ESLint plugins

By Kent C. Dodds

Writing custom Babel and ESLint plugins

The Abstract Syntax Tree. It sounds a lot worse than it is. It’s actually quite simple and enables some powerful tools. BabelJS uses it to transform your code from ES.Next to ES5. ESLint uses it to lint your code. And with a knowledge of how it works, you can extend these and other tools to do some mind bustingly powerful things. Prepare to be amazed by ASTs!

  • 12,815