Recently there have been several exciting projects that provide support for upcoming ES6 and ES7 features. One way of implementing parsers like this is with a context-free grammar. A popular way to do this is with Jison, but Gabriele Cannata sent in a new library called Jacob (GitHub: Canna71/Jacob, License: ISC, npm: jacob).
This means you can define your language or DSL, validate code written with it, and produce abstract syntax trees that can be used to write compilers.
I've written very basic grammar files with Jison before, and I've found that it takes practice to get the hang of it. The best place to get started is with real examples, so have a look at the Jacob examples folder. Also, the JSON definition on the json.org site will help you to understand how something you're familiar with maps to a formal grammar.
If you've ever wondered how people write things like transpilers in a formal and structured way, then it's worth checking out Jison and Jacob.